Skip to content
Merged
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
12 changes: 6 additions & 6 deletions tests/acl/test_acl.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ def setup_rules(self, dut, acl_table):
"""
pass

def post_setup_hook(self, dut, localhost, populate_vlan_arp_entries):
def post_setup_hook(self, dut, localhost, populate_vlan_arp_entries, tbinfo):
"""Perform actions after rules have been applied.

Args:
Expand Down Expand Up @@ -348,7 +348,7 @@ def teardown_rules(self, dut):
dut.command("config acl update full {}".format(remove_rules_dut_path))

@pytest.fixture(scope="class", autouse=True)
def acl_rules(self, duthosts, rand_one_dut_hostname, localhost, setup, acl_table, populate_vlan_arp_entries):
def acl_rules(self, duthosts, rand_one_dut_hostname, localhost, setup, acl_table, populate_vlan_arp_entries, tbinfo):
"""Setup/teardown ACL rules for the current set of tests.

Args:
Expand All @@ -369,7 +369,7 @@ def acl_rules(self, duthosts, rand_one_dut_hostname, localhost, setup, acl_table
with loganalyzer:
self.setup_rules(duthost, acl_table)

self.post_setup_hook(duthost, localhost, populate_vlan_arp_entries)
self.post_setup_hook(duthost, localhost, populate_vlan_arp_entries, tbinfo)
except LogAnalyzerError as err:
# Cleanup Config DB if rule creation failed
logger.error("ACL table creation failed, attempting to clean-up...")
Expand Down Expand Up @@ -747,7 +747,7 @@ class TestAclWithReboot(TestBasicAcl):
upon startup.
"""

def post_setup_hook(self, dut, localhost, populate_vlan_arp_entries):
def post_setup_hook(self, dut, localhost, populate_vlan_arp_entries, tbinfo):
"""Save configuration and reboot after rules are applied.

Args:
Expand All @@ -768,7 +768,7 @@ class TestAclWithPortToggle(TestBasicAcl):
Verify that ACLs still function as expected after links flap.
"""

def post_setup_hook(self, dut, localhost, populate_vlan_arp_entries):
def post_setup_hook(self, dut, localhost, populate_vlan_arp_entries, tbinfo):
"""Toggle ports after rules are applied.

Args:
Expand All @@ -777,5 +777,5 @@ def post_setup_hook(self, dut, localhost, populate_vlan_arp_entries):
populate_vlan_arp_entries: A fixture to populate ARP/FDB tables for VLAN interfaces.

"""
port_toggle(dut)
port_toggle(dut, tbinfo)
populate_vlan_arp_entries()
8 changes: 4 additions & 4 deletions tests/arp/test_arpall.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ def collect_info(duthost):


@pytest.fixture(scope="module")
def common_setup_teardown(duthosts, rand_one_dut_hostname, ptfhost):
def common_setup_teardown(duthosts, rand_one_dut_hostname, ptfhost, tbinfo):
duthost = duthosts[rand_one_dut_hostname]
mg_facts = duthost.minigraph_facts(host=duthost.hostname)['ansible_facts']
mg_facts = duthost.get_extended_minigraph_facts(tbinfo)
int_facts = duthost.interface_facts()['ansible_facts']

ports = list(sorted(mg_facts['minigraph_ports'].keys(), key=lambda item: int(item.replace('Ethernet', ''))))
Expand All @@ -36,8 +36,8 @@ def common_setup_teardown(duthosts, rand_one_dut_hostname, ptfhost):
intf2 = ports[1]
logger.info("Selected ints are {0} and {1}".format(intf1, intf2))

intf1_indice = mg_facts['minigraph_port_indices'][intf1]
intf2_indice = mg_facts['minigraph_port_indices'][intf2]
intf1_indice = mg_facts['minigraph_ptf_indices'][intf1]
intf2_indice = mg_facts['minigraph_ptf_indices'][intf2]

po1 = get_po(mg_facts, intf1)
po2 = get_po(mg_facts, intf2)
Expand Down
10 changes: 5 additions & 5 deletions tests/arp/test_wr_arp.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class TestWrArp:
'''
TestWrArp Performs control plane assisted warm-reboo
'''
def __prepareVxlanConfigData(self, duthost, ptfhost):
def __prepareVxlanConfigData(self, duthost, ptfhost, tbinfo):
'''
Prepares Vxlan Configuration data for Ferret service running on PTF host

Expand All @@ -34,9 +34,9 @@ def __prepareVxlanConfigData(self, duthost, ptfhost):
Returns:
None
'''
mgFacts = duthost.minigraph_facts(host=duthost.hostname)['ansible_facts']
mgFacts = duthost.get_extended_minigraph_facts(tbinfo)
vxlanConfigData = {
'minigraph_port_indices': mgFacts['minigraph_port_indices'],
'minigraph_port_indices': mgFacts['minigraph_ptf_indices'],
'minigraph_portchannel_interfaces': mgFacts['minigraph_portchannel_interfaces'],
'minigraph_portchannels': mgFacts['minigraph_portchannels'],
'minigraph_lo_interfaces': mgFacts['minigraph_lo_interfaces'],
Expand All @@ -51,7 +51,7 @@ def __prepareVxlanConfigData(self, duthost, ptfhost):
ptfhost.copy(src=VXLAN_CONFIG_FILE, dest='/tmp/')

@pytest.fixture(scope='class', autouse=True)
def setupFerret(self, duthosts, rand_one_dut_hostname, ptfhost):
def setupFerret(self, duthosts, rand_one_dut_hostname, ptfhost, tbinfo):
'''
Sets Ferret service on PTF host. This class-scope fixture runs once before test start

Expand Down Expand Up @@ -120,7 +120,7 @@ def setupFerret(self, duthosts, rand_one_dut_hostname, ptfhost):
chdir='/opt'
)

self.__prepareVxlanConfigData(duthost, ptfhost)
self.__prepareVxlanConfigData(duthost, ptfhost, tbinfo)

logger.info('Refreshing supervisor control with ferret configuration')
ptfhost.shell('supervisorctl reread && supervisorctl update')
Expand Down
2 changes: 1 addition & 1 deletion tests/bgp/test_bgp_multipath_relax.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def get_vips_prefix_paths(dut_t0_neigh, vips_prefix, topo_config):
return vips_t0, vips_asn

def get_bgp_v4_neighbors_from_minigraph(duthost, tbinfo):
mg_facts = duthost.minigraph_facts(host=duthost.hostname)['ansible_facts']
mg_facts = duthost.get_extended_minigraph_facts(tbinfo)

# Find all V4 bgp neighbors from minigraph
bgp_v4nei = {}
Expand Down
8 changes: 4 additions & 4 deletions tests/bgp/test_bgp_speaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ def change_route(operation, ptfip, neighbor, route, nexthop, port):
assert r.status_code == 200

@pytest.fixture(scope="module")
def common_setup_teardown(duthosts, rand_one_dut_hostname, ptfhost, localhost):
def common_setup_teardown(duthosts, rand_one_dut_hostname, ptfhost, localhost, tbinfo):
duthost = duthosts[rand_one_dut_hostname]

logging.info("########### Setup for bgp speaker testing ###########")

ptfip = ptfhost.host.options['inventory_manager'].get_host(ptfhost.hostname).vars['ansible_host']
logging.info("ptfip=%s" % ptfip)

mg_facts = duthost.minigraph_facts(host=duthost.hostname)['ansible_facts']
mg_facts = duthost.get_extended_minigraph_facts(tbinfo)
interface_facts = duthost.interface_facts()['ansible_facts']

constants_stat = duthost.stat(path="/etc/sonic/constants.yml")
Expand Down Expand Up @@ -86,7 +86,7 @@ def common_setup_teardown(duthosts, rand_one_dut_hostname, ptfhost, localhost):

vlan_ports = []
for i in range(0, 3):
vlan_ports.append(mg_facts['minigraph_port_indices'][mg_facts['minigraph_vlans'][mg_facts['minigraph_vlan_interfaces'][0]['attachto']]['members'][i]])
vlan_ports.append(mg_facts['minigraph_ptf_indices'][mg_facts['minigraph_vlans'][mg_facts['minigraph_vlan_interfaces'][0]['attachto']]['members'][i]])
logging.info("vlan_ports: %s" % str(vlan_ports))

# Generate ipv6 nexthops
Expand Down Expand Up @@ -217,7 +217,7 @@ def bgp_speaker_announce_routes_common(common_setup_teardown, tbinfo, duthost, p
extra_vars = {'announce_prefix': prefix,
'minigraph_portchannels': mg_facts['minigraph_portchannels'],
'minigraph_vlans': mg_facts['minigraph_vlans'],
'minigraph_port_indices': mg_facts['minigraph_port_indices']}
'minigraph_port_indices': mg_facts['minigraph_ptf_indices']}
ptfhost.host.options['variable_manager'].extra_vars.update(extra_vars)
logging.info("extra_vars: %s" % str(ptfhost.host.options['variable_manager'].extra_vars))

Expand Down
8 changes: 4 additions & 4 deletions tests/common/fixtures/advanced_reboot.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def __init__(self, request, duthost, ptfhost, localhost, tbinfo, creds, **kwargs
self.vlanMaxCnt = 0
self.hostMaxCnt = HOST_MAX_COUNT

self.__buildTestbedData()
self.__buildTestbedData(tbinfo)

def __extractTestParam(self):
'''
Expand Down Expand Up @@ -118,12 +118,12 @@ def getTestbedType(self):
'''
return self.tbinfo['topo']['name']

def __buildTestbedData(self):
def __buildTestbedData(self, tbinfo):
'''
Build testbed data that are needed by ptf advanced-reboot.ReloadTest class
'''

self.mgFacts = self.duthost.minigraph_facts(host=self.duthost.hostname)['ansible_facts']
self.mgFacts = self.duthost.get_extended_minigraph_facts(tbinfo)

self.rebootData['arista_vms'] = [
attr['mgmt_addr'] for dev, attr in self.mgFacts['minigraph_devices'].items() if attr['hwsku'] == 'Arista-VM'
Expand Down Expand Up @@ -307,7 +307,7 @@ def __setupTestbed(self):
testDataFiles = [
{'source' : self.mgFacts['minigraph_portchannels'], 'name' : 'portchannel_interfaces'},
{'source' : self.mgFacts['minigraph_vlans'], 'name' : 'vlan_interfaces' },
{'source' : self.mgFacts['minigraph_port_indices'], 'name' : 'ports' },
{'source' : self.mgFacts['minigraph_ptf_indices'], 'name' : 'ports' },
{'source' : self.mgFacts['minigraph_devices'], 'name' : 'peer_dev_info' },
{'source' : self.mgFacts['minigraph_neighbors'], 'name' : 'neigh_port_info' },
]
Expand Down
12 changes: 6 additions & 6 deletions tests/common/fixtures/pfc_asym.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ def ansible_facts(duthosts, rand_one_dut_hostname):


@pytest.fixture(scope="module")
def minigraph_facts(duthosts, rand_one_dut_hostname):
def minigraph_facts(duthosts, rand_one_dut_hostname, tbinfo):
""" DUT minigraph facts fixture """
duthost = duthosts[rand_one_dut_hostname]
yield duthost.minigraph_facts(host=duthost.hostname)['ansible_facts']
yield duthost.get_extended_minigraph_facts(tbinfo)


@pytest.fixture(autouse=True, scope="module")
Expand Down Expand Up @@ -285,8 +285,8 @@ def generate_server_ports(self):
self.vars["ptf_test_params"]["server_ports"] = []
for index, item in enumerate(self.vlan_members):
port_info = {"dut_name": item,
"ptf_name": "eth{}".format(self.mg_facts["minigraph_port_indices"][item]),
"index": self.mg_facts["minigraph_port_indices"][item],
"ptf_name": "eth{}".format(self.mg_facts["minigraph_ptf_indices"][item]),
"index": self.mg_facts["minigraph_ptf_indices"][item],
"ptf_ip": generated_ips[index],
"oid": None}

Expand All @@ -305,8 +305,8 @@ def generate_non_server_ports(self):
redis_oid = self.duthost.command("docker exec -i database redis-cli --raw -n 2 HMGET \
COUNTERS_PORT_NAME_MAP {}".format(self.portchannel_member))["stdout"]
sai_redis_oid = int(self.duthost.command("docker exec -i database redis-cli -n 1 hget VIDTORID {}".format(redis_oid))["stdout"].replace("oid:", ""), 16)
self.vars["ptf_test_params"]["non_server_port"] = {"ptf_name": "eth{}".format(self.mg_facts["minigraph_port_indices"][self.portchannel_member]),
"index": self.mg_facts["minigraph_port_indices"][self.portchannel_member],
self.vars["ptf_test_params"]["non_server_port"] = {"ptf_name": "eth{}".format(self.mg_facts["minigraph_ptf_indices"][self.portchannel_member]),
"index": self.mg_facts["minigraph_ptf_indices"][self.portchannel_member],
"ip": self.mg_facts["minigraph_portchannel_interfaces"][0]["peer_addr"],
"dut_name": self.portchannel_member,
"oid": sai_redis_oid}
Expand Down
14 changes: 7 additions & 7 deletions tests/common/fixtures/populate_fdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def __init__(self, request, duthost, ptfhost):
self.duthost = duthost
self.ptfhost = ptfhost

def __prepareVlanConfigData(self):
def __prepareVlanConfigData(self, tbinfo):
"""
Prepares Vlan Configuration data

Expand All @@ -57,13 +57,13 @@ def __prepareVlanConfigData(self):
None
"""
mgVlanPorts = []
mgFacts = self.duthost.minigraph_facts(host=self.duthost.hostname)["ansible_facts"]
mgFacts = self.duthost.get_extended_minigraph_facts(tbinfo)
for vlan, config in mgFacts["minigraph_vlans"].items():
for port in config["members"]:
mgVlanPorts.append({
"port": port,
"vlan": vlan,
"index": mgFacts["minigraph_port_indices"][port]
"index": mgFacts["minigraph_ptf_indices"][port]
})
vlan_interfaces = {}
for vlan in mgFacts["minigraph_vlan_interfaces"]:
Expand All @@ -82,7 +82,7 @@ def __prepareVlanConfigData(self):
logger.info("Copying VLan config file to {0}".format(self.ptfhost.hostname))
self.ptfhost.copy(src=self.VLAN_CONFIG_FILE, dest="/tmp/")

def run(self):
def run(self, tbinfo):
"""
Populates DUT FDB entries

Expand All @@ -92,7 +92,7 @@ def run(self):
Returns:
None
"""
self.__prepareVlanConfigData()
self.__prepareVlanConfigData(tbinfo)

logger.info("Populate DUT FDB entries")
ptf_runner(
Expand All @@ -112,7 +112,7 @@ def run(self):
)

@pytest.fixture
def populate_fdb(request, duthosts, rand_one_dut_hostname, ptfhost):
def populate_fdb(request, duthosts, rand_one_dut_hostname, ptfhost, tbinfo):
"""
Populates DUT FDB entries

Expand All @@ -127,4 +127,4 @@ def populate_fdb(request, duthosts, rand_one_dut_hostname, ptfhost):
duthost = duthosts[rand_one_dut_hostname]
populateFdb = PopulateFdb(request, duthost, ptfhost)

populateFdb.run()
populateFdb.run(tbinfo)
4 changes: 2 additions & 2 deletions tests/common/port_toggle.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
logger = logging.getLogger(__name__)


def port_toggle(duthost, ports=None, wait=60, wait_after_ports_up=60, watch=False):
def port_toggle(duthost, tbinfo, ports=None, wait=60, wait_after_ports_up=60, watch=False):
"""
Toggle ports on DUT.

Expand Down Expand Up @@ -42,7 +42,7 @@ def __check_interface_state(state='up'):

if ports is None:
logger.debug('ports is None, toggling all minigraph ports')
mg_facts = duthost.minigraph_facts(host=duthost.hostname)['ansible_facts']
mg_facts = duthost.get_extended_minigraph_facts(tbinfo)
ports = mg_facts['minigraph_ports'].keys()

logger.info('toggling ports:\n%s', pprint.pformat(ports))
Expand Down
2 changes: 1 addition & 1 deletion tests/copp/test_copp.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def _gather_test_params(tbinfo, duthost, request):
pkt_tx_count = request.config.getoption("--pkt_tx_count")
swap_syncd = request.config.getoption("--copp_swap_syncd")
topo = tbinfo["topo"]["name"]
bgp_graph = duthost.minigraph_facts(host=duthost.hostname)["ansible_facts"]["minigraph_bgp"]
bgp_graph = duthost.get_extended_minigraph_facts(tbinfo)["minigraph_bgp"]

return _COPPTestParameters(nn_target_port=nn_target_port,
pkt_tx_count=pkt_tx_count,
Expand Down
4 changes: 2 additions & 2 deletions tests/crm/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ def crm_thresholds(duthosts, rand_one_dut_hostname):


@pytest.fixture(scope="module", autouse=True)
def crm_interface(duthosts, rand_one_dut_hostname):
def crm_interface(duthosts, rand_one_dut_hostname, tbinfo):
""" Return tuple of two DUT interfaces """
duthost = duthosts[rand_one_dut_hostname]
mg_facts = duthost.minigraph_facts(host=duthost.hostname)["ansible_facts"]
mg_facts = duthost.get_extended_minigraph_facts(tbinfo)

if len(mg_facts["minigraph_portchannel_interfaces"]) >= 4:
crm_intf1 = mg_facts["minigraph_portchannel_interfaces"][0]["attachto"]
Expand Down
18 changes: 10 additions & 8 deletions tests/dhcp_relay/test_dhcp_pkt_fwd.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class DhcpPktFwdBase:
"port": 67,
}

def __getPortLagsAndPeerIp(self, duthost, testPort):
def __getPortLagsAndPeerIp(self, duthost, testPort, tbinfo):
"""
Retrieves all port lag members for a given testPort

Expand All @@ -50,19 +50,19 @@ def __getPortLagsAndPeerIp(self, duthost, testPort):
peerIp(str): BGP peer IP
"""
peerIp = None
mgFacts = duthost.minigraph_facts(host=duthost.hostname)["ansible_facts"]
mgFacts = duthost.get_extended_minigraph_facts(tbinfo)
for peer in mgFacts["minigraph_bgp"]:
if peer["name"] == mgFacts["minigraph_neighbors"][testPort]["name"] and \
ipaddr.IPAddress(peer["addr"]).version == 4:
peerIp = peer["addr"]
break

lags = [mgFacts["minigraph_port_indices"][testPort]]
lags = [mgFacts["minigraph_ptf_indices"][testPort]]
for portchannelConfig in mgFacts["minigraph_portchannels"].values():
if testPort in portchannelConfig["members"]:
for lag in portchannelConfig["members"]:
if testPort != lag:
lags.append(mgFacts["minigraph_port_indices"][lag])
lags.append(mgFacts["minigraph_ptf_indices"][lag])
break

return lags, peerIp
Expand Down Expand Up @@ -110,7 +110,7 @@ def dutPorts(self, duthosts, rand_one_dut_hostname, tbinfo):
downstreamPorts = []
upstreamPorts = []

mgFacts = duthost.minigraph_facts(host=duthost.hostname)["ansible_facts"]
mgFacts = duthost.get_extended_minigraph_facts(tbinfo)

for dutPort, neigh in mgFacts["minigraph_neighbors"].items():
if "T0" in neigh["name"]:
Expand All @@ -121,7 +121,7 @@ def dutPorts(self, duthosts, rand_one_dut_hostname, tbinfo):
yield {"upstreamPorts": upstreamPorts, "downstreamPorts": downstreamPorts}

@pytest.fixture(scope="class")
def testPorts(self, duthosts, rand_one_dut_hostname, dutPorts):
def testPorts(self, duthosts, rand_one_dut_hostname, dutPorts, tbinfo):
"""
Select one upstream and one downstream ports for DHCP packet forwarding test

Expand All @@ -135,11 +135,13 @@ def testPorts(self, duthosts, rand_one_dut_hostname, dutPorts):
duthost = duthosts[rand_one_dut_hostname]
downstreamLags, downstreamPeerIp = self.__getPortLagsAndPeerIp(
duthost,
random.choice(dutPorts["downstreamPorts"])
random.choice(dutPorts["downstreamPorts"]),
tbinfo
)
upstreamLags, upstreamPeerIp = self.__getPortLagsAndPeerIp(
duthost,
random.choice(dutPorts["upstreamPorts"])
random.choice(dutPorts["upstreamPorts"]),
tbinfo
)

self.__updateRoute(duthost, self.DHCP_SERVER["ip"], upstreamPeerIp)
Expand Down
Loading