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
1 change: 1 addition & 0 deletions .azure-pipelines/pr_test_scripts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ t0:
- test_procdockerstatsd.py
- database/test_db_scripts.py
- system_health/test_watchdog.py
- ip/test_mgmt_ipv6_only.py

t0-2vlans:
- dhcp_relay/test_dhcp_relay.py
Expand Down
6 changes: 3 additions & 3 deletions tests/ip/test_mgmt_ipv6_only.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from tests.bgp.test_bgp_fact import run_bgp_facts
from tests.test_features import run_show_features
from tests.tacacs.test_ro_user import ssh_remote_run
from tests.ntp.test_ntp import run_ntp, setup_ntp # noqa F401
from tests.ntp.test_ntp import run_ntp, setup_ntp_func # noqa F401
from tests.common.helpers.assertions import pytest_require
from tests.tacacs.conftest import tacacs_creds, check_tacacs_v6_func # noqa F401
from tests.syslog.test_syslog import run_syslog, check_default_route # noqa F401
Expand Down Expand Up @@ -179,5 +179,5 @@ def test_telemetry_output_ipv6_only(convert_and_restore_config_db_to_ipv6_only,

# use function scope fixture so that convert_and_restore_config_db_to_ipv6_only will run before setup_ntp_func
def test_ntp_ipv6_only(duthosts, rand_one_dut_hostname,
convert_and_restore_config_db_to_ipv6_only, setup_ntp): # noqa F811
run_ntp(duthosts, rand_one_dut_hostname, setup_ntp)
convert_and_restore_config_db_to_ipv6_only, setup_ntp_func): # noqa F811
run_ntp(duthosts, rand_one_dut_hostname, setup_ntp_func)
13 changes: 13 additions & 0 deletions tests/ntp/test_ntp.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import logging
import time
import pytest
from contextlib import contextmanager

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -46,6 +47,18 @@ def config_long_jump(duthost, enable=False):

@pytest.fixture(scope="module")
def setup_ntp(ptfhost, duthosts, rand_one_dut_hostname, ptf_use_ipv6):
with _context_for_setup_ntp(ptfhost, duthosts, rand_one_dut_hostname, ptf_use_ipv6) as result:
yield result


@pytest.fixture(scope="function")
def setup_ntp_func(ptfhost, duthosts, rand_one_dut_hostname, ptf_use_ipv6):
with _context_for_setup_ntp(ptfhost, duthosts, rand_one_dut_hostname, ptf_use_ipv6) as result:
yield result


@contextmanager
def _context_for_setup_ntp(ptfhost, duthosts, rand_one_dut_hostname, ptf_use_ipv6):
"""setup ntp client and server"""
duthost = duthosts[rand_one_dut_hostname]

Expand Down