Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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: 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):
testbed_type = ['t0', 't1', 'ptf']
for val in testbed_type:
if topo_name.find(val) != -1:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

suggest to use regex match somehting like ("^(t0|t1|ptf)[-]")?

Copy link
Copy Markdown
Contributor Author

@EmmaLin11 EmmaLin11 Mar 26, 2020

Choose a reason for hiding this comment

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

@lguohan , thank you for your advice. I change to use regex match() to check if topo_name matches expected topo_type. Could you please review it?

return val
raise Exception("Unsupported testbed type - {}".format(topo_name))

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