Skip to content

Commit cba5cae

Browse files
committed
test: stabilize Windows concurrency checks
1 parent b0bee2b commit cba5cae

2 files changed

Lines changed: 11 additions & 8 deletions

File tree

tests/mcp/test_oauth.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1363,17 +1363,16 @@ def wait_for_barrier(name: str) -> None:
13631363
time.sleep(0.01)
13641364
13651365
class BarrierStorage(MCPSecretStorage):
1366-
_blob_barrier_fired = False
1366+
_blob_reads = 0
13671367
13681368
def get_secret(self, key: str) -> str | None:
13691369
value = super().get_secret(key)
13701370
# 所有 OAuth 字段现在合并进单个 blob 条目;两个进程都读到过期旧状态后,
13711371
# 用一次性栅栏让它们同时进入刷新竞争,验证粗粒度 CAS 锁只放行一次网络刷新。
1372-
if not self._blob_barrier_fired and key == oauth_module.oauth_storage_key(
1373-
config, scope=MCPConfigScope.USER
1374-
):
1375-
self._blob_barrier_fired = True
1376-
wait_for_barrier("oauth-blob-read")
1372+
if key == oauth_module.oauth_storage_key(config, scope=MCPConfigScope.USER):
1373+
self._blob_reads += 1
1374+
if self._blob_reads == 4:
1375+
wait_for_barrier("oauth-blob-read")
13771376
return value
13781377
13791378
oauth_module.discover_oauth_metadata = lambda _config: oauth_module.OAuthMetadata(

tests/skill_bridge/test_alicloud_ros_agent_bridge.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2298,15 +2298,19 @@ def test_manager_idle_countdown_starts_after_sse_worker_exits(monkeypatch, tmp_p
22982298
monkeypatch.setenv(bridge.STATE_DIR_ENV, str(tmp_path / "state"))
22992299
workspace = tmp_path / "workspace"
23002300
workspace.mkdir()
2301-
fake_cli = _write_fake_aliyun(
2302-
tmp_path,
2301+
# Invoke the current interpreter as the fake CLI and let it execute the
2302+
# positional ``ros`` script from the worker cwd. This avoids depending on
2303+
# Windows batch-file launch behavior in a manager lifecycle test.
2304+
fake_cli = Path(sys.executable)
2305+
(workspace / "ros").write_text(
23032306
"import json, time\n"
23042307
+ "time.sleep(0.6)\n"
23052308
+ "event = {'result': {'statusUpdate': {'taskId': 'task-1', 'contextId': 'session-1', "
23062309
+ "'status': {'state': 'TASK_STATE_INPUT_REQUIRED', 'message': {'role': 'ROLE_AGENT', "
23072310
+ "'parts': [{'text': 'done'}]}}, 'metadata': {'iac_code': {'assistantFinal': "
23082311
+ "{'complete': True}}, 'iacCodeSessionId': 'iac-1'}}}}\n"
23092312
+ "print(json.dumps({'data': event}), flush=True)\n",
2313+
encoding="utf-8",
23102314
)
23112315

23122316
# Leave enough scheduling headroom for a loaded Windows xdist runner; this

0 commit comments

Comments
 (0)