-
Notifications
You must be signed in to change notification settings - Fork 29
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
feat(anta): Added test case to verify dynamic vlans source #978
base: main
Are you sure you want to change the base?
feat(anta): Added test case to verify dynamic vlans source #978
Conversation
Quality Gate passedIssues Measures |
CodSpeed Performance ReportMerging #978 will not alter performanceComparing Summary
|
This test performs the following checks for each specified routerpath: | ||
1. Verifies that the dynamic VLANs are configured. | ||
2. Verifies that the dynamic VLANs are active only within the expected source. | ||
Expected Results |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check the documentation(mkdocs) to ensure it highlights the expected results.
dynamic_vlans = command_output.get("dynamicVlans", {}) | ||
|
||
actual_source = [source for source, data in dynamic_vlans.items() if data.get("vlanIds")] | ||
# If the dynamic vlans are not configured, test fails. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
skipping the test.
|
||
expected_source = self.inputs.source | ||
# If dynamic VLANs are not active for specified source, test fails | ||
if not set(actual_source).issubset(expected_source): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be exact match, right?
1. Verifies that the dynamic VLANs are configured. | ||
2. Verifies that the dynamic VLANs are active only within the expected source. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1. Verifies that the dynamic VLANs are configured. | |
2. Verifies that the dynamic VLANs are active only within the expected source. | |
1. Ensures that dynamic VLANs are properly configured in the system. | |
2. Confirms that dynamic VLANs are active only within their designated sources. |
expected_source = self.inputs.source | ||
# If dynamic VLANs are not active for specified source, test fails | ||
if not set(actual_source).issubset(expected_source): | ||
self.result.is_failure(f"Incorrect source for dynamic VLANs - Expected: {expected_source} Actual: {actual_source}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.result.is_failure(f"Incorrect source for dynamic VLANs - Expected: {expected_source} Actual: {actual_source}") | |
self.result.is_failure(f"Dynamic VLANs are not restricted to given sources - Expected: ', '.join(expected_source)} Actual: {', '.join(actual_source)}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check csv reports.
"""Input model for the VerifyDynamicVlanSource test.""" | ||
|
||
model_config = ConfigDict(extra="forbid") | ||
source: list[str] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may restrict the sources. Also do we really need extra="forbid" ?
"test": VerifyDynamicVlanSource, | ||
"eos_data": [{"dynamicVlans": {"vccbfd": {"vlanIds": [1500]}, "mlagsync": {"vlanIds": [1501]}}}], | ||
"inputs": {"source": ["evpn", "mlagsync"]}, | ||
"expected": {"result": "failure", "messages": ["Incorrect source for dynamic VLANs - Expected: ['evpn', 'mlagsync'] Actual: ['vccbfd', 'mlagsync']"]}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We avoid use of lists, dicts inside the string.
"name": "success-singal-source-found", | ||
"test": VerifyDynamicVlanSource, | ||
"eos_data": [{"dynamicVlans": {"evpn": {"vlanIds": [1199]}, "mlagsync": {"vlanIds": []}}}], | ||
"inputs": {"source": ["evpn", "mlagsync"]}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not see any dynamic VLANs with the input source mlagsync
, yet the test passes.
Description
This test performs the following checks for each specified:
1. Verifies that the dynamic VLANs are configured.
2. Verifies that the dynamic VLANs are active only within the expected source.
Expected Results
----------------
* Success: The test will pass if the dynamic VLANs are active only within the expected source.
* Failure: The test will fail if the dynamic VLANs are not active within the expected source or activated in other sources.
Fixes #864
Checklist:
pre-commit run
)tox -e testenv
)