diff --git a/ansible/roles/test/files/ptftests/fib_test.py b/ansible/roles/test/files/ptftests/fib_test.py index 279234ed2cd..e0b506acbe5 100644 --- a/ansible/roles/test/files/ptftests/fib_test.py +++ b/ansible/roles/test/files/ptftests/fib_test.py @@ -38,7 +38,8 @@ from ptf.testutils import verify_packet_any_port from ptf.testutils import verify_no_packet_any -from collections import Iterable, defaultdict +from collections.abc import Iterable +from collections import defaultdict class FibTest(BaseTest): diff --git a/ansible/roles/test/files/ptftests/py3/hash_test.py b/ansible/roles/test/files/ptftests/py3/hash_test.py index aec7fdd81a6..b5f756ad9ee 100644 --- a/ansible/roles/test/files/ptftests/py3/hash_test.py +++ b/ansible/roles/test/files/ptftests/py3/hash_test.py @@ -12,7 +12,8 @@ import six import itertools -from collections import Iterable, defaultdict +from collections.abc import Iterable +from collections import defaultdict from ipaddress import ip_address, ip_network import ptf diff --git a/tests/common/helpers/ntp_helper.py b/tests/common/helpers/ntp_helper.py index d6ecb702589..43e1a847114 100644 --- a/tests/common/helpers/ntp_helper.py +++ b/tests/common/helpers/ntp_helper.py @@ -15,12 +15,25 @@ class NtpDaemon(Enum): @contextmanager def setup_ntp_context(ptfhost, duthost, ptf_use_ipv6): """setup ntp client and server""" - ptfhost.lineinfile(path="/etc/ntp.conf", line="server 127.127.1.0 prefer") + ntp_daemon_type = get_ntp_daemon_in_use(ptfhost) + ntp_conf_path = None + ntp_service_name = None + if ntp_daemon_type == NtpDaemon.NTPSEC: + ntp_conf_path = '/etc/ntpsec/ntp.conf' + ntp_service_name = 'ntpsec' + elif ntp_daemon_type == NtpDaemon.CHRONY: + ntp_conf_path = '/etc/chrony/chrony.conf' + ntp_service_name = 'chrony' + elif ntp_daemon_type == NtpDaemon.NTP: + ntp_conf_path = '/etc/ntp.conf' + ntp_service_name = 'ntp' + + ptfhost.lineinfile(path=ntp_conf_path, line="server 127.127.1.0 prefer") # restart ntp server - ntp_en_res = ptfhost.service(name="ntp", state="restarted") + ntp_en_res = ptfhost.service(name=ntp_service_name, state="restarted") - pytest_assert(wait_until(120, 5, 0, check_ntp_status, ptfhost, NtpDaemon.NTP), + pytest_assert(wait_until(120, 5, 0, check_ntp_status, ptfhost, ntp_daemon_type), "NTP server was not started in PTF container {}; NTP service start result {}" .format(ptfhost.hostname, ntp_en_res)) @@ -28,7 +41,7 @@ def setup_ntp_context(ptfhost, duthost, ptf_use_ipv6): # root dispersion of more than 3 seconds (configurable via /etc/chrony/chrony.conf, but we currently # don't touch that setting). Therefore, block here until the root dispersion is less than 3 seconds # so that we don't incorrectly fail the test. - pytest_assert(wait_until(180, 10, 0, check_max_root_dispersion, ptfhost, 3, NtpDaemon.NTP), + pytest_assert(wait_until(180, 10, 0, check_max_root_dispersion, ptfhost, 3, ntp_daemon_type), "NTP timing hasn't converged enough in PTF container {}".format(ptfhost.hostname)) # check to see if iburst option is present @@ -49,7 +62,7 @@ def setup_ntp_context(ptfhost, duthost, ptf_use_ipv6): yield # stop ntp server - ptfhost.service(name="ntp", state="stopped") + ptfhost.service(name=ntp_service_name, state="stopped") # reset ntp client configuration duthost.command("config ntp del %s" % (ptfhost.mgmt_ipv6 if ptf_use_ipv6 else ptfhost.mgmt_ip)) for ntp_server in ntp_servers: diff --git a/tests/gnmi/test_gnmi_appldb.py b/tests/gnmi/test_gnmi_appldb.py index 9ebd18edfee..b46810a3a16 100644 --- a/tests/gnmi/test_gnmi_appldb.py +++ b/tests/gnmi/test_gnmi_appldb.py @@ -28,6 +28,7 @@ def test_gnmi_appldb_01(duthosts, rand_one_dut_hostname, ptfhost): # Check gnmi_get result path_list1 = ["/sonic-db:APPL_DB/localhost/DASH_VNET_TABLE/Vnet1/vni"] path_list2 = ["/sonic-db:APPL_DB/localhost/_DASH_VNET_TABLE/Vnet1/vni"] + output = None try: msg_list1 = gnmi_get(duthost, ptfhost, path_list1) except Exception as e: