fix(up): hard timeout and progress for follower capture
This commit is contained in:
1 parent
98cf42a113
commit
e903c49921
5 files changed
+88
-3
No files matched your search
@@ -82,6 +82,41 @@ def test_capture_dedupes_and_continues_after_failure():
|
||||
db.close()
|
||||
|
||||
|
||||
class BlockingClient:
|
||||
"""模拟 DNS/传输层挂起:请求永不返回。"""
|
||||
|
||||
def __init__(self, *, block=()):
|
||||
self.calls = []
|
||||
self.block = set(block)
|
||||
|
||||
def relation_stat(self, mid):
|
||||
self.calls.append(int(mid))
|
||||
if int(mid) in self.block:
|
||||
time.sleep(5)
|
||||
raise AssertionError("不应返回")
|
||||
return SimpleNamespace(mid=int(mid), follower=1000 + int(mid), following=5)
|
||||
|
||||
|
||||
def test_capture_times_out_and_continues():
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
db, repo = setup(tmp)
|
||||
try:
|
||||
client = BlockingClient(block={100})
|
||||
service = UpProfileService(
|
||||
repo, lambda: client, clock=lambda: NOW,
|
||||
request_timeout=0.05, heartbeat=1,
|
||||
)
|
||||
result = service.capture([100, 200])
|
||||
assert result.requested == 2
|
||||
assert result.failed == 1
|
||||
assert "timeout" in result.errors[0]
|
||||
# 卡住的 UP 不影响后续
|
||||
assert repo.get_video(3)["up_follower"] == 1200
|
||||
assert repo.get_video(1)["up_follower"] is None
|
||||
finally:
|
||||
db.close()
|
||||
|
||||
|
||||
def test_capture_marks_old_videos_as_backfilled():
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
db, repo = setup(tmp)
|
||||
|
||||
Reference in new issue
Block a user