Skip to content
Merged
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
38 changes: 19 additions & 19 deletions tests/drop_packets/drop_packets.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@
import importlib
import netaddr
import pytest
import time

import ptf.testutils as testutils
import ptf.mask as mask
import ptf.packet as packet

from tests.common.helpers.assertions import pytest_assert
from tests.common.platform.device_utils import fanout_switch_port_lookup

RX_DRP = "RX_DRP"
RX_ERR = "RX_ERR"
L2_COL_KEY = RX_DRP
Expand Down Expand Up @@ -142,40 +146,36 @@ def setup(duthost, tbinfo):


@pytest.fixture
def rif_port_down(duthost, setup, loganalyzer):
""" Disable RIF interface and return neighbor IP address attached to this interface """
def rif_port_down(duthost, setup, fanouthosts):
"""Shut RIF interface and return neighbor IP address attached to this interface.

The RIF member is shut from the fanout side so that the ARP entry remains in
place on the DUT."""
wait_after_ports_up = 30

if not setup["rif_members"]:
pytest.skip("RIF interface is absent")
rif_member_iface = setup["rif_members"].keys()[0]

try:
vm_name = setup["mg_facts"]["minigraph_neighbors"][rif_member_iface]["name"]
except KeyError as err:
pytest.fail("Didn't found RIF interface in 'minigraph_neighbors'. {}".format(str(err)))
vm_name = setup["mg_facts"]["minigraph_neighbors"][rif_member_iface].get("name", None)
pytest_assert(vm_name, 'Neighbor not found for RIF member "{}"'.format(rif_member_iface))

ip_dst = None
for item in setup["mg_facts"]["minigraph_bgp"]:
if item["name"] == vm_name:
if netaddr.valid_ipv4(item["addr"]):
ip_dst = item["addr"]
break
else:
pytest.fail("Unable to find neighbor in 'minigraph_bgp' list")
if item["name"] == vm_name and netaddr.valid_ipv4(item["addr"]):
ip_dst = item["addr"]
break
pytest_assert(ip_dst, 'Unable to find IP address for neighbor "{}"'.format(vm_name))

loganalyzer.expect_regex = [LOG_EXPECT_PORT_ADMIN_DOWN_RE.format(rif_member_iface)]
with loganalyzer as analyzer:
duthost.command("config interface shutdown {}".format(rif_member_iface))
fanout_neighbor, fanout_intf = fanout_switch_port_lookup(fanouthosts, rif_member_iface)

fanout_neighbor.shutdown(fanout_intf)
time.sleep(1)

yield ip_dst

loganalyzer.expect_regex = [LOG_EXPECT_PORT_ADMIN_UP_RE.format(rif_member_iface)]
with loganalyzer as analyzer:
duthost.command("config interface startup {}".format(rif_member_iface))
time.sleep(wait_after_ports_up)
fanout_neighbor.no_shutdown(fanout_intf)
time.sleep(wait_after_ports_up)


@pytest.fixture(params=["port_channel_members", "vlan_members", "rif_members"])
Expand Down