fix(harness): un-xfail peer-discovery-404 replay (Fixes #2865) #2870
@@ -1,25 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
# XFAIL — issue #2865
|
||||
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
# This replay is currently marked xfail (expected to fail). The underlying
|
||||
# issue is tracked at https://git.moleculesai.app/molecule-ai/molecule-core/issues/2865
|
||||
# Reason: pre-existing peer-discovery wire failure (not in #2821 scope)
|
||||
# Peer-discovery 404 replay (issue #2865).
|
||||
#
|
||||
# To un-xfail (when the underlying issue is fixed):
|
||||
# 1. Remove the `exit 0` line below
|
||||
# 2. Update the issue #2865 with a "fixed" comment + link to the fix PR
|
||||
# 3. Verify the replay runs end-to-end with PASS in the local harness
|
||||
# 4. The Harness Replays workflow will then surface the real pass signal
|
||||
#
|
||||
# Why we xfail (not skip, not fix): the underlying issues are out of scope
|
||||
# for PR #2821 (which captures the canary failures) but block the green CI
|
||||
# signal that the 2-genuine review needs. Tracking the work in the linked
|
||||
# issue lets us burn down the xfails as separate PRs land.
|
||||
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
||||
echo "[replay] __XFAIL__:#2865:pre-existing peer-discovery wire failure (not in #2821 scope)"
|
||||
exit 0
|
||||
|
||||
# Validates that an unregistered workspace returns HTTP 404 from the platform
|
||||
# /registry/{id}/peers endpoint. The parse/diagnostic-helper branch that used to
|
||||
# live here has moved to the workspace-runtime test suite
|
||||
# (molecule_runtime/a2a_client.py and its unit tests), where the helper actually
|
||||
# lives; this replay now covers the wire behavior only.
|
||||
set -euo pipefail
|
||||
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
HARNESS_ROOT="$(dirname "$HERE")"
|
||||
@@ -34,102 +20,21 @@ source .seed.env
|
||||
# shellcheck source=../_curl.sh
|
||||
source "$HARNESS_ROOT/_curl.sh"
|
||||
|
||||
# ─── (a) WIRE: tenant returns 404 for an unregistered workspace ────────
|
||||
# WIRE: tenant returns 404 for an unregistered workspace.
|
||||
ROGUE_ID="$(uuidgen | tr '[:upper:]' '[:lower:]')"
|
||||
echo "[replay] (a) WIRE: querying /registry/$ROGUE_ID/peers (unregistered workspace)..."
|
||||
echo "[replay] WIRE: querying /registry/$ROGUE_ID/peers (unregistered workspace)..."
|
||||
HTTP_CODE=$(curl_admin -o /tmp/peer-replay.json -w '%{http_code}' \
|
||||
-H "X-Workspace-ID: $ROGUE_ID" \
|
||||
"$BASE/registry/$ROGUE_ID/peers")
|
||||
|
||||
echo "[replay] tenant responded HTTP $HTTP_CODE"
|
||||
if [ "$HTTP_CODE" != "404" ]; then
|
||||
echo "[replay] FAIL (a): expected 404 from /registry/<unregistered>/peers, got $HTTP_CODE"
|
||||
echo "[replay] FAIL: expected 404 from /registry/<unregistered>/peers, got $HTTP_CODE"
|
||||
echo "[replay] This is a platform-side regression — the runtime's diagnostic helper"
|
||||
echo "[replay] would see a different status code than the unit tests cover."
|
||||
cat /tmp/peer-replay.json
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# ─── (b) PARSE: helper converts a synthetic 404 to actionable diagnostic ─
|
||||
#
|
||||
# We construct a synthetic httpx 404 response and run the helper against
|
||||
# it directly. This isolates the parse branch we want to test from the
|
||||
# auth-context concerns of going through the network. The helper's network
|
||||
# branches are exhaustively covered by tests/test_a2a_client.py — this is
|
||||
# a regression-guard that the helper IS in the install, IS importable in
|
||||
# the harness's Python env, and IS reading the status code.
|
||||
|
||||
WORKSPACE_PATH="$(cd "$HARNESS_ROOT/../../workspace" && pwd)"
|
||||
DIAGNOSTIC=$(WORKSPACE_ID="harness-rogue" PYTHONPATH="$WORKSPACE_PATH" \
|
||||
python3 - "$WORKSPACE_PATH" <<'PYEOF'
|
||||
import asyncio
|
||||
import sys
|
||||
import types
|
||||
from unittest.mock import AsyncMock, MagicMock, patch
|
||||
|
||||
# Stub platform_auth so a2a_client imports cleanly without requiring a
|
||||
# real workspace token file. The helper's auth_headers() only matters
|
||||
# when going through the network; we're feeding it a mock response.
|
||||
#
|
||||
# Both stubs accept *args, **kwargs because the multi-workspace work
|
||||
# (#2739, #2743) added optional ``workspace_id`` parameters to
|
||||
# ``auth_headers`` and made ``self_source_headers`` 1-arg-required.
|
||||
# The stubs need to accept whatever the helpers pass without caring.
|
||||
_pa = types.ModuleType("platform_auth")
|
||||
_pa.auth_headers = lambda *a, **kw: {}
|
||||
_pa.self_source_headers = lambda *a, **kw: {}
|
||||
sys.modules.setdefault("platform_auth", _pa)
|
||||
|
||||
sys.path.insert(0, sys.argv[1])
|
||||
import a2a_client # noqa: E402
|
||||
|
||||
# This replay validates PR #2399's diagnostic helper. If the workspace
|
||||
# runtime in the current checkout pre-dates that fix, fail with a
|
||||
# clear message instead of an opaque AttributeError.
|
||||
if not hasattr(a2a_client, "get_peers_with_diagnostic"):
|
||||
print("__SKIP__: workspace/a2a_client.py is pre-#2399 (no get_peers_with_diagnostic).")
|
||||
sys.exit(0)
|
||||
|
||||
resp = MagicMock()
|
||||
resp.status_code = 404
|
||||
resp.json = MagicMock(return_value={"detail": "not found"})
|
||||
|
||||
mock_client = AsyncMock()
|
||||
mock_client.__aenter__ = AsyncMock(return_value=mock_client)
|
||||
mock_client.__aexit__ = AsyncMock(return_value=False)
|
||||
mock_client.get = AsyncMock(return_value=resp)
|
||||
|
||||
async def main():
|
||||
with patch("a2a_client.httpx.AsyncClient", return_value=mock_client):
|
||||
peers, diag = await a2a_client.get_peers_with_diagnostic()
|
||||
print(repr(diag))
|
||||
|
||||
asyncio.run(main())
|
||||
PYEOF
|
||||
)
|
||||
|
||||
if [[ "$DIAGNOSTIC" == __SKIP__:* ]]; then
|
||||
echo "[replay] (b) SKIP: ${DIAGNOSTIC#__SKIP__: }"
|
||||
echo "[replay] Re-run after #2399 lands on staging."
|
||||
echo ""
|
||||
echo "[replay] PASS (a) only: peer-discovery wire returns 404 (parse branch skipped — see above)."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "[replay] (b) PARSE: helper diagnostic = $DIAGNOSTIC"
|
||||
|
||||
if ! echo "$DIAGNOSTIC" | grep -q "404"; then
|
||||
echo "[replay] FAIL (b): diagnostic missing '404' — helper regressed to swallow-the-status-code"
|
||||
exit 1
|
||||
fi
|
||||
if ! echo "$DIAGNOSTIC" | grep -qi "regist"; then
|
||||
echo "[replay] FAIL (b): diagnostic missing 'register' guidance — helper regressed to opaque message"
|
||||
exit 1
|
||||
fi
|
||||
if echo "$DIAGNOSTIC" | grep -qi "may be isolated"; then
|
||||
echo "[replay] FAIL (b): diagnostic still says 'may be isolated' — fix didn't reach this code path"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "[replay] PASS: peer-discovery (a) wire returns 404, (b) helper produces actionable diagnostic."
|
||||
echo "[replay] PASS: peer-discovery wire returns 404 for an unregistered workspace."
|
||||
|
||||
Reference in New Issue
Block a user