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 the test case to verify SNMP Logging Configuration #849

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

Conversation

vitthalmagadum
Copy link
Collaborator

@vitthalmagadum vitthalmagadum commented Oct 3, 2024

Description

This test performs the following checks for each specified host:

 1. Verifies that the SNMP logging is enabled on the device.
 2. Verifies SNMP host matches the expected value.
 3. Ensures that VRF provided matches the expected value.

Expected Results
----------------
* Success: The test will pass if all of the following conditions are met:
    - The SNMP logging is enabled on the device.
    - The SNMP host matches the expected value.
    - The VRF provided matches the expected value.
* Failure: The test will fail if any of the following conditions is met:
    - The SNMP logging is disabled on the device.
    - The SNMP host do not matches the expected value.
    - The VRF provided do not matches the expected value.

Fixes #821

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 Oct 3, 2024

CodSpeed Performance Report

Merging #849 will not alter performance

Comparing vitthalmagadum:issue_821 (9764580) with main (68c664d)

Summary

✅ 22 untouched benchmarks

failures += f"SNMP host '{hostname }' is not configured.\n"
continue
if actual_vrf != vrf:
failures += f"SNMP host '{hostname }' is not correctly configured in specified vrf '{vrf}'.\n"
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should give the failure message like For SNMP host '{hostname }' expected vrf is blah but found blah11 instead.

class SNMPHost(BaseModel):
"""Model for a SNMP Host."""

hostname: IPv4Address
Copy link
Collaborator

Choose a reason for hiding this comment

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

if there is only option of ipv4 address then better to use host instead of hostname. If we can use and name then update input restriction

"hosts": {
"192.168.1.100": {"port": 162, "vrf": ""},
"192.168.1.101": {"port": 162, "vrf": "MGMT"},
"snmp-server-01": {"port": 162, "vrf": "MGMT"},
Copy link
Collaborator

Choose a reason for hiding this comment

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

can you share the json output from device for hostname

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

leaf1-dc1#show snmp | json
{
    "chassis": {
        "chassisId": "C2BB56D511CAB40E40B2DCD1E9D3A9C9"
    },
    "contact": {
        "contact": "\"Network Admin\""
    },
    "location": {
        "location": "\"Data Center A\""
    },
    "counters": {
        "serviceEnabled": true,
        "inPkts": 0,
        "inVersionErrs": 0,
        "inBadCommunityNames": 0,
        "inBadCommunityUses": 0,
        "inParseErrs": 0,
        "inRequestVars": 0,
        "inSetVars": 0,
        "inGetPdus": 0,
        "inGetNextPdus": 0,
        "inSetPdus": 0,
        "outPkts": 5,
        "outTooBigErrs": 0,
        "outNoSuchNameErrs": 0,
        "outBadValueErrs": 0,
        "outGeneralErrs": 0,
        "outGetResponsePdus": 0,
        "outTrapPdus": 5,
        "outTrapDrops": 0,
        "groupLength": 3,
        "numberOfGroups": 9,
        "numberOfViews": 0
    },
    "logging": {
        "loggingEnabled": true,
        "hosts": {
            "192.168.1.100": {
                "port": 162,
                "vrf": ""
            },
            "leaf1-dc1": {
                "port": 162,
                "vrf": ""
            },
            "spine": {
                "port": 162,
                "vrf": ""
            },
            "spine1-dc1.fun.aristanetworks.com": {
                "port": 162,
                "vrf": ""
            }
        }
    },
    "vrfs": {
        "snmpVrfs": [
            "default"
        ]
    },
    "srcIntf": {
        "sourceInterfaces": {
            "default": "Management0",
            "MGMT": "Ethernet1"
        }
    },
    "misc": {
        "transmitMsgMaxSize": 65536
    },
    "enabled": true,
}

Copy link
Contributor

This pull request has conflicts, please resolve those before we can evaluate the pull request.

Copy link
Contributor

Conflicts have been resolved. A maintainer will review the pull request shortly.

Copy link

Copy link
Contributor

github-actions bot commented Dec 2, 2024

This pull request has conflicts, please resolve those before we can evaluate the pull request.

Copy link
Contributor

github-actions bot commented Jan 9, 2025

Conflicts have been resolved. A maintainer will review the pull request shortly.

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 SNMP Logging Configuration.
3 participants