MCPcopy Create free account
hub / github.com/saltstack/salt / test_batch_issue_56273

Function test_batch_issue_56273

tests/pytests/functional/cli/test_batch.py:153–187  ·  view source on GitHub ↗

Regression test for race condition in batch logic. https://github.com/saltstack/salt/issues/56273

()

Source from the content-addressed store, hash-verified

151
152
153def test_batch_issue_56273():
154 """
155 Regression test for race condition in batch logic.
156 https://github.com/saltstack/salt/issues/56273
157 """
158
159 mock_pub = MockPub()
160 MockSubscriber.pubret = mock_pub
161
162 def returns_for_job(jid):
163 return True
164
165 opts = {
166 "conf_file": "",
167 "tgt": "minion*",
168 "fun": "state.sls",
169 "arg": ["foo"],
170 "timeout": 1,
171 "gather_job_timeout": 1,
172 "batch": 2,
173 "extension_modules": "",
174 "failhard": True,
175 }
176 with patch("salt.transport.tcp.PublishClient", MockSubscriber):
177 batch = salt.cli.batch.Batch(opts, quiet=True)
178 with patch.object(batch.local, "pub", Mock(side_effect=mock_pub)):
179 with patch.object(
180 batch.local, "returns_for_job", Mock(side_effect=returns_for_job)
181 ):
182 ret = list(batch.run())
183 assert len(ret) == 4
184 for val, _ in ret:
185 values = list(val.values())
186 assert len(values) == 1
187 assert values[0] is True
188
189
190class MockPubSingleJid:

Callers

nothing calls this directly

Calls 5

runMethod · 0.95
MockPubClass · 0.85
patchFunction · 0.50
listFunction · 0.50
valuesMethod · 0.45

Tested by

no test coverage detected