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
@@ -13,6 +13,7 @@
|
||||
| 监督进程是否有控制器 | 子进程始终持有内部停止控制器,以接收已授权的监督控制;父请求 `interactive_stop` 独立反映调用方权限。测试分别检查二者。 |
|
||||
| 跨模块 Desktop.created 泄漏 | 共享模拟运行时工厂自身初始化 Desktop/Cad 状态,不依赖另一个测试文件的 autouse fixture。 |
|
||||
| 未知弹窗样例的组合失败 | 先断言未知弹窗未被自动点击,再模拟操作员按记录指纹明确选择样例按钮、等待自然退出。确认无强制结束,不依赖异常杀进程清理测试窗口。 |
|
||||
| 强制结束样例的就绪标记 | 子进程先写完临时 PID 标记再原子发布,父测试线程不能读到空文件。新增可控慢写样例,仍须通过完整强制结束保护和不重放断言;测试驱动出错时仅清理自己启动的样例。 |
|
||||
|
||||
## 生产逻辑修复
|
||||
|
||||
|
||||
@@ -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