Skip to content

Commit e0bc49b

Browse files
authored
[advanced-reboot] Set timeout for reboot test to prevent hung tests (#5365)
Advanced-reboot testcases sometimes gets hung inside ptf. This was earlier handled as part of #4532 Although PR 4532 sets a timeout for PTF test, the inbuilt --test-case-timeout interrupts the advanced-reboot test as expected, but sometimes that is not enough. After the timeout interrupt, the test still proceeds to collect logs and analyze the pcap files. In an unlikely event when the analysis logic is hung, the whole testcase stays hung indefinitely. This commit fixes this testcase hung issue.
1 parent 189cb13 commit e0bc49b

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

tests/common/fixtures/advanced_reboot.py

+14-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from tests.common.helpers.sad_path import SadOperation
1414
from tests.ptf_runner import ptf_runner
1515
from tests.common.helpers.assertions import pytest_assert
16+
from tests.common.utilities import InterruptableThread
1617

1718
logger = logging.getLogger(__name__)
1819

@@ -448,9 +449,21 @@ def runRebootTest(self):
448449
pre_reboot_analysis, post_reboot_analysis = self.advanceboot_loganalyzer
449450
marker = pre_reboot_analysis()
450451
self.__setupRebootOper(rebootOper)
451-
result = self.__runPtfRunner(rebootOper)
452+
thread = InterruptableThread(
453+
target=self.__runPtfRunner,
454+
kwargs={"rebootOper": rebootOper})
455+
thread.daemon = True
456+
thread.start()
457+
# give the test REBOOT_CASE_TIMEOUT (1800s) to complete the reboot with IO,
458+
# and then additional 300s to examine the pcap, logs and generate reports
459+
ptf_timeout = REBOOT_CASE_TIMEOUT + 300
460+
thread.join(timeout=ptf_timeout, suppress_exception=True)
461+
self.ptfhost.shell("pkill -f 'ptftests advanced-reboot.ReloadTest'", module_ignore_errors=True)
462+
# the thread might still be running, and to catch any exceptions after pkill allow 10s to join
463+
thread.join(timeout=10)
452464
self.__verifyRebootOper(rebootOper)
453465
except Exception:
466+
logger.error("Exception caught while running advanced-reboot test on ptf")
454467
failed_list.append(rebootOper)
455468
finally:
456469
# always capture the test logs

0 commit comments

Comments
 (0)