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
18 changes: 16 additions & 2 deletions tests/common/fixtures/ptfhost_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
from tests.common.dualtor.dual_tor_utils import update_linkmgrd_probe_interval, recover_linkmgrd_probe_interval
from tests.common.utilities import wait_until
from tests.common.dualtor.dual_tor_utils import mux_cable_server_ip
from pytest_ansible.errors import AnsibleConnectionFailure


logger = logging.getLogger(__name__)

Expand All @@ -35,6 +37,7 @@
GARP_SERVICE_CONF_TEMPL = 'garp_service.conf.j2'
PTF_TEST_PORT_MAP = '/root/ptf_test_port_map.json'
PROBER_INTERVAL_MS = 3000
PTFHOST_EXCEPTION_RC = 16


@pytest.fixture(scope="session", autouse=True)
Expand Down Expand Up @@ -299,11 +302,17 @@ def ptf_portmap_file_module(rand_selected_dut, ptfhost, tbinfo):
yield _ptf_portmap_file(rand_selected_dut, ptfhost, tbinfo)


def pytest_sessionfinish(session, exitstatus):
if session.config.cache.get("ptfhost_exception", None):
session.config.cache.set("ptfhost_exception", None)
session.exitstatus = PTFHOST_EXCEPTION_RC


icmp_responder_session_started = False


@pytest.fixture(scope="session", autouse=True)
def run_icmp_responder_session(duthosts, duthost, ptfhost, tbinfo):
def run_icmp_responder_session(duthosts, duthost, ptfhost, tbinfo, request):
"""Run icmp_responder on ptfhost session-wise on dualtor testbeds with active-active ports."""
# No vlan is available on non-t0 testbed, so skip this fixture
if "dualtor-mixed" not in tbinfo["topo"]["name"] and "dualtor-aa" not in tbinfo["topo"]["name"]:
Expand All @@ -319,7 +328,12 @@ def run_icmp_responder_session(duthosts, duthost, ptfhost, tbinfo):

duthost = duthosts[0]
logger.debug("Copy icmp_responder.py to ptfhost '{0}'".format(ptfhost.hostname))
ptfhost.copy(src=os.path.join(SCRIPTS_SRC_DIR, ICMP_RESPONDER_PY), dest=OPT_DIR)
try:
ptfhost.copy(src=os.path.join(SCRIPTS_SRC_DIR, ICMP_RESPONDER_PY), dest=OPT_DIR)
except AnsibleConnectionFailure as e:
logger.error("Failed to copy files to ptfhost.")
request.config.cache.set("ptfhost_exception", True)
pt_assert(False, "!!! ptfhost copy file failed !!! Exception: {}".format(repr(e)))

logger.info("Start running icmp_responder")
templ = Template(open(os.path.join(TEMPLATES_DIR, ICMP_RESPONDER_CONF_TEMPL)).read())
Expand Down
6 changes: 6 additions & 0 deletions tests/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,12 @@ function run_individual_tests()
return ${ret_code}
fi

# rc 16 means ptfhost is unreachable
if [ ${ret_code} -eq 16 ]; then
echo "=== ptfhost has exception for $test_script. Skip rest of the scripts if there is any. ==="
return ${ret_code}
fi

EXIT_CODE=1
if [[ ${TEST_MAX_FAIL} != 0 ]]; then
return ${EXIT_CODE}
Expand Down
Loading