feat(cli): add --device-tag argument for per-device filtering - #889
Open
ChristopherJHart wants to merge 2 commits into
Open
feat(cli): add --device-tag argument for per-device filtering#889ChristopherJHart wants to merge 2 commits into
ChristopherJHart wants to merge 2 commits into
Conversation
Adds a --device-tag CLI option (also settable via NAC_TEST_DEVICE_TAG env var) that filters test execution to only devices whose 'tags' list in the data model contains the specified value. The value is threaded through CombinedOrchestrator → PyATSOrchestrator → subprocess env vars for both API and D2D test paths. This enables a single set of test scripts to serve dual purposes: migration-scoped (--device-tag migration) and fabric-wide (no flag). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The test_combined_orchestrator_controller tests assert exact kwargs passed to PyATSOrchestrator. Adding device_tag=None to match the new parameter added in the previous commit. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Collaborator
|
Thanks for the PR. I feel this won’t be the last device filter we‘ll need to limit the d2d tests to specific devices, I wonder if we can come up with something more generic which avoids adding multiple options we will need to wire through nac-test. |
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.
Description
Adds a
--device-tagCLI argument (also settable viaNAC_TEST_DEVICE_TAGenv var) that filters test execution to only devices whosetagslist in the data model contains the specified value. This enables a single set of test scripts to serve dual purposes — scoped to specific devices (e.g.,--device-tag migration) or fabric-wide (no flag) — without duplicating test code.Although SD-WAN is the catalyst for this change and the first architecture where the pattern is implemented (driven by an immediate customer need for post-migration validation), the intent is for each architecture to adopt this mechanism to filter operational tests down to a user-defined subset of devices. The CLI argument and env var plumbing are architecture-agnostic; only the per-architecture base class/resolver needs to read the env var and filter accordingly.
Related Issue(s)
Type of Change
Test Framework Affected
Network as Code (NaC) Architecture Affected
SD-WAN is the first implementation. The CLI/orchestrator plumbing is architecture-agnostic — future architectures add filtering by reading
NAC_TEST_DEVICE_TAGin their resolver or base class.Platform Tested
Key Changes
nac_test/cli/main.py): New--device-tagoption withNAC_TEST_DEVICE_TAGenvvar supportnac_test/combined_orchestrator.py): Accepts and storesdevice_tag, forwards to PyATSOrchestratornac_test/pyats_core/orchestrator.py): InjectsNAC_TEST_DEVICE_TAGinto subprocess env for API tests; sets env var before D2D device discoverynac_test/pyats_core/execution/device/device_executor.py): InjectsNAC_TEST_DEVICE_TAGinto D2D subprocess envTesting Done
pytest/pre-commit run -a)Test Commands Used
Checklist
pre-commit run -apasses)Additional Notes
nac-test-pyats-common(companion PR Bump robotframework-pabot from 2.10.0 to 2.11.0 #39) — this PR only handles the CLI argument and env var plumbinggroups = ["migration"]to be excluded from fabric-wide runs via--exclude migration, enabling both device-level AND test-level scoping