@@ -90,6 +90,42 @@ wait_for_health() {
9090 fail " $label did not become healthy after $(( max * 2 )) s"
9191}
9292
93+ wait_for_postgres () {
94+ local max=" $1 " label=" ${2:- PostgreSQL} "
95+ for i in $( seq 1 " $max " ) ; do
96+ if compose exec -T postgres pg_isready -U ccg -d ccg_integration > /dev/null 2>&1 ; then
97+ info " $label is healthy"
98+ return 0
99+ fi
100+ echo -n " ."
101+ sleep 2
102+ done
103+ fail " $label did not become healthy after $(( max * 2 )) s"
104+ }
105+
106+ start_integration_stack () {
107+ info " Starting base services..."
108+ compose up -d postgres gitea
109+
110+ info " Building ccg image..."
111+ compose build ccg
112+
113+ info " Waiting for PostgreSQL..."
114+ wait_for_postgres 30 " PostgreSQL"
115+
116+ info " Waiting for Gitea..."
117+ wait_for_health " $GITEA_URL /api/v1/version" 30 " Gitea"
118+
119+ info " Running ccg migrations..."
120+ compose run --rm --no-deps ccg migrate
121+
122+ info " Starting ccg..."
123+ compose up -d ccg
124+
125+ info " Waiting for ccg..."
126+ wait_for_health " $CCG_URL /ready" 30 " ccg"
127+ }
128+
93129api () {
94130 local method=" $1 " path=" $2 " ; shift 2
95131 curl -fsS -X " $method " " ${GITEA_URL}${path} " \
@@ -147,7 +183,7 @@ if not isinstance(r, dict):
147183 print("response is not a JSON object", file=sys.stderr)
148184 sys.exit(2)
149185if r.get("error") is not None:
150- print(f "JSON-RPC error: { r.get(' error' )}" , file=sys.stderr)
186+ print("JSON-RPC error:", r.get(" error") , file=sys.stderr)
151187 sys.exit(3)
152188result = r.get("result")
153189if not isinstance(result, dict):
@@ -225,6 +261,10 @@ mcp_session_required() {
225261 [ -n " $session " ] || [ " ${CCG_E2E_ALLOW_MCP_LOG_FALLBACK:- 0} " = " 1" ]
226262}
227263
264+ mcp_log_fallback_allowed () {
265+ [ " ${CCG_E2E_ALLOW_MCP_LOG_FALLBACK:- 0} " = " 1" ]
266+ }
267+
228268extract_last_webhook_node_count () {
229269 local logs=" $1 "
230270 printf ' %s' " $logs " | python3 -c '
@@ -267,7 +307,7 @@ wait_for_webhook_sync() {
267307 if webhook_logs_failed " $logs " " $workspace " ; then
268308 fail " ccg build failed for ${label} . See ${ARTIFACT_DIR} /ccg.log after cleanup. Recent logs:\n$( printf ' %s\n' " $logs " | tail -20) "
269309 fi
270- if webhook_logs_completed " $logs " " $workspace " ; then
310+ if mcp_log_fallback_allowed && webhook_logs_completed " $logs " " $workspace " ; then
271311 info " ${label} webhook sync observed via logs"
272312 return 0
273313 fi
@@ -279,14 +319,8 @@ wait_for_webhook_sync() {
279319run_integration_test () {
280320
281321# ── Phase 1: Start containers ──
282- info " Starting containers..."
283- compose up -d --build
284-
285- info " Waiting for Gitea..."
286- wait_for_health " $GITEA_URL /api/v1/version" 30 " Gitea"
287-
288- info " Waiting for ccg..."
289- wait_for_health " $CCG_URL /ready" 30 " ccg"
322+ info " Starting containers..."
323+ start_integration_stack
290324
291325# ── Phase 2: Create Gitea admin user ──
292326info " Creating Gitea admin user..."
398432 -H " Content-Type: application/json" \
399433 -H " Authorization: Bearer ${MCP_BEARER_TOKEN} " \
400434 -H " Mcp-Session-Id: ${MCP_SESSION} " \
401- -d ' { "jsonrpc": "2.0", "id":2,"method": "tools/call", "params":{"name": "list_graph_stats", "arguments":{}}} ' 2> /dev/null) || STATS_RESP=" "
435+ -d " { \ " jsonrpc\" : \ " 2.0\" , \ " id\ " :2,\ " method\" : \ " tools/call\" , \ " params\ " :{\ " name\" : \ " list_graph_stats\" , \ " arguments\ " :{\" workspace \" : \" ${REPO_NAME} \" }}} " 2> /dev/null) || STATS_RESP=" "
402436
403437 if [ -z " $STATS_RESP " ]; then
404438 fail " MCP tools/call returned empty response"
817851
818852# ── Summary ──
819853TOOLS_TESTED=0
854+ TOTAL_MCP_TOOLS=33
820855if [ -n " $MCP_SESSION " ]; then
821- TOOLS_TESTED=29
856+ TOOLS_TESTED=27
822857fi
823858
824859echo " "
825860echo -e " ${GREEN} ════════════════════════════════════════════════════════${NC} "
826861if [ -n " $MCP_SESSION " ]; then
827- echo -e " ${GREEN} Integration test PASSED — ${TOOLS_TESTED} /29 MCP tools verified${NC} "
862+ echo -e " ${GREEN} Integration test PASSED — ${TOOLS_TESTED} /${TOTAL_MCP_TOOLS} MCP tools verified${NC} "
828863else
829- echo -e " ${YELLOW} Integration webhook smoke completed — 0/29 MCP tools verified (local debug override)${NC} "
864+ echo -e " ${YELLOW} Integration webhook smoke completed — 0/${TOTAL_MCP_TOOLS} MCP tools verified (local debug override)${NC} "
830865fi
831866echo -e " ${GREEN} ════════════════════════════════════════════════════════${NC} "
832867echo " "
0 commit comments