-
Notifications
You must be signed in to change notification settings - Fork 233
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
Fix(eos_validate_state): ANTA VerifyRoutingProtocolModel now only run if there is BGP configuration #3212
Merged
ClausHolbechArista
merged 7 commits into
aristanetworks:devel
from
carl-baillargeon:fix/3189
Oct 12, 2023
Merged
Fix(eos_validate_state): ANTA VerifyRoutingProtocolModel now only run if there is BGP configuration #3212
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
97b587f
Fix: VerifyRoutingProtocolModel is now run only if there is a BGP con…
carl-baillargeon 650a0ce
Fix: Preview doc + address review comments
carl-baillargeon 050f048
Fix: Update doc
carl-baillargeon 19323fd
Fix logs + add unit tests
carl-baillargeon 2ecb6e5
Fix unit tests
carl-baillargeon 5b8027b
Merge branch 'devel' into fix/3189
ClausHolbechArista 6fbead6
Fix: Remove else per review
carl-baillargeon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
1,154 changes: 575 additions & 579 deletions
1,154
ansible_collections/arista/avd/molecule/eos_validate_state/reports/FABRIC-state.csv
Large diffs are not rendered by default.
Oops, something went wrong.
1,166 changes: 581 additions & 585 deletions
1,166
ansible_collections/arista/avd/molecule/eos_validate_state/reports/FABRIC-state.md
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
29 changes: 29 additions & 0 deletions
29
ansible_collections/arista/avd/tests/unit/roles/eos_validate_state/avdtests.py
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Copyright (c) 2023 Arista Networks, Inc. | ||
# Use of this source code is governed by the Apache License 2.0 | ||
# that can be found in the LICENSE file. | ||
|
||
from __future__ import annotations | ||
|
||
import logging | ||
from typing import TYPE_CHECKING | ||
|
||
from ansible_collections.arista.avd.plugins.plugin_utils.eos_validate_state_utils import AvdTestBase | ||
from ansible_collections.arista.avd.plugins.plugin_utils.utils import load_python_class | ||
|
||
if TYPE_CHECKING: | ||
from pytest import LogCaptureFixture | ||
|
||
|
||
def test_avd_tests(caplog: LogCaptureFixture, data: dict) -> None: | ||
""" | ||
Generic function for all AvdTestBase subclasses unit tests. | ||
""" | ||
caplog.set_level(logging.INFO) | ||
avd_test_class = load_python_class("ansible_collections.arista.avd.roles.eos_validate_state.python_modules.tests", data["test_module"], AvdTestBase) | ||
avd_test_bgp = avd_test_class(device_name="DC1-SPINE1", hostvars=data["hostvars"]) | ||
result = avd_test_bgp.render() | ||
assert result == data["expected_result"] | ||
|
||
if data["expected_log"] and data["expected_log_level"]: | ||
found_expected_log = any(record.message == data["expected_log"] and record.levelname == data["expected_log_level"] for record in caplog.records) | ||
assert found_expected_log, f"Expected log message not found: {data['expected_log']}" |
35 changes: 35 additions & 0 deletions
35
ansible_collections/arista/avd/tests/unit/roles/eos_validate_state/conftest.py
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Copyright (c) 2023 Arista Networks, Inc. | ||
# Use of this source code is governed by the Apache License 2.0 | ||
# that can be found in the LICENSE file. | ||
|
||
from __future__ import annotations | ||
|
||
from typing import TYPE_CHECKING | ||
|
||
if TYPE_CHECKING: | ||
from pytest import Metafunc | ||
|
||
|
||
def build_test_id(val: dict) -> str: | ||
""" | ||
Build a proper test ID for AvdTestBase subclasses unit tests: `<test_module>-<test_name>` | ||
|
||
Examples output: | ||
|
||
`test_avd_tests[AvdTestBGP-missing-router-bgp]` | ||
|
||
`test_avd_tests[AvdTestBGP-missing-service-routing-protocols-model]` | ||
""" | ||
return f"{val['test_module']}-{val['test_name']}" | ||
|
||
|
||
def pytest_generate_tests(metafunc: Metafunc) -> None: | ||
""" | ||
This function is called during test collection. | ||
|
||
It will parametrize test cases based on the `DATA` data structure defined in `tests.unit.roles.eos_validate_state.tests` modules. | ||
|
||
Test IDs are generated using the `build_test_id` function above. | ||
""" | ||
if "tests.unit.roles.eos_validate_state.tests" in metafunc.module.__package__: | ||
metafunc.parametrize("data", metafunc.module.DATA, ids=build_test_id) |
Oops, something went wrong.
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.
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.
Could invert if and else and return first
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.
Agreed. Fixed in 6fbead6