Skip to content

Conversation

@vitthalmagadum
Copy link
Contributor

@vitthalmagadum vitthalmagadum commented Oct 27, 2025

Change Summary

Add toggle to sort tests by status

Related Issue(s)

Fixes #5949

Component(s) name

arista.avd.anta_runner

Proposed changes

Add toggle to sort tests by status

How to test

Tested locally

anta_report.json
anta_report.md

Checklist

User Checklist

  • N/A

Repository Checklist

  • My code has been rebased from devel before I start
  • I have read the CONTRIBUTING document.
  • My change requires a change to the documentation and documentation have been updated accordingly.
  • I have updated molecule CI testing accordingly. (check the box if not applicable)

@vitthalmagadum vitthalmagadum requested review from a team as code owners October 27, 2025 16:47
@github-actions
Copy link

Review docs on Read the Docs

To test this pull request:

# Create virtual environment for this testing below the current directory
python -m venv test-avd-pr-6066
# Activate the virtual environment
source test-avd-pr-6066/bin/activate
# Install all requirements including PyAVD
pip install "pyavd[ansible] @ git+https://github.com/vitthalmagadum/avd.git@anta_runner/sort-toggle#subdirectory=python-avd" --force
# Point Ansible collections path to the Python virtual environment
export ANSIBLE_COLLECTIONS_PATH=$VIRTUAL_ENV/ansible_collections
# Install Ansible collection
ansible-galaxy collection install git+https://github.com/vitthalmagadum/avd.git#/ansible_collections/arista/avd/,anta_runner/sort-toggle --force
# Optional: Install AVD examples
cd test-avd-pr-6066
ansible-playbook arista.avd.install_examples

@vitthalmagadum vitthalmagadum marked this pull request as draft October 27, 2025 16:47
@github-actions github-actions bot added the state: CI Updated CI scenario have been updated in the PR label Oct 27, 2025
@vitthalmagadum vitthalmagadum changed the title Feat(anta_runner): Add toggle to sort tests by status[WIP] Feat(anta_runner): Add toggle to sort tests by status Oct 29, 2025
@sonarqubecloud
Copy link

Copy link
Contributor

@carl-baillargeon carl-baillargeon left a comment

Choose a reason for hiding this comment

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

Let's take the opportunity to improve the data model for report:

"report": {
  "type": "dict",
  "options": {
    "csv_output": {"type": "str"},
    "md_output": {"type": "str"},
    "json_output": {"type": "str"},
    
    "filters": {
      "type": "dict",
      "options": {
        "exclude_statuses": {  # Renamed from hide_statuses
          "type": "list",
          "elements": "str",
          "choices": ["success", "failure", "error", "skipped", "unset"]
        }
      }
    },
    
    "sorting": {
      "type": "dict",
      "options": {
        "status_priority": {
          "type": "list",
          "elements": "str",
          "choices": ["success", "failure", "error", "skipped", "unset"],
          "default": ["error", "failure", "skipped", "success", "unset"],
        },
        "sort_by": {
          "type": "list",
          "elements": "str",
          "choices": ["device", "categories", "test", "description", "result", "custom_field"],
          "default": ["device", "categories", "test", "description", "result", "custom_field"],
        }
      }
    }
  }
}

status_priority would act as the primary sort. We would first group all tests by their status, following status_priority order.

@JulioPDX Would you be OK with the following:

For example:

sorting:
  status_priority:
    - failure
    - error
    - skipped
  sort_by:
    - device

With this:

  1. All failures at the top (sorted by device).
  2. Then, all errors (sorted by device).
  3. Then, all skipped tests (also sorted by device).
  4. Any remaining statuses (like "success") would come last.

I know we don't have all functionalities in ANTA ResultManager but we can do it in anta_workflow no problem.

@JulioPDX
Copy link
Contributor

JulioPDX commented Oct 30, 2025

@carl-baillargeon The workflow makes sense. It solves the issue of having to search through the reports on failures (helpful on an active change control or troubleshooting event).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

state: CI Updated CI scenario have been updated in the PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feat(anta_runner): Add toggle to sort tests by status

3 participants