Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
9 changes: 4 additions & 5 deletions tests/bgp/test_bgp_fact.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,22 @@
pytest.mark.device_type('vs')
]

def test_bgp_facts(duthosts, dut_index, asic_index):
def test_bgp_facts(duthosts, dut_hostname, asic_index):
"""compare the bgp facts between observed states and target state"""

duthost = duthosts[dut_index]
duthost = duthosts[dut_hostname]
bgp_facts =duthost.bgp_facts(instance_id=asic_index)['ansible_facts']
namespace = duthost.get_namespace_from_asic_id(asic_index)
config_facts = duthost.config_facts(host=duthost.hostname, source="running",namespace=namespace)['ansible_facts']

for k, v in bgp_facts['bgp_neighbors'].items():
# Verify bgp sessions are established
assert v['state'] == 'established'
# Verify locat ASNs in bgp sessions
# Verify local ASNs in bgp sessions
assert v['local AS'] == int(config_facts['DEVICE_METADATA']['localhost']['bgp_asn'].decode("utf-8"))

for k, v in config_facts['BGP_NEIGHBOR'].items():
# Compare the bgp neighbors name with config db bgp neigbhors name
# Compare the bgp neighbors name with config db bgp neighbors name
assert v['name'] == bgp_facts['bgp_neighbors'][k]['description']
# Compare the bgp neighbors ASN with config db
assert int(v['asn'].decode("utf-8")) == bgp_facts['bgp_neighbors'][k]['remote AS']

19 changes: 16 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,13 +456,12 @@ def get_host_data(request, dut):

def generate_param_asic_index(request, dut_indices, param_type):
logging.info("generating {} asic indicies for DUT [{}] in ".format(param_type, dut_indices))

tbname = request.config.getoption("--testbed")
tbfile = request.config.getoption("--testbed_file")
if tbname is None or tbfile is None:
raise ValueError("testbed and testbed_file are required!")



tbinfo = TestbedInfo(tbfile)

#if the params are not present treat the device as a single asic device
Expand Down Expand Up @@ -491,6 +490,17 @@ def generate_params_dut_index(request):
return range(num_duts)


def generate_params_dut_hostname(request):
tbname = request.config.getoption("--testbed")
tbfile = request.config.getoption("--testbed_file")
if tbname is None or tbfile is None:
raise ValueError("testbed and testbed_file are required!")
tbinfo = TestbedInfo(tbfile)
duts = tbinfo.testbed_topo[tbname]["duts"]
logging.info("DUTs in testbed topology: {}".format(str(duts)))
return tbinfo.testbed_topo[tbname]["duts"]


def generate_port_lists(request, port_scope):
empty = [ encode_dut_port_name('unknown', 'unknown') ]
if 'ports' in port_scope:
Expand Down Expand Up @@ -543,6 +553,9 @@ def pytest_generate_tests(metafunc):
if "dut_index" in metafunc.fixturenames:
dut_indices = generate_params_dut_index(metafunc)
metafunc.parametrize("dut_index",dut_indices)
elif "dut_hostname" in metafunc.fixturenames: # Fixture "dut_index" and "dut_hostname" should be mutually exclusive
dut_hostnames = generate_params_dut_hostname(metafunc)
metafunc.parametrize("dut_hostname", dut_hostnames)
if "asic_index" in metafunc.fixturenames:
metafunc.parametrize("asic_index",generate_param_asic_index(metafunc, dut_indices, ASIC_PARAM_TYPE_ALL))
if "frontend_asic_index" in metafunc.fixturenames:
Expand Down