mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-10-26 13:16:24 +00:00
test(backend): fix three more Windows-host test failures (#7008)
- test_local_dev_loopback_bind: the stale-render test compared Git Bash's MSYS path (/tmp/...) against a native path; route it through _normalize_rendered_path like its sibling tests. - test_project_documents_repo: TestShelfSnapshot relied on back-to-back inserts getting increasing updated_at, which ties on Windows' ~15.6 ms clock and falls through to the id tie-break. Pin updated_at explicitly. - test_multi_worker_run_ownership: the transient-renewal test compared two immediate lease timestamps with a strict >; start from a deadline inside the lease window, as test_scheduled_goal_handoff already does.
This commit is contained in:
parent
eae908c00d
commit
158c54508f
@ -246,7 +246,7 @@ def test_default_bind_host_removes_a_config_rendered_for_an_earlier_bind_host(ch
|
||||
result = _run(checkout, bind_host)
|
||||
|
||||
assert result.returncode == 0, result.stderr
|
||||
assert Path(result.stdout.strip()) == (checkout / "docker" / "nginx" / "nginx.local.conf").resolve()
|
||||
assert Path(_normalize_rendered_path(result.stdout.strip())) == (checkout / "docker" / "nginx" / "nginx.local.conf").resolve()
|
||||
assert not rendered.exists(), "a stale render with the old listen lines should not be left behind"
|
||||
|
||||
|
||||
|
||||
@ -972,6 +972,10 @@ async def test_transient_renewal_exception_before_deadline_keeps_run_alive():
|
||||
return await original_update_lease(*args, **kwargs)
|
||||
|
||||
store.update_lease = fail_once_then_renew
|
||||
# Keep the confirmed deadline inside the 30-second lease window. Renewal
|
||||
# computes a fresh now+lease value; Windows' coarse clock can otherwise make
|
||||
# two immediate samples identical and defeat the strict > below.
|
||||
record.lease_expires_at = (datetime.now(UTC) + timedelta(seconds=10)).isoformat()
|
||||
original_expiry = record.lease_expires_at
|
||||
|
||||
try:
|
||||
|
||||
@ -11,7 +11,7 @@ concurrent upload vs project delete, and concurrent duplicate upload.
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
from datetime import UTC, datetime
|
||||
from datetime import UTC, datetime, timedelta
|
||||
|
||||
import pytest
|
||||
|
||||
@ -137,6 +137,23 @@ class TestReadsFilterTrashed:
|
||||
assert total == 0
|
||||
|
||||
|
||||
async def _stamp_updated_at(docs: ProjectDocumentRepository, stamps: dict[str, datetime]) -> None:
|
||||
"""Pin ``updated_at`` so ordering tests do not depend on the wall clock.
|
||||
|
||||
Rows inserted back to back can share a timestamp on hosts with a coarse
|
||||
clock (Windows ticks at ~15.6 ms), which silently falls through to the
|
||||
``id`` tie-break.
|
||||
"""
|
||||
import sqlalchemy as sa
|
||||
|
||||
from deerflow.persistence.projects.model import ProjectDocumentRow
|
||||
|
||||
async with docs._sf() as session:
|
||||
for doc_id, updated_at in stamps.items():
|
||||
await session.execute(sa.update(ProjectDocumentRow).where(ProjectDocumentRow.id == doc_id).values(updated_at=updated_at))
|
||||
await session.commit()
|
||||
|
||||
|
||||
class TestShelfSnapshot:
|
||||
async def test_ordering_is_updated_desc_id_asc_with_one_round_trip_shape(self, repos):
|
||||
projects, docs = repos
|
||||
@ -146,13 +163,10 @@ class TestShelfSnapshot:
|
||||
rows.append(await _insert(docs, project["id"], sha=f"{i}" * 64, name=f"f{i}.txt", doc_id=f"d{i}"))
|
||||
# Re-touch d2 so it becomes the most recently updated row.
|
||||
await _insert(docs, project["id"], sha="e" * 64, name="f5.txt", doc_id="d5")
|
||||
import sqlalchemy as sa
|
||||
|
||||
from deerflow.persistence.projects.model import ProjectDocumentRow
|
||||
|
||||
async with docs._sf() as session:
|
||||
await session.execute(sa.update(ProjectDocumentRow).where(ProjectDocumentRow.id == "d2").values(updated_at=datetime(2999, 1, 1, tzinfo=UTC)))
|
||||
await session.commit()
|
||||
base = datetime(2026, 1, 1, tzinfo=UTC)
|
||||
stamps = {f"d{i}": base + timedelta(seconds=i) for i in range(6)}
|
||||
stamps["d2"] = datetime(2999, 1, 1, tzinfo=UTC)
|
||||
await _stamp_updated_at(docs, stamps)
|
||||
|
||||
snapshot_rows, total = await docs.shelf_snapshot(project["id"], limit=3, user_id="u1")
|
||||
assert total == 6
|
||||
@ -168,6 +182,8 @@ class TestShelfSnapshot:
|
||||
project = await _project(projects)
|
||||
for i in range(7):
|
||||
await _insert(docs, project["id"], sha=f"{i}" * 64, name=f"f{i}.txt", doc_id=f"d{i}")
|
||||
base = datetime(2026, 1, 1, tzinfo=UTC)
|
||||
await _stamp_updated_at(docs, {f"d{i}": base + timedelta(seconds=i) for i in range(7)})
|
||||
seen: list[str] = []
|
||||
offset = 0
|
||||
while True:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user