8000 feat(anta): Add evidence field to TestResult by carl-baillargeon · Pull Request #1117 · aristanetworks/anta · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat(anta): Add evidence field to TestResult #1117

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

Closed

Conversation

carl-baillargeon
Copy link
Contributor
@carl-baillargeon carl-baillargeon commented Mar 24, 2025

Description

Add save_evidence parameter to the runner to optionally save each test inputs and commands to their respective TestResult.

Fixes #1103

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)

Copy link
codspeed-hq bot commented Mar 24, 2025

CodSpeed Performance Report

Merging #1117 will not alter performance

Comparing carl-baillargeon:feat/evidence (94cc771) with main (67acd31)

Summary

✅ 22 untouched benchmarks

Copy link
@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces an optional evidence saving mechanism for test results by adding a save_evidence parameter and related logic throughout the code. Key changes include:

  • Adding a new execute method in asynceapi/device.py and a get_result helper in asynceapi/_models.py.
  • Propagating a save_evidence parameter in anta/runner.py and updating AntaTest initialization in anta/models.py to attach evidence.
  • Enhancing TestResult with a new evidence property and adding a serialize_results method in the result manager.

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
asynceapi/device.py Added execute method for EapiRequest execution with enhanced error handling.
asynceapi/_models.py Added a helper method get_result for retrieving a command result by index.
anta/tests/cvx.py Updated test failure messages to improve clarity of expected state.
anta/runner.py Introduced save_evidence parameter propagation in test coroutine creation.
anta/result_manager/models.py Added TestEvidence and updated TestResult to support evidence serialization.
anta/result_manager/init.py Added serialize_results to include evidence when dumping test results.
anta/models.py Introduced AntaCommandMetadata and updated AntaTest to include evidence saving.
anta/device.py Adjusted command execution flow and error logging to leverage new error handling.
Comments suppressed due to low confidence (2)

asynceapi/device.py:469

  • Typo in the docstring: 'EapiReponseError' should be 'EapiResponseError'.
raise an EapiReponseError if the response contains errors, by default True.

anta/device.py:540

  • [nitpick] Consider formatting the error message by joining multiple errors into a single string for better readability rather than conditionally displaying a single error or a list.
logger.error("Command '%s' failed on %s: %s", command.command, self.name, command.errors[0] if len(command.errors) == 1 else command.errors)

Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@carl-baillargeon
Copy link
Contributor Author

#680 will return the full run context so this is no longer needed.

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.

feat(anta): Add option to save the command outputs in TestResult
2 participants
0