Repository navigation
Decouple hotyvalidate from tests.unit.utils - #1145
Merged
Merged
Conversation
wilkmar
force-pushed
the
decouple_hotyvalidate_f_tests
branch
from
September 28, 2026 15:25
1afbec9 to
a933d1f
Compare
wilkmar
force-pushed
the
decouple_hotyvalidate_f_tests
branch
from
September 28, 2026 15:38
a933d1f to
1414795
Compare
wilkmar
force-pushed
the
decouple_hotyvalidate_f_tests
branch
from
October 7, 2026 08:39
1414795 to
8be8ef7
Compare
Member
|
lgtm but need to fix the issue raised by copilot |
wilkmar
force-pushed
the
decouple_hotyvalidate_f_tests
branch
from
October 7, 2026 12:56
8be8ef7 to
9143c75
Compare
wilkmar
force-pushed
the
decouple_hotyvalidate_f_tests
branch
2 times, most recently
from
October 7, 2026 13:41
9143c75 to
4e92803
Compare
Move the scenario-test loading needed by the standalone validator into hotsos.core.ycheck.engine.common instead of importing the unit-test utilities and constructing TemplatedTestGenerator instances. Add TEST_TEMPLATE_SCHEMA and load_test_def() to share YAML loading and top-level key validation with TemplatedTestGenerator. Reject empty or non-mapping YAML values with InvalidFileFormatError before inspecting keys. Preserve KeyError for unknown keys and YAML parser errors for malformed input. Add resolve_target_scenario_path() to map tests under <defs>/tests/scenarios to scenarios under <defs>/scenarios, honouring target-name and optionally reusing an already-loaded test. Require an absolute test path, normalize it and check directory containment with commonpath before loading the test. Restrict non-null target-name overrides to non-empty string basenames, rejecting separators, dot components and NUL characters. Use YDefsLoader discovery and these helpers in hotyvalidate, removing all references to tests.unit.utils. Centralize definitions-root initialization in configure_defs_dir(), shared by both validation methods and the CLI. Preserve an existing HotSOSConfig.plugin_yaml_defs value; otherwise prefer HOTSOS_DEFS_DIR and fall back to <HOTSOS_ROOT>/defs. Raise RuntimeError when no configuration is available, with the CLI reporting the error and exiting nonzero without a traceback. Add regression tests for configuration precedence, root fallback, missing configuration, and direct invocation of both validation methods. Cover template types and keys, nested target mapping, normalized paths, path escapes and invalid target-name overrides. Assisted-By: Claude Opus 4.8 Signed-off-by: Marcin Wilk <marcin.wilk@canonical.com>
wilkmar
force-pushed
the
decouple_hotyvalidate_f_tests
branch
from
October 8, 2026 08:21
4e92803 to
eeab730
Compare
There was a problem hiding this comment.
🟢 Approval recommended
The refactoring preserves existing behavior while adding appropriate validation and regression coverage.
1 open finding
🧠 Review effort: Balanced
Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.


Move the scenario-test loading needed by the standalone validator into hotsos.core.ycheck.engine.common instead of importing the unit-test utilities and constructing TemplatedTestGenerator instances.
Add TEST_TEMPLATE_SCHEMA and load_test_def() to share YAML loading, empty-template rejection and top-level key validation with TemplatedTestGenerator. Add resolve_target_scenario_path() to map a test under /tests/scenarios to its scenario under /scenarios, honouring target-name and optionally reusing an already-loaded test.
Use YDefsLoader discovery and these helpers in hotyvalidate, removing all references to tests.unit.utils. Centralize definitions-root initialization in configure_defs_dir(), shared by both validation methods and the CLI. Preserve an existing HotSOSConfig.plugin_yaml_defs value; otherwise prefer HOTSOS_DEFS_DIR and fall back to <HOTSOS_ROOT>/defs. Raise RuntimeError when no configuration is available, with the CLI reporting the error and exiting nonzero without a traceback.
Add regression tests for configuration precedence, root fallback, missing configuration, and direct invocation of both validation methods with scenario-test discovery and target-name mapping.
Assisted-By: Claude Opus 4.8