Skip to content

Commit 288ea57

Browse files
meakshdwoz
andauthored
Even more reliable pillar timeout test
* Even more reliable pillar timeout test * Use sys.executable on test_pillar_timeout test --------- Co-authored-by: Daniel A. Wozniak <[email protected]>
1 parent e0c3d4a commit 288ea57

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

tests/pytests/integration/minion/test_return_retries.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from saltfactories.utils import random_string
66

77
from tests.support.helpers import dedent
8+
import salt.utils.files
89

910

1011
@pytest.fixture(scope="function")
@@ -57,14 +58,13 @@ def test_publish_retry(salt_master, salt_minion_retry, salt_cli, salt_run_cli):
5758

5859
@pytest.mark.slow_test
5960
@pytest.mark.flaky(max_runs=4)
60-
def test_pillar_timeout(salt_master_factory):
61-
cmd = (
62-
sys.executable
63-
+ ' -c "import time; time.sleep(4.8); print(\'{\\"foo\\": \\"bar\\"}\');"'
64-
).strip()
61+
def test_pillar_timeout(salt_master_factory, tmp_path):
62+
with salt.utils.files.fopen(tmp_path / "script.py", "w") as fp:
63+
fp.write('print(\'{"foo": "bar"}\');\n')
64+
6565
master_overrides = {
6666
"ext_pillar": [
67-
{"cmd_json": cmd},
67+
{"cmd_json": f"{sys.executable} {tmp_path / 'script.py'}"},
6868
],
6969
"auto_accept": True,
7070
"worker_threads": 3,
@@ -110,7 +110,11 @@ def test_pillar_timeout(salt_master_factory):
110110
sls_tempfile = master.state_tree.base.temp_file(
111111
"{}.sls".format(sls_name), sls_contents
112112
)
113-
with master.started(), minion1.started(), minion2.started(), minion3.started(), minion4.started(), sls_tempfile:
113+
with master.started(), minion1.started(), minion2.started(), minion3.started(), minion4.started(), (
114+
sls_tempfile
115+
):
116+
with salt.utils.files.fopen(tmp_path / "script.py", "w") as fp:
117+
fp.write('import time; time.sleep(6); print(\'{"foo": "bang"}\');\n')
114118
proc = cli.run("state.sls", sls_name, minion_tgt="*")
115119
# At least one minion should have a Pillar timeout
116120
print(proc)

0 commit comments

Comments
 (0)