Skip to content
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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

geetanjalimanegslab
Copy link
Collaborator

@geetanjalimanegslab geetanjalimanegslab commented Dec 24, 2024

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:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have run pre-commit for code linting and typing (pre-commit run)
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes (tox -e testenv)

@geetanjalimanegslab geetanjalimanegslab changed the title Issue_864:Added test case to verify dynamic vlans source feat(anta)::Added test case to verify dynamic vlans source Dec 24, 2024
@geetanjalimanegslab geetanjalimanegslab changed the title feat(anta)::Added test case to verify dynamic vlans source feat(anta):Added test case to verify dynamic vlans source Dec 24, 2024
@geetanjalimanegslab geetanjalimanegslab changed the title feat(anta):Added test case to verify dynamic vlans source feat(anta): Added test case to verify dynamic vlans source Dec 24, 2024
Copy link

codspeed-hq bot commented Dec 24, 2024

CodSpeed Performance Report

Merging #978 will not alter performance

Comparing geetanjalimanegslab:test_dynamic_vlans (29babe0) with main (3b97984)

Summary

✅ 22 untouched benchmarks

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
Copy link
Collaborator

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.
Copy link
Collaborator

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):
Copy link
Collaborator

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?

Comment on lines +79 to +80
1. Verifies that the dynamic VLANs are configured.
2. Verifies that the dynamic VLANs are active only within the expected source.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
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}")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
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)}")

Copy link
Collaborator

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]
Copy link
Collaborator

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']"]},
Copy link
Collaborator

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"]},
Copy link
Collaborator

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.

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.

Add the test case to verify dynamic vlans
2 participants