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 Notification Host #838

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

vitthalmagadum
Copy link
Collaborator

Description

Verifies the SNMP notification host (SNMP manager) configurations.

Fixes #822

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)

@vitthalmagadum vitthalmagadum marked this pull request as draft September 26, 2024 11:37
@vitthalmagadum vitthalmagadum marked this pull request as ready for review September 27, 2024 06:21
anta/tests/snmp.py Outdated Show resolved Hide resolved
anta/tests/snmp.py Outdated Show resolved Hide resolved
anta/tests/snmp.py Outdated Show resolved Hide resolved
anta/tests/snmp.py Outdated Show resolved Hide resolved
anta/tests/snmp.py Outdated Show resolved Hide resolved
Copy link

codspeed-hq bot commented Oct 1, 2024

CodSpeed Performance Report

Merging #838 will not alter performance

Comparing vitthalmagadum:issue_822 (63bbd6a) with main (995943a)

Summary

✅ 22 untouched benchmarks

anta/tests/snmp.py Outdated Show resolved Hide resolved
anta/tests/snmp.py Outdated Show resolved Hide resolved
anta/tests/snmp.py Outdated Show resolved Hide resolved
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

@gmuloc gmuloc marked this pull request as draft November 28, 2024 09:49
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.

Copy link
Collaborator

@gmuloc gmuloc left a comment

Choose a reason for hiding this comment

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

please fix wording before I make another review

anta/input_models/snmp.py Outdated Show resolved Hide resolved
anta/input_models/snmp.py Outdated Show resolved Hide resolved
anta/tests/snmp.py Outdated Show resolved Hide resolved
anta/tests/snmp.py Outdated Show resolved Hide resolved
anta/tests/snmp.py Outdated Show resolved Hide resolved
anta/tests/snmp.py Outdated Show resolved Hide resolved
anta/tests/snmp.py Outdated Show resolved Hide resolved
anta/tests/snmp.py Show resolved Hide resolved
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
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.

self.result.is_failure(f"{host} Version: {version} - Not configured")
continue

# If actual notification type do not matches the expected value, test fails.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
# If actual notification type do not matches the expected value, test fails.
# If actual notification type does not match the expected value, test fails.


# If actual notification type do not matches the expected value, test fails.
if notification_type != (actual_notification_type := get_value(host_details, "notificationType", default_value)):
self.result.is_failure(f"{host} - Incorrect notification type - Expected: {notification_type} Actual: {actual_notification_type}")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
self.result.is_failure(f"{host} - Incorrect notification type - Expected: {notification_type} Actual: {actual_notification_type}")
self.result.is_failure(f"{host} - Incorrect notification type - Expected: {notification_type}, Actual: {actual_notification_type}")

if notification_type != (actual_notification_type := get_value(host_details, "notificationType", default_value)):
self.result.is_failure(f"{host} - Incorrect notification type - Expected: {notification_type} Actual: {actual_notification_type}")

# If actual udp port do not matches the expected value, test fails.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
# If actual udp port do not matches the expected value, test fails.
# If actual UDP port does not match the expected value, test fails.


# If actual udp port do not matches the expected value, test fails.
if udp_port != (actual_udp_port := get_value(host_details, "port", default_value)):
self.result.is_failure(f"{host} - Incorrect UDP port - Expected: {udp_port} Actual: {actual_udp_port}")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
self.result.is_failure(f"{host} - Incorrect UDP port - Expected: {udp_port} Actual: {actual_udp_port}")
self.result.is_failure(f"{host} - Incorrect UDP port - Expected: {udp_port}, Actual: {actual_udp_port}")

user_found = user != (actual_user := get_value(host_details, "v3Params.user", default_value))
version_user_check = (version == "v3", user_found)

# If SNMP protocol version is v1 or v2c and actual community string do not matches the expected value, test fails.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
# If SNMP protocol version is v1 or v2c and actual community string do not matches the expected value, test fails.
# If SNMP protocol version is v1 or v2c and actual community string does not match the expected value, test fails.

if version in ["v1", "v2c"] and community_string != (actual_community_string := get_value(host_details, "v1v2cParams.communityString", default_value)):
self.result.is_failure(f"{host} Version: {version} - Incorrect community string - Expected: {community_string} Actual: {actual_community_string}")

# If SNMP protocol version is v3 and actual user do not matches the expected value, test fails.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
# If SNMP protocol version is v3 and actual user do not matches the expected value, test fails.
# If SNMP protocol version is v3 and actual user does not match the expected value, test fails.

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 Notification Host
4 participants