mirror of
https://github.com/andrewyng/openworker.git
synced 2026-08-30 22:53:41 +00:00
Merge 988d4ce2e7 into 9e145d9ceb
This commit is contained in:
@@ -215,6 +215,13 @@ def _slack_frame():
|
||||
async def test_one_hub_fans_out_to_both_adapters(monkeypatch):
|
||||
"""THE step-3 invariant: slack + github share one relay socket; frames land
|
||||
on their own adapter by provider tag."""
|
||||
# Stub name resolution at its chokepoint. A dead port only refuses instantly on
|
||||
# POSIX; on Windows it takes ~2.0s per call and this frame makes two, blowing the
|
||||
# 2.0s wait_dispatched budget below. The env var stays as a no-network backstop.
|
||||
async def _no_slack_api(self, team_id, method, params):
|
||||
return None
|
||||
|
||||
monkeypatch.setattr(SlackRelayAdapter, "_slack_get", _no_slack_api)
|
||||
monkeypatch.setenv("SLACK_API_URL", "http://127.0.0.1:9/")
|
||||
hub = RelayHub(
|
||||
"wss://relay.test/ws",
|
||||
|
||||
@@ -20,9 +20,21 @@ from coworker.secrets import SecretStore
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def _no_slack_network(monkeypatch):
|
||||
"""Name/channel resolution is best-effort; unstubbed lookups must fail
|
||||
instantly at a dead loopback port, never reach slack.com — a slow real
|
||||
answer was blowing the 2s wait_dispatched window intermittently."""
|
||||
"""Name/channel resolution is best-effort, so stub it at its single chokepoint.
|
||||
|
||||
A dead loopback port alone is not enough. Refusing a connection is only instant
|
||||
on POSIX; on Windows it takes ~2.0s, and `_dispatch_slack_event` awaits both
|
||||
`_display_name` and `_channel_name`, so one frame cost ~4s against the 2.0s
|
||||
budget and no frame ever dispatched in time. `SLACK_API_URL` still points at a
|
||||
dead port as a backstop, so an unstubbed path can never reach slack.com.
|
||||
"""
|
||||
|
||||
async def _no_slack_api(self, team_id, method, params):
|
||||
return None
|
||||
|
||||
monkeypatch.setattr(
|
||||
relay_client.SlackRelayAdapter, "_slack_get", _no_slack_api
|
||||
)
|
||||
monkeypatch.setenv("SLACK_API_URL", "http://127.0.0.1:9/")
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user