Skip to content

Commit 14e0ec1

Browse files
lizhijianrdAharonMalkin
authored andcommitted
[post-test] Add a param to specify show tech since in post-test (sonic-net#9771)
What is the motivation for this PR? Add a parameter to specify show tech since in post-test. The default value is yesterday, which keeps the same behavior as current code. To collect show tech result of all time spans, please specify --posttest_show_tech_since='-1hour'. How did you do it? Add parameter --posttest_show_tech_since in conftest.py and use it in test_collect_techsupport. How did you verify/test it? Verified on physical DUT with below parameters: * Do not specify --posttest_show_tech_since * Empty string: --posttest_show_tech_since= * Collect all time span: --posttest_show_tech_since='@0' * Collect since 1 hour ago: --posttest_show_tech_since='-1hour' Signed-off-by: Zhijian Li <[email protected]>
1 parent 7b3038b commit 14e0ec1

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

tests/conftest.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,14 @@ def pytest_addoption(parser):
149149
help="Specify the url of the saithrift package to be installed on the ptf "
150150
"(should be http://<serverip>/path/python-saithrift_0.9.4_amd64.deb")
151151

152+
#########################
153+
# post-test options #
154+
#########################
155+
parser.addoption("--posttest_show_tech_since", action="store", default="yesterday",
156+
help="collect show techsupport since <date>. <date> should be a string which can "
157+
"be parsed by bash command 'date --d <date>'. Default value is yesterday. "
158+
"To collect all time spans, please use '@0' as the value.")
159+
152160
############################
153161
# keysight ixanvl options #
154162
############################

tests/test_posttest.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,23 @@
1414
]
1515

1616

17-
def test_collect_techsupport(duthosts, enum_dut_hostname):
17+
def test_collect_techsupport(request, duthosts, enum_dut_hostname):
18+
since = request.config.getoption("--posttest_show_tech_since")
19+
if since == '':
20+
since = 'yesterday'
1821
duthost = duthosts[enum_dut_hostname]
1922
"""
2023
A util for collecting techsupport after tests.
2124
2225
Since nightly test on Jenkins will do a cleanup at the beginning of tests,
2326
we need a method to save history logs and dumps. This util does the job.
2427
"""
25-
logger.info("Collecting techsupport since yesterday")
28+
logger.info("Collecting techsupport since {}".format(since))
2629
# Because Jenkins is configured to save artifacts from tests/logs,
2730
# and this util is mainly designed for running on Jenkins,
2831
# save path is fixed to logs for now.
2932
TECHSUPPORT_SAVE_PATH = 'logs/'
30-
out = duthost.command("generate_dump -s yesterday", module_ignore_errors=True)
33+
out = duthost.command("show techsupport --since {}".format(since), module_ignore_errors=True)
3134
if out['rc'] == 0:
3235
tar_file = out['stdout_lines'][-1]
3336
duthost.fetch(src=tar_file, dest=TECHSUPPORT_SAVE_PATH, flat=True)

0 commit comments

Comments
 (0)