Skip to content

Commit 1932562

Browse files
afrindclaude
andcommitted
Add bash integration test for admin /info endpoint
Launches o_rly, polls until the admin server is ready, curls /info, and validates the JSON response fields. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent b39ada1 commit 1932562

2 files changed

Lines changed: 50 additions & 0 deletions

File tree

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ if(ORLY_BUILD_TESTS)
7979
)
8080
include(GoogleTest)
8181
gtest_discover_tests(o_rly_relay_test)
82+
83+
add_test(
84+
NAME admin_info_endpoint
85+
COMMAND bash ${PROJECT_SOURCE_DIR}/tests/test_admin_info.sh $<TARGET_FILE:o_rly>
86+
)
8287
endif()
8388

8489
include(${PROJECT_SOURCE_DIR}/cmake/Lint.cmake)

tests/test_admin_info.sh

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
BINARY="${1:-$(dirname "$0")/../build/o_rly}"
5+
ADMIN_PORT=9669
6+
ADMIN_URL="http://localhost:${ADMIN_PORT}/info"
7+
8+
if [[ ! -x "$BINARY" ]]; then
9+
echo "ERROR: binary not found or not executable: $BINARY" >&2
10+
exit 1
11+
fi
12+
13+
# Start o_rly in insecure mode (no TLS needed for this test) in the background.
14+
"$BINARY" --insecure --admin_port="$ADMIN_PORT" &
15+
O_RLY_PID=$!
16+
trap 'kill "$O_RLY_PID" 2>/dev/null; wait "$O_RLY_PID" 2>/dev/null || true' EXIT
17+
18+
# Wait for the admin server to become ready (up to 5 s).
19+
for i in $(seq 1 50); do
20+
if curl -sf "$ADMIN_URL" >/dev/null 2>&1; then
21+
break
22+
fi
23+
sleep 0.1
24+
if [[ $i -eq 50 ]]; then
25+
echo "ERROR: admin server did not become ready in time" >&2
26+
exit 1
27+
fi
28+
done
29+
30+
# Fetch the /info response.
31+
RESPONSE=$(curl -sf "$ADMIN_URL")
32+
echo "Response: $RESPONSE"
33+
34+
# Validate expected fields.
35+
if ! echo "$RESPONSE" | grep -q '"service":"o-rly"'; then
36+
echo "FAIL: missing \"service\":\"o-rly\" in response" >&2
37+
exit 1
38+
fi
39+
40+
if ! echo "$RESPONSE" | grep -q '"version":'; then
41+
echo "FAIL: missing \"version\" field in response" >&2
42+
exit 1
43+
fi
44+
45+
echo "PASS"

0 commit comments

Comments
 (0)