Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
7 changes: 6 additions & 1 deletion ansible/roles/test/tasks/snmp.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# When uptime is less than the boot time of snmp, to pause the task until snmp service is up.
- name: Wait for snmp service start
pause: seconds={{210 - ansible_uptime_seconds}}
when: ansible_uptime_seconds < 210

# Gather facts with SNMP version 2
- name: Gathering basic snmp facts about the device
snmp_facts: host={{ ansible_host }} version=v2c community={{ snmp_rocommunity }}
Expand Down Expand Up @@ -32,4 +37,4 @@
include_tasks: roles/test/tasks/snmp/psu.yml
when:
- testcase_name is defined
- (hostvars[ansible_hostname]['type'] is not defined) or (hostvars[ansible_hostname]['type'] != 'simx')
- (hostvars[ansible_hostname]['type'] is not defined) or (hostvars[ansible_hostname]['type'] != 'simx')
7 changes: 7 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,18 @@ def __init__(self, testbed_file):
del line['topo']
line['topo'] = defaultdict()
line['topo']['name'] = topo
line['topo']['type'] = self.get_testbed_type(line['topo']['name'])
with open("../ansible/vars/topo_{}.yml".format(topo), 'r') as fh:
line['topo']['properties'] = yaml.safe_load(fh)

self.testbed_topo[line['conf-name']] = line

def get_testbed_type(self, topo_name):
pattern = re.compile(r'^(t0|t1|ptf)')
match = pattern.match(topo_name)
if match == None:
raise Exception("Unsupported testbed type - {}".format(topo_name))
return match.group()

def pytest_addoption(parser):
parser.addoption("--testbed", action="store", default=None, help="testbed name")
Expand Down
5 changes: 5 additions & 0 deletions tests/snmp/test_snmp_lldp.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import pytest
from ansible_host import AnsibleHost

@pytest.fixture(scope="module", autouse=True)
def setup_check_topo(testbed):
if testbed['topo']['type'] == 'ptf':
pytest.skip('Unsupported topology')

@pytest.mark.bsl
def test_snmp_lldp(ansible_adhoc, testbed, creds):
"""
Expand Down