Skip to content

Commit b19e8b1

Browse files
committed
check if ntp restarted after apply-patch
1 parent 0402eac commit b19e8b1

4 files changed

Lines changed: 34 additions & 31 deletions

File tree

ansible/vtestbed.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,8 @@
173173
topo: dualtor-mixed
174174
ptf_image_name: docker-ptf
175175
ptf: ptf-08
176-
ptf_ip: 10.250.0.119/24
176+
ptf_ip: 10.250.0.109/24
177177
ptf_ipv6: fec0::ffff:afa:9/64
178-
netns_mgmt_ip: 10.250.0.126/24
179178
server: server_1
180179
vm_base: VM0140
181180
dut:

tests/common/devices/ptf.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import tempfile
44

55
from tests.common.devices.base import AnsibleHostBase
6-
from tests.macsec.macsec_helper import load_macsec_info
6+
#from tests.macsec.macsec_helper import load_macsec_info
77

88
logger = logging.getLogger(__name__)
99

@@ -31,20 +31,20 @@ def change_mac_addresses(self):
3131
def remove_ip_addresses(self):
3232
self.script(REMOVE_IP_ADDRESS_SCRIPT)
3333

34-
def create_macsec_info(self):
35-
macsec_info = {}
36-
for port_name, injected_port_id in self.duthost.get_extended_minigraph_facts(self.tbinfo)["minigraph_ptf_indices"].items():
37-
try:
38-
macsec_info[injected_port_id] = load_macsec_info(
39-
self.duthost, port_name, force_reload=True)
40-
except KeyError:
41-
# If key error, It means the MACsec info isn't enabled in the specified port.
42-
logging.info(
43-
"MACsec isn't enabled on the port {}".format(port_name))
44-
continue
45-
tf = tempfile.NamedTemporaryFile(delete=True)
46-
pickle.dump(macsec_info, tf)
47-
tf.flush()
48-
self.copy(src=tf.name, dest="/root/" + MACSEC_INFO_FILE)
34+
# def create_macsec_info(self):
35+
# macsec_info = {}
36+
# for port_name, injected_port_id in self.duthost.get_extended_minigraph_facts(self.tbinfo)["minigraph_ptf_indices"].items():
37+
# try:
38+
# macsec_info[injected_port_id] = load_macsec_info(
39+
# self.duthost, port_name, force_reload=True)
40+
# except KeyError:
41+
# # If key error, It means the MACsec info isn't enabled in the specified port.
42+
# logging.info(
43+
# "MACsec isn't enabled on the port {}".format(port_name))
44+
# continue
45+
# tf = tempfile.NamedTemporaryFile(delete=True)
46+
# pickle.dump(macsec_info, tf)
47+
# tf.flush()
48+
# self.copy(src=tf.name, dest="/root/" + MACSEC_INFO_FILE)
4949

5050
# TODO: Add a method for running PTF script

tests/conftest.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@
4343
from tests.common.connections.console_host import ConsoleHost
4444
from tests.common.utilities import str2bool
4545

46-
try:
47-
from tests.macsec import MacsecPlugin
48-
except ImportError as e:
49-
logging.error(e)
46+
#try:
47+
# from tests.macsec import MacsecPlugin
48+
#except ImportError as e:
49+
# logging.error(e)
5050

5151
from tests.platform_tests.args.advanced_reboot_args import add_advanced_reboot_args
5252
from tests.platform_tests.args.cont_warm_reboot_args import add_cont_warm_reboot_args
@@ -162,9 +162,9 @@ def pytest_addoption(parser):
162162
type=str, help="profile name list in macsec/profile.json")
163163

164164

165-
def pytest_configure(config):
166-
if config.getoption("enable_macsec"):
167-
config.pluginmanager.register(MacsecPlugin())
165+
#def pytest_configure(config):
166+
# if config.getoption("enable_macsec"):
167+
# config.pluginmanager.register(MacsecPlugin())
168168

169169

170170
@pytest.fixture(scope="session", autouse=True)

tests/generic_config_updater/test_ntp.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import datetime
12
import logging
23
import pytest
34
import re
@@ -74,14 +75,14 @@ def server_exist_in_conf(duthost, server_pattern):
7475
return False
7576

7677

77-
def ntp_service_restarted(duthost):
78-
""" Check if ntp.service is just restarted within 10 secs
78+
def ntp_service_restarted(duthost, start_time):
79+
""" Check if ntp.service is just restarted after start_time
7980
"""
8081
output = duthost.shell("systemctl show ntp.service --property ActiveState --value")
8182
if output["stdout"] != "active":
8283
return False
8384
output = duthost.shell("ps -o etimes -p $(systemctl show ntp.service --property ExecMainPID --value) | sed '1d'")
84-
if int(output['stdout'].strip()) < 10:
85+
if int(output['stdout'].strip()) < (datetime.datetime.now() - start_time).seconds:
8586
return True
8687
return False
8788

@@ -103,11 +104,12 @@ def ntp_server_tc1_add_config(duthost):
103104
logger.info("tmpfile {}".format(tmpfile))
104105

105106
try:
107+
start_time = datetime.datetime.now()
106108
output = apply_patch(duthost, json_data=json_patch, dest_file=tmpfile)
107109
expect_op_success(duthost, output)
108110

109111
pytest_assert(
110-
ntp_service_restarted(duthost),
112+
ntp_service_restarted(duthost, start_time),
111113
"ntp.service is not restarted after change"
112114
)
113115
pytest_assert(
@@ -170,11 +172,12 @@ def ntp_server_tc1_replace(duthost):
170172
logger.info("tmpfile {}".format(tmpfile))
171173

172174
try:
175+
start_time = datetime.datetime.now()
173176
output = apply_patch(duthost, json_data=json_patch, dest_file=tmpfile)
174177
expect_op_success(duthost, output)
175178

176179
pytest_assert(
177-
ntp_service_restarted(duthost),
180+
ntp_service_restarted(duthost, start_time),
178181
"ntp.service is not restarted after change"
179182
)
180183
pytest_assert(
@@ -201,11 +204,12 @@ def ntp_server_tc1_remove(duthost):
201204
logger.info("tmpfile {}".format(tmpfile))
202205

203206
try:
207+
start_time = datetime.datetime.now()
204208
output = apply_patch(duthost, json_data=json_patch, dest_file=tmpfile)
205209
expect_op_success(duthost, output)
206210

207211
pytest_assert(
208-
ntp_service_restarted(duthost),
212+
ntp_service_restarted(duthost, start_time),
209213
"ntp.service is not restarted after change"
210214
)
211215
pytest_assert(

0 commit comments

Comments
 (0)