-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: add codspeed to benchmark ANTA (#826)
* fix(anta.tests): test results should not be an error when it can be a failure
- Loading branch information
Showing
23 changed files
with
538 additions
and
113 deletions.
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Copyright (c) 2023-2024 Arista Networks, Inc. | ||
# Use of this source code is governed by the Apache License 2.0 | ||
# that can be found in the LICENSE file. | ||
"""Benchmark tests for ANTA.""" |
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,40 @@ | ||
# Copyright (c) 2023-2024 Arista Networks, Inc. | ||
# Use of this source code is governed by the Apache License 2.0 | ||
# that can be found in the LICENSE file. | ||
"""Fixtures for benchmarking ANTA.""" | ||
|
||
import logging | ||
|
||
import pytest | ||
import respx | ||
from _pytest.terminal import TerminalReporter | ||
|
||
from anta.catalog import AntaCatalog | ||
|
||
from .utils import AntaMockEnvironment | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
TEST_CASE_COUNT = None | ||
|
||
|
||
@pytest.fixture(name="anta_mock_env", scope="session") # We want this fixture to have a scope set to session to avoid reparsing all the unit tests data. | ||
def anta_mock_env_fixture() -> AntaMockEnvironment: | ||
"""Return an AntaMockEnvironment for this test session. Also configure respx to mock eAPI responses.""" | ||
global TEST_CASE_COUNT # noqa: PLW0603 | ||
eapi_route = respx.post(path="/command-api", headers={"Content-Type": "application/json-rpc"}) | ||
env = AntaMockEnvironment() | ||
TEST_CASE_COUNT = env.tests_count | ||
eapi_route.side_effect = env.eapi_response | ||
return env | ||
|
||
|
||
@pytest.fixture # This fixture should have a scope set to function as the indexing result is stored in this object | ||
def catalog(anta_mock_env: AntaMockEnvironment) -> AntaCatalog: | ||
"""Fixture that return an ANTA catalog from the AntaMockEnvironment of this test session.""" | ||
return anta_mock_env.catalog | ||
|
||
|
||
def pytest_terminal_summary(terminalreporter: TerminalReporter) -> None: | ||
"""Display the total number of ANTA unit test cases used to benchmark.""" | ||
terminalreporter.write_sep("=", f"{TEST_CASE_COUNT} ANTA test cases") |
Oops, something went wrong.