From 6c38c1a253a0e34072a20d3a637b1339fe4b3f4a Mon Sep 17 00:00:00 2001 From: Marek Czernek Date: Fri, 30 Aug 2024 11:37:27 +0200 Subject: [PATCH] Fix test_system flaky setup_teardown fn --- tests/pytests/functional/modules/test_system.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/pytests/functional/modules/test_system.py b/tests/pytests/functional/modules/test_system.py index 07f34e8a516..5944507c1ee 100644 --- a/tests/pytests/functional/modules/test_system.py +++ b/tests/pytests/functional/modules/test_system.py @@ -5,10 +5,12 @@ import shutil import signal import subprocess import textwrap +import time import pytest import salt.utils.files +from salt.exceptions import CommandExecutionError pytestmark = [ pytest.mark.skip_unless_on_linux, @@ -76,7 +78,13 @@ def setup_teardown_vars(file, service, system): file.remove("/etc/machine-info") if _systemd_timesyncd_available_: - res = service.start("systemd-timesyncd") + try: + res = service.start("systemd-timesyncd") + except CommandExecutionError: + # We possibly did too many restarts in too short time + # Wait 10s (default systemd timeout) and try again + time.sleep(10) + res = service.start("systemd-timesyncd") assert res