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

[Multiasic]: Update Interfaces MIB testcase to test multiasic platform #1635

Merged
merged 5 commits into from
Mar 3, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ansible/library/config_facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def create_maps(config):
for idx, val in enumerate(port_name_list_sorted):
port_index_map[val] = idx

port_name_to_alias_map = { name : v['alias'] for name, v in config["PORT"].iteritems()}
port_name_to_alias_map = { name : v['alias'] for name, v in config["PORT"].iteritems() if 'alias' in v }

# Create inverse mapping between port name and alias
port_alias_to_name_map = {v: k for k, v in port_name_to_alias_map.iteritems()}
Expand Down
29 changes: 21 additions & 8 deletions tests/snmp/test_snmp_interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,39 @@
]

@pytest.mark.bsl
def test_snmp_interfaces(duthosts, rand_one_dut_hostname, localhost, creds):
Copy link
Contributor

@qiluo-msft qiluo-msft Mar 2, 2021

Choose a reason for hiding this comment

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

test_snmp_interfaces [](start = 4, length = 20)

You changed function name, but it is used in several places already. #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed function name to as it was before.

"""compare the bgp facts between observed states and target state"""
duthost = duthosts[rand_one_dut_hostname]

def test_snmp_interface(localhost, creds, duthosts, enum_dut_hostname, enum_asic_index):
"""compare the snmp facts between observed states and target state"""
duthost = duthosts[enum_dut_hostname]
hostip = duthost.host.options['inventory_manager'].get_host(duthost.hostname).vars['ansible_host']

namespace = duthost.get_namespace_from_asic_id(enum_asic_index)
config_facts = duthost.config_facts(host=duthost.hostname, source="persistent", namespace=namespace)['ansible_facts']
snmp_facts = localhost.snmp_facts(host=hostip, version="v2c", community=creds["snmp_rocommunity"])['ansible_facts']
config_facts = duthost.config_facts(host=duthost.hostname, source="persistent")['ansible_facts']

snmp_ifnames = [ v['name'] for k, v in snmp_facts['snmp_interfaces'].items() ]
print snmp_ifnames

# Verify all physical ports in snmp interface list
for _, alias in config_facts['port_name_to_alias_map'].items():
assert alias in snmp_ifnames
assert alias in snmp_ifnames, "Interface not found in SNMP facts."

# Verify all port channels in snmp interface list
for po_name in config_facts.get('PORTCHANNEL', {}):
assert po_name in snmp_ifnames
assert po_name in snmp_ifnames, "PortChannel not found in SNMP facts."

@pytest.mark.bsl
def test_snmp_mgmt_interface(localhost, creds, duthosts, enum_dut_hostname):
"""compare the snmp facts between observed states and target state"""

duthost = duthosts[enum_dut_hostname]
hostip = duthost.host.options['inventory_manager'].get_host(duthost.hostname).vars['ansible_host']

snmp_facts = localhost.snmp_facts(host=hostip, version="v2c", community=creds["snmp_rocommunity"])['ansible_facts']
config_facts = duthost.config_facts(host=duthost.hostname, source="persistent")['ansible_facts']

snmp_ifnames = [ v['name'] for k, v in snmp_facts['snmp_interfaces'].items() ]
print snmp_ifnames

# Verify management port in snmp interface list
for name in config_facts.get('MGMT_INTERFACE', {}):
assert name in snmp_ifnames
assert name in snmp_ifnames, "Management Interface not found in SNMP facts."