test: publish supervisor sample PID witness atomically
This commit is contained in:
1 parent
93f0253037
commit
086e0ebb61
2 files changed
+13
-6
No files matched your search
@@ -357,11 +357,12 @@ def test_failed_protection_fsync_is_retried_before_force_is_allowed(tmp_path, mo
|
||||
thread.join(3)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('deny_first,transport_failure,cleanup_failure,late_write_failure', [
|
||||
(False, False, False, False), (True, False, False, False), (False, True, False, False),
|
||||
(False, False, True, False), (False, False, False, True), (False, False, True, True)])
|
||||
@pytest.mark.parametrize('deny_first,transport_failure,cleanup_failure,late_write_failure,slow_witness', [
|
||||
(False, False, False, False, False), (True, False, False, False, False), (False, True, False, False, False),
|
||||
(False, False, True, False, False), (False, False, False, True, False), (False, False, True, True, False),
|
||||
(False, False, False, False, True)])
|
||||
def test_real_supervisor_force_preserves_protection_and_never_replays(
|
||||
tmp_path, monkeypatch, deny_first, transport_failure, cleanup_failure, late_write_failure):
|
||||
tmp_path, monkeypatch, deny_first, transport_failure, cleanup_failure, late_write_failure, slow_witness):
|
||||
import os
|
||||
import textwrap
|
||||
import time
|
||||
@@ -386,7 +387,11 @@ def test_real_supervisor_force_preserves_protection_and_never_replays(
|
||||
def business(self, task_id, **kwargs):
|
||||
root=self._project_task_service(task_id)._quick_run_preparer.data_root/'quick-run'
|
||||
root.mkdir(parents=True,exist_ok=True)
|
||||
(root/'started').write_text(str(os.getpid()))
|
||||
with (root/'started.tmp').open('w') as stream:
|
||||
if sys.argv[2] == 'slow':
|
||||
time.sleep(.2)
|
||||
stream.write(str(os.getpid()))
|
||||
(root/'started.tmp').replace(root/'started')
|
||||
request=json.loads(Path(sys.argv[1]).read_text(encoding='utf-8'))
|
||||
print(json.dumps({'version':1,'batch_id':request['batch_id'],'attempt_id':request['attempt_id'],
|
||||
'generation':1,'sequence':100,'type':'progress','payload':'fixture executing'}),flush=True)
|
||||
@@ -397,7 +402,7 @@ def test_real_supervisor_force_preserves_protection_and_never_replays(
|
||||
''')
|
||||
original_command = module._command
|
||||
monkeypatch.setattr(module, '_command', lambda request:
|
||||
(sys.executable, '-c', bootstrap, str(request))
|
||||
(sys.executable, '-c', bootstrap, str(request), 'slow' if slow_witness else 'normal')
|
||||
if json.loads(request.read_text())['operation'] == 'execute_quick_run' else original_command(request))
|
||||
original_mark = module._mark_interrupted
|
||||
denied = []
|
||||
@@ -459,6 +464,7 @@ def test_real_supervisor_force_preserves_protection_and_never_replays(
|
||||
control.request_force()
|
||||
except Exception as error:
|
||||
driver_errors.append(error)
|
||||
control.request_force()
|
||||
thread = Thread(target=request)
|
||||
thread.start()
|
||||
try:
|
||||
|
||||
Reference in new issue
Block a user