|
5 | 5 | from saltfactories.utils import random_string |
6 | 6 |
|
7 | 7 | from tests.support.helpers import dedent |
| 8 | +import salt.utils.files |
8 | 9 |
|
9 | 10 |
|
10 | 11 | @pytest.fixture(scope="function") |
@@ -57,14 +58,13 @@ def test_publish_retry(salt_master, salt_minion_retry, salt_cli, salt_run_cli): |
57 | 58 |
|
58 | 59 | @pytest.mark.slow_test |
59 | 60 | @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 | + |
65 | 65 | master_overrides = { |
66 | 66 | "ext_pillar": [ |
67 | | - {"cmd_json": cmd}, |
| 67 | + {"cmd_json": f"{sys.executable} {tmp_path / 'script.py'}"}, |
68 | 68 | ], |
69 | 69 | "auto_accept": True, |
70 | 70 | "worker_threads": 3, |
@@ -110,7 +110,11 @@ def test_pillar_timeout(salt_master_factory): |
110 | 110 | sls_tempfile = master.state_tree.base.temp_file( |
111 | 111 | "{}.sls".format(sls_name), sls_contents |
112 | 112 | ) |
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') |
114 | 118 | proc = cli.run("state.sls", sls_name, minion_tgt="*") |
115 | 119 | # At least one minion should have a Pillar timeout |
116 | 120 | print(proc) |
|
0 commit comments