Fix test_system flaky setup_teardown fn

This commit is contained in:
Marek Czernek 2024-08-30 11:37:27 +02:00 committed by Daniel Wozniak
parent 99639ca5c9
commit 6c38c1a253

View file

@ -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