Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pfc tests migration from abstract to snappi #3641

Closed
Closed
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
425 changes: 425 additions & 0 deletions tests/common/fixtures/snappi_fixtures.py

Large diffs are not rendered by default.

74 changes: 74 additions & 0 deletions tests/snappi/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import pytest
import random
from tests.common.ixia.common_helpers import enable_packet_aging, start_pfcwd
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use tests.common.snappi.common_helpers instead.

from tests.conftest import generate_priority_lists

@pytest.fixture(autouse=True, scope="module")
def rand_lossless_prio(request):
"""
Fixture that randomly selects a lossless priority

Args:
request (object): pytest request object

Yields:
lossless priority (str): string containing 'hostname|lossless priority'

"""
lossless_prios = generate_priority_lists(request, "lossless")
if lossless_prios:
yield random.sample(lossless_prios, 1)[0]
else:
yield 'unknown|unknown'

@pytest.fixture(autouse=True, scope="module")
def rand_lossy_prio(request):
"""
Fixture that randomly selects a lossy priority

Args:
request (object): pytest request object

Yields:
lossy priority (str): string containing 'hostname|lossy priority'

"""
lossy_prios = generate_priority_lists(request, "lossy")
if lossy_prios:
yield random.sample(lossy_prios, 1)[0]
else:
yield 'unknown|unknown'

@pytest.fixture(autouse=True, scope="module")
def start_pfcwd_after_test(duthosts, rand_one_dut_hostname):
"""
Ensure that PFC watchdog is enabled with default setting after tests

Args:
duthosts (pytest fixture) : list of DUTs
rand_one_dut_hostname (pytest fixture): DUT hostname

Yields:
N/A
"""
yield

duthost = duthosts[rand_one_dut_hostname]
start_pfcwd(duthost)

@pytest.fixture(autouse=True, scope="module")
def enable_packet_aging_after_test(duthosts, rand_one_dut_hostname):
"""
Ensure that packet aging is enabled after tests

Args:
duthosts (pytest fixture) : list of DUTs
rand_one_dut_hostname (pytest fixture): DUT hostname

Yields:
N/A
"""
yield

duthost = duthosts[rand_one_dut_hostname]
enable_packet_aging(duthost)
Empty file added tests/snappi/pfc/__init__.py
Empty file.
1 change: 1 addition & 0 deletions tests/snappi/pfc/files/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Local library for PFC tests.
Loading