Repeat to reduce flakyness

Signed-off-by: Pedro Algarvio <palgarvio@vmware.com>
This commit is contained in:
Pedro Algarvio 2022-12-19 07:50:04 +00:00 committed by Pedro Algarvio
parent d78d377a42
commit a3b29c8341
3 changed files with 29 additions and 3 deletions

View file

@ -9,4 +9,11 @@ pytestmark = [
def test_sync_grains(salt_call_cli):
ret = salt_call_cli.run("saltutil.sync_grains")
assert ret.returncode == 0
assert ret.data == []
try:
assert ret.data == []
except AssertionError:
# Maybe it had to sync again on the above call.
# On this next call though, it shold return an empty list
ret = salt_call_cli.run("saltutil.sync_grains")
assert ret.returncode == 0
assert ret.data == []

View file

@ -2,6 +2,7 @@
Integration tests for salt-ssh logging
"""
import logging
import time
import pytest
from saltfactories.utils import random_string
@ -117,6 +118,16 @@ def test_log_password(salt_ssh_cli, caplog, ssh_auth):
ret = salt_ssh_cli.run("--log-level=trace", "test.ping", minion_tgt="pyvertest")
if "kex_exchange_identification" in ret.stdout:
pytest.skip("Container closed ssh connection, skipping for now")
try:
assert ret.returncode == 0
except AssertionError:
time.sleep(5)
with caplog.at_level(logging.TRACE):
ret = salt_ssh_cli.run(
"--log-level=trace", "test.ping", minion_tgt="pyvertest"
)
if "kex_exchange_identification" in ret.stdout:
pytest.skip("Container closed ssh connection, skipping for now")
assert ret.returncode == 0
assert ssh_pass not in caplog.text
assert ret.returncode == 0
assert ret.data is True

View file

@ -163,7 +163,15 @@ def test_setup(salt_ssh_cli, ssh_container_name, ssh_sub_container_name, ssh_pas
ret = salt_ssh_cli.run(
"--passwd", ssh_password, "--key-deploy", "test.ping", minion_tgt="*"
)
assert ret.returncode == 0
try:
assert ret.returncode == 0
except AssertionError:
# Sleep and Repeat in case of failure to reduce flakyness
time.sleep(5)
ret = salt_ssh_cli.run(
"--passwd", ssh_password, "--key-deploy", "test.ping", minion_tgt="*"
)
assert ret.returncode == 0
for id in possible_ids:
assert id in ret.data
assert ret.data[id] is True