Merge pull request 'fix(workspace): fix test_blocks_until_inflight_completes httpx mock thread issue' (#525) from fix/test-blocks-until-inflight-completes into main
Some checks failed
Block internal-flavored paths / Block forbidden paths (push) Successful in 9s
CI / Detect changes (push) Successful in 21s
Secret scan / Scan diff for credential-shaped strings (push) Successful in 11s
E2E API Smoke Test / detect-changes (push) Successful in 26s
E2E Staging Canvas (Playwright) / detect-changes (push) Successful in 30s
CI / Platform (Go) (push) Successful in 9s
Handlers Postgres Integration / detect-changes (push) Successful in 32s
CI / Canvas (Next.js) (push) Successful in 8s
CI / Shellcheck (E2E scripts) (push) Successful in 6s
CI / Canvas Deploy Reminder (push) Has been skipped
Runtime PR-Built Compatibility / detect-changes (push) Successful in 31s
E2E API Smoke Test / E2E API Smoke Test (push) Successful in 6s
E2E Staging Canvas (Playwright) / Canvas tabs E2E (push) Successful in 7s
Handlers Postgres Integration / Handlers Postgres Integration (push) Successful in 5s
publish-runtime-autobump / autobump-and-tag (push) Failing after 50s
Sweep stale AWS Secrets Manager secrets / Sweep AWS Secrets Manager (push) Failing after 7s
Runtime PR-Built Compatibility / PR-built wheel + import smoke (push) Successful in 1m50s
Staging SaaS smoke (every 30 min) / Staging SaaS smoke (push) Failing after 4m38s
CI / Python Lint & Test (push) Successful in 6m45s
Sweep stale e2e-* orgs (staging) / Sweep e2e orgs (push) Successful in 9s
Sweep stale Cloudflare Tunnels / Sweep CF tunnels (push) Failing after 12s
Continuous synthetic E2E (staging) / Synthetic E2E against staging (push) Failing after 4m54s
Some checks failed
Block internal-flavored paths / Block forbidden paths (push) Successful in 9s
CI / Detect changes (push) Successful in 21s
Secret scan / Scan diff for credential-shaped strings (push) Successful in 11s
E2E API Smoke Test / detect-changes (push) Successful in 26s
E2E Staging Canvas (Playwright) / detect-changes (push) Successful in 30s
CI / Platform (Go) (push) Successful in 9s
Handlers Postgres Integration / detect-changes (push) Successful in 32s
CI / Canvas (Next.js) (push) Successful in 8s
CI / Shellcheck (E2E scripts) (push) Successful in 6s
CI / Canvas Deploy Reminder (push) Has been skipped
Runtime PR-Built Compatibility / detect-changes (push) Successful in 31s
E2E API Smoke Test / E2E API Smoke Test (push) Successful in 6s
E2E Staging Canvas (Playwright) / Canvas tabs E2E (push) Successful in 7s
Handlers Postgres Integration / Handlers Postgres Integration (push) Successful in 5s
publish-runtime-autobump / autobump-and-tag (push) Failing after 50s
Sweep stale AWS Secrets Manager secrets / Sweep AWS Secrets Manager (push) Failing after 7s
Runtime PR-Built Compatibility / PR-built wheel + import smoke (push) Successful in 1m50s
Staging SaaS smoke (every 30 min) / Staging SaaS smoke (push) Failing after 4m38s
CI / Python Lint & Test (push) Successful in 6m45s
Sweep stale e2e-* orgs (staging) / Sweep e2e orgs (push) Successful in 9s
Sweep stale Cloudflare Tunnels / Sweep CF tunnels (push) Failing after 12s
Continuous synthetic E2E (staging) / Synthetic E2E against staging (push) Failing after 4m54s
This commit is contained in:
commit
eb612b8612
@ -1460,26 +1460,33 @@ class TestWaitForEnrichmentInFlight:
|
||||
def test_blocks_until_inflight_completes(self):
|
||||
"""In-flight entry cleared while waiting → returns."""
|
||||
import a2a_client
|
||||
import time as _time
|
||||
|
||||
a2a_client._peer_in_flight_clear_for_testing()
|
||||
a2a_client._peer_metadata.clear()
|
||||
|
||||
peer_data = {"id": _TEST_PEER_ID, "name": "Blocker Peer"}
|
||||
resp = _make_sync_response(200, peer_data)
|
||||
mock_client = _make_sync_mock_client(get_resp=resp)
|
||||
|
||||
with patch("a2a_client.httpx.Client", return_value=mock_client):
|
||||
# Schedule the nonblocking call — it will be in-flight.
|
||||
a2a_client.enrich_peer_metadata_nonblocking(_TEST_PEER_ID)
|
||||
# Replace enrich_peer_metadata with one that bypasses httpx entirely.
|
||||
# The httpx patch approach fails because the background worker runs
|
||||
# after the patch context exits (thread-boundary issue: the executor
|
||||
# thread is created before the patch, so it uses the original httpx).
|
||||
# Replacing the function itself works across thread boundaries.
|
||||
fake_enrich = lambda pid, src=None, *, now=None: (
|
||||
a2a_client._peer_metadata_set(pid, (now or _time.monotonic(), peer_data)),
|
||||
a2a_client._peer_names.__setitem__(pid, peer_data["name"])
|
||||
)
|
||||
|
||||
orig = a2a_client.enrich_peer_metadata
|
||||
a2a_client.enrich_peer_metadata = fake_enrich
|
||||
try:
|
||||
# Wait should block until the worker finishes.
|
||||
a2a_client.enrich_peer_metadata_nonblocking(_TEST_PEER_ID)
|
||||
a2a_client._wait_for_enrichment_inflight_for_testing(timeout=5.0)
|
||||
# Cache should now be warm.
|
||||
cached = a2a_client._peer_metadata_get(_TEST_PEER_ID)
|
||||
assert cached is not None
|
||||
assert cached[1] == peer_data
|
||||
finally:
|
||||
a2a_client.enrich_peer_metadata = orig
|
||||
a2a_client._peer_metadata.clear()
|
||||
a2a_client._peer_names.clear()
|
||||
a2a_client._peer_in_flight_clear_for_testing()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user