Skip to content
Open
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
43 changes: 43 additions & 0 deletions tests/qos/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,49 @@ def skip_lossy_buffer_only(is_lossy_only_pool):
pytest.skip("Skip test for lossy only pool")


# Global variable to track fixture failures per parameter set for TestQosSai
_fixture_failures = {}


def pytest_sessionstart(session):
"""Clear fixture failure tracking to prevent stale state in pytest-xdist workers."""
_fixture_failures.clear()


def pytest_runtest_makereport(item, call):
"""Record fixture failures during setup to skip subsequent tests in the same parameter set."""
if not (hasattr(item, 'cls') and item.cls and item.cls.__name__ == 'TestQosSai'):
return

if call.when == "setup" and call.excinfo is not None:
test_name = item.name
if '[' in test_name:
param_set = test_name.split('[')[1].rstrip(']')
else:
param_set = 'default'

_fixture_failures[param_set] = True


def pytest_runtest_setup(item):
"""Skip tests if fixtures failed for this parameter set."""
if not (hasattr(item, 'cls') and item.cls and item.cls.__name__ == 'TestQosSai'):
return

# Don't skip seed tests - let them fail naturally to show the root cause
if 'fixture_seed' in item.keywords:
return

test_name = item.name
if '[' in test_name:
param_set = test_name.split('[')[1].rstrip(']')
else:
param_set = 'default'

if param_set in _fixture_failures:
pytest.skip(f"Skipping because fixtures failed for parameter set [{param_set}]")


@pytest.fixture(scope="module", autouse=True)
def enable_dscp_remapping_on_dualtor_flag(request, duthost):
"""
Expand Down
1 change: 1 addition & 0 deletions tests/qos/test_qos_sai.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,7 @@ def check_and_set_ecn_status(self, duthost, qosConfig, expected_status='on'):

return ecn_status

@pytest.mark.fixture_seed
def testParameter(
self, duthosts, get_src_dst_asic_and_duts, dutConfig, dutQosConfig, ingressLosslessProfile,
ingressLossyProfile, egressLosslessProfile, dualtor_ports_for_duts
Expand Down
Loading