diff --git a/backend/tests/test_cluster.py b/backend/tests/test_cluster.py index 580e5377..dcaa42eb 100644 --- a/backend/tests/test_cluster.py +++ b/backend/tests/test_cluster.py @@ -356,7 +356,7 @@ async def test_registering_again_tidies_up_what_the_retired_identity_left(monkey from app.cluster import service as service_mod from app.cluster.fence import now as fence_now - monkeypatch.setattr(identity, "OWNER", identity.OWNER) + monkeypatch.setattr(identity, "OWNER", f"{identity.host()}:{os.getpid()}:retired0") # 测试完换回原来的身份 old = identity.owner() now = utcnow() async with SessionLocal() as session: diff --git a/backend/tests/test_cluster_fence.py b/backend/tests/test_cluster_fence.py index 5d3908bb..906db81e 100644 --- a/backend/tests/test_cluster_fence.py +++ b/backend/tests/test_cluster_fence.py @@ -5,6 +5,7 @@ from __future__ import annotations import asyncio import contextlib +import os import pytest from sqlalchemy import func, select @@ -237,7 +238,7 @@ async def test_the_lease_task_keeps_going_when_registering_again_fails(monkeypat from app.cluster import identity, service as service_mod, workers from app.cluster.version import VersionMismatch - monkeypatch.setattr(identity, "OWNER", identity.OWNER) # 测试完换回原来的身份 + monkeypatch.setattr(identity, "OWNER", f"{identity.host()}:{os.getpid()}:retired1") # 测试完换回原来的身份 monkeypatch.setattr(workers, "heartbeat_s", lambda: 0.01) monkeypatch.setattr(workers, "lease_s", lambda: 5.0) svc = service_mod._Service()