Skip to content

Commit

Permalink
[test_lldp] divide into two test cases and put a TODO about SNMP comm…
Browse files Browse the repository at this point in the history
…unity string

Signed-off-by: Stepan Blyschak <stepanb@mellanox.com>
  • Loading branch information
Stepan Blyschak committed Aug 1, 2019
1 parent 78b2907 commit bedbbc9
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions tests/test_lldp.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
from ansible_host import AnsibleHost


def test_lldp(localhost, ansible_adhoc, testbed):
"""verify the lldp message on DUT and neighbors"""
""" verify the LLDP message on DUT """

hostname = testbed['dut']
ans_host = AnsibleHost(ansible_adhoc, hostname)

mg_facts = ans_host.minigraph_facts(host=hostname)['ansible_facts']
host_facts = ans_host.setup()['ansible_facts']
lldp_facts = ans_host.lldp()['ansible_facts']
res = ans_host.shell("docker exec -i lldp lldpcli show chassis | grep \"SysDescr:\" | sed -e 's/^\\s*SysDescr:\\s*//g'")
dut_system_description = res['stdout']

minigraph_lldp_nei = {}
for k, v in mg_facts['minigraph_neighbors'].items():
Expand All @@ -28,10 +26,26 @@ def test_lldp(localhost, ansible_adhoc, testbed):
# Compare the LLDP neighbor interface with minigraph neigbhor interface (exclude the management port)
assert v['port']['ifname'] == mg_facts['minigraph_neighbors'][k]['port']


def test_lldp_neighbor(localhost, ansible_adhoc, testbed):
""" verify LLDP information on neighbors """

hostname = testbed['dut']
ans_host = AnsibleHost(ansible_adhoc, hostname)
mg_facts = ans_host.minigraph_facts(host=hostname)['ansible_facts']
res = ans_host.shell("docker exec -i lldp lldpcli show chassis | grep \"SysDescr:\" | sed -e 's/^\\s*SysDescr:\\s*//g'")
dut_system_description = res['stdout']
lldp_facts = ans_host.lldp()['ansible_facts']
host_facts = ans_host.setup()['ansible_facts']
lhost = AnsibleHost(ansible_adhoc, 'localhost', True)

for k, v in lldp_facts['lldp'].items():
if k == 'eth0':
# skip test on management interface
continue

hostip = v['chassis']['mgmt-ip']
# TODO: Need to read eos.yml to get SNMP version and community string
nei_lldp_facts = lhost.lldp_facts(host=hostip, version='v2c', community='strcommunity')['ansible_facts']
print nei_lldp_facts
neighbor_interface = v['port']['ifname']
Expand Down

0 comments on commit bedbbc9

Please sign in to comment.