-
Notifications
You must be signed in to change notification settings - Fork 20
feat(projectconfig): accept [tests] and [test-groups] schema in config #229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
bhagyapathak
wants to merge
1
commit into
microsoft:main
Choose a base branch
from
bhagyapathak:bhagya/azldev-test-schema
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,105 @@ | ||
| # Tests and Test Groups | ||
|
|
||
| > **Status:** parse-only. The schema below is accepted and validated for | ||
| > structural correctness, but azldev does not yet resolve references, | ||
| > flatten groups, or run anything from these sections. The resolver and | ||
| > `azldev test` CLI land in a follow-up change. Use [Test Suites](test-suites.md) | ||
| > for executable test configuration today. | ||
|
|
||
| The `[tests]` and `[test-groups]` sections declare framework-agnostic test | ||
| metadata that components and images can target by name. Each test entry | ||
| binds a single test (a pytest run, a LISA case, a TMT plan, | ||
| job, …) to a named identifier; each group entry bundles tests (and | ||
| nested groups) under one name so callers can reference a curated set | ||
| without enumerating every member. | ||
|
|
||
| ## Test Definition | ||
|
|
||
| Each entry under `[tests.<name>]` describes one configuration of one | ||
| runner. Framework-specific options live in a typed subtable | ||
| (`pytest`, `lisa`, `tmt`) whose contents are passed through | ||
| to the runner; their internal schemas are intentionally not validated | ||
| by azldev so frameworks can evolve independently. | ||
|
|
||
| | Field | TOML Key | Type | Required | Description | | ||
| |-------|----------|------|----------|-------------| | ||
| | Type | `type` | string | Yes | Test framework: `pytest`, `lisa`, or `tmt` | | ||
| | Description | `description` | string | No | Human-readable description | | ||
| | Kind | `kind` | string array | No | Free-form hints (e.g. `functional`, `performance`, `bvt`) | | ||
| | Long running | `long-running` | boolean | No | Hints that this test may run for hours | | ||
| | Required capabilities | `required-capabilities` | string array | No | Capability tokens the image must declare for this test to be applicable | | ||
| | Lisa | `lisa` | table | No | LISA-specific configuration (opaque to azldev) | | ||
| | Tmt | `tmt` | table | No | TMT-specific configuration (opaque to azldev) | | ||
| | Pytest | `pytest` | table | No | pytest-specific configuration (opaque to azldev) | | ||
|
|
||
| ## Test Group | ||
|
|
||
| Each entry under `[test-groups.<name>]` names an ordered list of test or | ||
| nested-group references that callers can target as a single unit. | ||
|
|
||
| | Field | TOML Key | Type | Required | Description | | ||
| |-------|----------|------|----------|-------------| | ||
| | Description | `description` | string | No | Human-readable description | | ||
| | Tests | `tests` | array of [TestRef](#test-reference) | No | Ordered members of the group | | ||
|
|
||
| ## Test Reference | ||
|
|
||
| `TestRef` is an inline table with exactly one of `name` or `group`: | ||
|
|
||
| | Field | TOML Key | Type | Description | | ||
| |-------|----------|------|-------------| | ||
| | Name | `name` | string | References a `[tests.<name>]` entry | | ||
| | Group | `group` | string | References a `[test-groups.<name>]` entry | | ||
|
|
||
| Semantic validation (name-vs-group exclusivity, reference resolution, | ||
| cycle detection, capability matching) is deferred to the resolver in | ||
| the follow-up PR. | ||
|
|
||
| ## Referencing from Components and Images | ||
|
|
||
| Components and images both expose a `tests` subtable that holds a list | ||
| of `TestRef`s: | ||
|
|
||
| ```toml | ||
| [components.kernel.tests] | ||
| tests = [{ group = "kernel-bvt" }, { name = "kdump-smoke" }] | ||
|
|
||
| [images.vm-base.tests] | ||
| tests = [{ group = "bvt" }] | ||
| ``` | ||
|
|
||
| > The image `tests` subtable still also accepts the legacy `test-suites` | ||
| > field documented in [Images — Image Tests](images.md#image-tests). | ||
|
|
||
| ## Example | ||
|
|
||
| ```toml | ||
| [tests.bvt-ssh] | ||
| type = "pytest" | ||
| description = "Basic SSH boot verification" | ||
| kind = ["functional", "bvt"] | ||
| required-capabilities = ["ssh"] | ||
| pytest = { working-dir = "tests/bvt", test-paths = ["test_ssh.py"] } | ||
|
|
||
| [tests.kdump-smoke] | ||
| type = "lisa" | ||
| description = "Smoke test for kdump" | ||
| lisa = { case = "kdump.smoke" } | ||
|
|
||
| [test-groups.bvt] | ||
| description = "Build verification tests" | ||
| tests = [ | ||
| { name = "bvt-ssh" }, | ||
| { group = "bvt-extras" }, | ||
| ] | ||
|
|
||
| [test-groups.bvt-extras] | ||
| tests = [{ name = "kdump-smoke" }] | ||
| ``` | ||
|
|
||
| ## Related Resources | ||
|
|
||
| - [Test Suites](test-suites.md) — current executable test configuration | ||
| - [Components](components.md#component-tests) — per-component `tests` field | ||
| - [Images](images.md#image-tests) — per-image `tests` field | ||
| - [Config File Structure](config-file.md) — top-level config layout | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
|
|
||
| package projectconfig | ||
|
|
||
| import ( | ||
| "github.com/invopop/jsonschema" | ||
| ) | ||
|
|
||
| // TestDefinition is the new-shape [tests.X] declaration: one configuration of one | ||
| // runner/harness with framework-specific options. Framework subtables are kept as | ||
| // loosely-typed maps so the resolver can evolve their schemas without requiring | ||
| // matching struct changes here. | ||
| type TestDefinition struct { | ||
| // Type identifies the framework/runner. Required, and constrained to the | ||
| // closed enum in the schema tag at the schema layer. The loader still | ||
| // accepts unknown values permissively; the resolver is the source of truth. | ||
| Type string `toml:"type" json:"type" jsonschema:"required,title=Type,description=Test framework type,enum=pytest,enum=lisa,enum=tmt"` | ||
|
|
||
|
bhagyapathak marked this conversation as resolved.
|
||
| // Human-readable description. | ||
| Description string `toml:"description,omitempty" json:"description,omitempty" jsonschema:"title=Description,description=Description of this test"` | ||
|
|
||
| // Kind hints at what the test exercises (e.g. functional, performance). | ||
| Kind []string `toml:"kind,omitempty" json:"kind,omitempty" jsonschema:"title=Kind,description=Test kind hints (e.g. functional or performance)"` | ||
|
|
||
| // LongRunning hints to schedulers/policy that this test may take a long time. | ||
| LongRunning bool `toml:"long-running,omitempty" json:"longRunning,omitempty" jsonschema:"title=Long running,description=Hints that this test may run for hours"` | ||
|
|
||
| // RequiredCapabilities lists capability tokens an image must declare to be a | ||
| // valid target for this test. Tokens are matched against [ImageCapabilities]. | ||
| RequiredCapabilities []string `toml:"required-capabilities,omitempty" json:"requiredCapabilities,omitempty" jsonschema:"title=Required capabilities,description=Capability tokens the image must declare"` | ||
|
|
||
| // Framework-specific subtables. Kept untyped so framework schema can evolve | ||
| // independently of the dev-tools type definitions. | ||
| Lisa map[string]any `toml:"lisa,omitempty" json:"lisa,omitempty" jsonschema:"title=LISA config,description=LISA-specific configuration"` | ||
| Tmt map[string]any `toml:"tmt,omitempty" json:"tmt,omitempty" jsonschema:"title=TMT config,description=TMT-specific configuration"` | ||
| Pytest map[string]any `toml:"pytest,omitempty" json:"pytest,omitempty" jsonschema:"title=Pytest config,description=pytest-specific configuration"` | ||
| } | ||
|
|
||
| // TestGroup is a [test-groups.X] declaration: a named bundle of test references that | ||
| // images or components can target via a single name. | ||
| type TestGroup struct { | ||
| // Human-readable description. | ||
| Description string `toml:"description,omitempty" json:"description,omitempty" jsonschema:"title=Description,description=Description of this test group"` | ||
|
|
||
| // Tests is the ordered list of test or nested-group references that make up | ||
| // the group's membership. | ||
| Tests []TestRef `toml:"tests,omitempty" json:"tests,omitempty" jsonschema:"title=Tests,description=Member references (each is either {name=...} or {group=...})"` | ||
| } | ||
|
|
||
| // TestRef is a reference to either a test (by name) or another group (by name). | ||
| // Exactly one of Name or Group should be set; semantic validation is the resolver's | ||
| // responsibility. | ||
| type TestRef struct { | ||
| // Name references a [tests.X] entry. | ||
| Name string `toml:"name,omitempty" json:"name,omitempty" jsonschema:"title=Name,description=Name of a test (mutually exclusive with group)"` | ||
|
|
||
| // Group references a [test-groups.X] entry. | ||
| Group string `toml:"group,omitempty" json:"group,omitempty" jsonschema:"title=Group,description=Name of a test group (mutually exclusive with name)"` | ||
| } | ||
|
|
||
| // ComponentTestsConfig holds the new-shape per-component tests block: | ||
| // | ||
| // tests.tests = [{ name = "..." }, { group = "..." }] | ||
| type ComponentTestsConfig struct { | ||
| // Tests is the list of test or group references that apply to the component. | ||
| Tests []TestRef `toml:"tests,omitempty" json:"tests,omitempty" jsonschema:"title=Tests,description=Per-component test or group references"` | ||
|
Comment on lines
+66
to
+67
|
||
| } | ||
|
|
||
| // JSONSchemaExtend tightens the generated schema for [TestRef] so editors can | ||
| // flag refs that set neither or both of name/group. The runtime resolver | ||
| // ([ErrInvalidTestRef]) is the source of truth; this keeps the schema in sync. | ||
| func (TestRef) JSONSchemaExtend(schema *jsonschema.Schema) { | ||
| // Exactly one of name|group: encoded as oneOf with `required` on each and | ||
| // `not` excluding the other, which forbids both `{}` and `{name, group}`. | ||
| schema.OneOf = []*jsonschema.Schema{ | ||
| {Required: []string{"name"}, Not: &jsonschema.Schema{Required: []string{"group"}}}, | ||
| {Required: []string{"group"}, Not: &jsonschema.Schema{Required: []string{"name"}}}, | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.