Skip to content

feat(config): add tmt.dist-git.enabled-components - #451

Open
bhagyapathak wants to merge 1 commit into
microsoft:mainfrom
bhagyapathak:bhagya/tmt-centralized-metadata
Open

bhagyapathak wants to merge 1 commit into
microsoft:mainfrom
bhagyapathak:bhagya/tmt-centralized-metadata

Conversation

@bhagyapathak

Copy link
Copy Markdown
Contributor

Summary

Adds a top-level [tmt.dist-git] section so a project can list, in one place, the components whose own dist-git TMT tests are enabled:

[tmt.dist-git]
enabled-components = ["bash", "hostname", "selinux-policy", "util-linux"]

Motivation

Today the only way to associate TMT tests with a component is a [tests.<name>] catalog entry (a pinned plan and source) plus a tests.tests reference on the component. That fits external suites, but not packages whose upstream dist-git already ships .fmf/ and plans/: those would need a duplicated source pin per package and one or more edits to component definitions.

For the Azure Linux repo, this keeps a single file (base/comps/tmt.tests.toml) as the source of truth for enablement. Downstream consumers (ControlTower's metadata service, and the test execution engine) can read the list from azldev config dump and run the component's dist-git tests via azldev component prepare-sources + azldev component test --source-dir.

Changes

  • Config: new tmt section with dist-git.enabled-components (string array).
  • Loader: the section is merged across included config files (lists are appended) and carried into the resolved project config, so azldev config dump -f json now emits tmt.distGit.enabledComponents. The field is omitted when unused.
  • Validation: an entry that is not a defined component is an error (undefined component in tmt.dist-git.enabled-components), and duplicates are rejected, including across files.
  • Schema and docs: regenerated schemas/azldev.schema.json, updated the scenario schema snapshots, and documented the section in docs/user/reference/config/tests.md and config-file.md.

Not changed

azldev component test does not read the list. It is policy for callers; azldev's existing behavior is unchanged (with --source-dir and no plan, tmt runs every enabled plan it finds).

Testing

Run locally, matching the CI jobs:

  • mage -v unit: pass.
  • mage -v check static, check mod, check licenses: pass.
  • mage check lint: golangci-lint passes. The editorconfig step was verified against tracked files only, because my working tree has unrelated untracked scratch files.
  • mage -v docs / generate: no diff after regeneration.
  • New tests cover parsing with strict unknown-field rejection, cross-file merge, undefined component, empty and duplicate names (including across files), and the generated schema shape.
  • Checked against the real Azure Linux project: config dump shows the four enabled components, and a typo in the list fails the load with a clear error.

Scenario tests: TestCheckedInSchemasAreUpToDate and the host config generate-schema snapshot pass after the update. The Docker-based scenario tests cannot run on my machine (Docker socket permission denied), so TestSnapshotsContainer_config_generate-schema_stdout_1.snap was updated by copying the host snapshot, which was byte-identical to it before this change. The remaining non-container scenario tests fail identically (27 tests, all the Docker permission error) on an unmodified checkout of main and on this branch, so this change adds no failures. CI will run the full scenario suite.

Related

Azure Linux metadata that uses this section: microsoft/azurelinux#20501.

Add a top-level [tmt.dist-git] section whose enabled-components list names
the components with dist-git TMT tests enabled. Consumers such as
ControlTower can read it from 'azldev config dump' (tmt.distGit.enabledComponents)
without a [tests.<name>] catalog entry or a per-component setting.

- Parse the section, merge it across included config files, and carry it
  into the resolved project config so it appears in 'config dump'.
- Reject names that are not defined components, and duplicates (including
  across files).
- Document the section and regenerate the JSON schema and the schema
  snapshots.

'azldev component test' does not read the list; it is policy for callers.
Copilot AI balanced review requested due to automatic review settings November 26, 2026 11:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Enabled-component validation rejects valid spec-discovered components without explicit config entries, causing config loading to fail and blocking config dump and source preparation.

1 open issue
What changed in this PR

Adds [tmt.dist-git].enabled-components as centralized opt-in metadata for components’ dist-git TMT tests. Downstream consumers can read it through config dump; azldev component test behavior remains unchanged.

Changes:

  • Adds configuration types, cross-file list merging, and resolved dump output.
  • Validates component references, duplicate entries, and empty names.
  • Updates configuration documentation, schema, tests, and schema snapshots.
File Description
schemas/​azldev.schema.json Adds the TMT discovery configuration schema.
scenario/​__snapshots__/​TestSnapshotsContainer_config_generate-schema_stdout_1.snap Updates the container schema snapshot.
scenario/​__snapshots__/​TestSnapshots_config_generate-schema_stdout_1.snap Updates the host schema snapshot.
internal/​projectconfig/​testsuite.go Adds the undefined-component error.
internal/​projectconfig/​project.go Exposes and validates resolved TMT metadata.
internal/​projectconfig/​loader.go Appends enablement lists across config files.
internal/​projectconfig/​loader_test.go Tests merging and reference validation.
internal/​projectconfig/​configfile.go Defines TMT configuration and validation.
internal/​projectconfig/​configfile_test.go Tests parsing and list constraints.
internal/​app/​azldev/​cmds/​config/​schema_test.go Verifies the generated schema shape.
docs/​user/​reference/​config/​tests.md Documents dist-git test enablement metadata.
docs/​user/​reference/​config/​config-file.md Lists the new top-level tmt section.

Review effort: Balanced

Comment on lines +108 to +109
if _, ok := components[name]; !ok {
return fmt.Errorf("%w: %#q", ErrUndefinedTmtDistGitComponent, name)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants