Skip to content

Commit 45480fa

Browse files
committed
Fix e2e: wait for CONFIG_WIZARD before capturing OctoPrint artifacts
The test and screenshot hook both matched "OctoPrint" in the starting page title instead of waiting for the actual wizard. Now both poll specifically for CONFIG_WIZARD in the response. The test saves HTML from the matching response (not a second curl). Add chromium to the Docker container for headless screenshots. Increase poll timeout to 600s for slower CI runners.
1 parent 8ea7d14 commit 45480fa

3 files changed

Lines changed: 36 additions & 24 deletions

File tree

testing/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ FROM ptrsr/pi-ci:latest
33
ENV LIBGUESTFS_BACKEND=direct
44

55
RUN apt-get update && apt-get install -y --no-install-recommends \
6-
sshpass openssh-client curl socat imagemagick \
6+
sshpass openssh-client curl socat imagemagick chromium \
77
&& rm -rf /var/lib/apt/lists/*
88

99
# Shared framework from CustomPiOS (copied into build context by CI)

testing/hooks/screenshot.sh

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,35 @@ ARTIFACTS_DIR="${3:-/output}"
66

77
SSH_CMD="sshpass -p raspberry ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o PreferredAuthentications=password -o PubkeyAuthentication=no -o LogLevel=ERROR -p $SSH_PORT ${SSH_HOST}"
88

9-
echo "Capturing OctoPrint web UI artifacts..."
9+
echo "Waiting for OctoPrint wizard page before capturing..."
1010

11-
# Save rendered HTML via curl through SSH (inside the guest, hitting localhost:80)
12-
BODY=$(${SSH_CMD} -l pi "curl -s http://localhost" 2>/dev/null || echo "")
11+
WIZARD_READY=0
12+
for i in $(seq 1 24); do
13+
BODY=$(${SSH_CMD} -l pi "curl -s http://localhost" 2>/dev/null || echo "")
14+
if echo "$BODY" | grep -q "CONFIG_WIZARD"; then
15+
WIZARD_READY=1
16+
echo "$BODY" > "$ARTIFACTS_DIR/octoprint-ui.html"
17+
echo " Saved OctoPrint wizard HTML to artifacts (after ${i}x5s)"
18+
break
19+
fi
20+
printf "."
21+
sleep 5
22+
done
23+
echo ""
1324

14-
if [ -n "$BODY" ]; then
15-
echo "$BODY" > "$ARTIFACTS_DIR/octoprint-ui.html"
16-
echo " Saved OctoPrint HTML to artifacts"
25+
if [ "$WIZARD_READY" -eq 0 ]; then
26+
echo " WARNING: CONFIG_WIZARD not found after 120s, saving current page"
27+
if [ -n "$BODY" ]; then
28+
echo "$BODY" > "$ARTIFACTS_DIR/octoprint-ui.html"
29+
fi
1730
fi
1831

19-
# Attempt headless screenshot from inside the container if a browser is available
2032
HTTP_PORT="${QEMU_HTTP_PORT:-8080}"
2133
for BROWSER in chromium chromium-browser google-chrome; do
2234
if command -v "$BROWSER" &>/dev/null; then
2335
echo " Using $BROWSER for headless screenshot..."
2436
"$BROWSER" --headless --disable-gpu --no-sandbox \
25-
--virtual-time-budget=10000 \
37+
--virtual-time-budget=15000 \
2638
--screenshot="$ARTIFACTS_DIR/screenshot.png" \
2739
--window-size=1280,720 \
2840
"http://localhost:${HTTP_PORT}" 2>/dev/null || true

testing/tests/test_octoprint_web.sh

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,21 @@ PASS="raspberry"
99

1010
SSH_CMD="sshpass -p $PASS ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o PreferredAuthentications=password -o PubkeyAuthentication=no -o LogLevel=ERROR -p $PORT ${USER}@${HOST}"
1111

12-
echo "Test: OctoPrint web server is accessible and fully started"
12+
echo "Test: OctoPrint web server is accessible with CONFIG_WIZARD"
1313

1414
OCTOPRINT_READY=0
15-
for i in $(seq 1 60); do
15+
for i in $(seq 1 120); do
1616
BODY=$($SSH_CMD "curl -s http://localhost" 2>/dev/null || echo "")
1717
HTTP_CODE=$($SSH_CMD "curl -s -o /dev/null -w '%{http_code}' http://localhost" 2>/dev/null || echo "000")
1818

1919
if [ "$HTTP_CODE" = "200" ]; then
20-
if echo "$BODY" | grep -q "starting up"; then
21-
printf "S"
22-
elif echo "$BODY" | grep -q "CONFIG_WIZARD\|OctoPrint"; then
20+
if echo "$BODY" | grep -q "CONFIG_WIZARD"; then
2321
OCTOPRINT_READY=1
2422
break
23+
elif echo "$BODY" | grep -q "starting up\|still starting"; then
24+
printf "S"
2525
else
26-
printf "W"
26+
printf "?"
2727
fi
2828
else
2929
printf "."
@@ -33,23 +33,23 @@ done
3333
echo ""
3434

3535
if [ "$OCTOPRINT_READY" -eq 0 ]; then
36-
echo " FAIL: OctoPrint did not fully start within 300s"
36+
echo " FAIL: OctoPrint CONFIG_WIZARD did not appear within 600s"
37+
echo " Last HTTP code: $HTTP_CODE"
38+
echo " Last body (first 200 chars): $(echo "$BODY" | head -c 200)"
3739
exit 1
3840
fi
3941

40-
echo " OctoPrint web server is fully started (HTTP 200, UI loaded)"
41-
42-
FULL_HTML=$($SSH_CMD "curl -s http://localhost" 2>/dev/null)
42+
echo " OctoPrint CONFIG_WIZARD is loaded (HTTP 200)"
4343

4444
if [ -n "$ARTIFACTS_DIR" ]; then
45-
echo "$FULL_HTML" > "$ARTIFACTS_DIR/octoprint.html"
46-
echo " Saved HTML to $ARTIFACTS_DIR/octoprint.html"
45+
echo "$BODY" > "$ARTIFACTS_DIR/octoprint.html"
46+
echo " Saved wizard HTML to $ARTIFACTS_DIR/octoprint.html"
4747
fi
4848

49-
if echo "$FULL_HTML" | grep -q "OctoPrint"; then
50-
echo " PASS: OctoPrint web UI returned expected content"
49+
if echo "$BODY" | grep -q "OctoPrint"; then
50+
echo " PASS: OctoPrint wizard page returned expected content"
5151
exit 0
5252
else
53-
echo " FAIL: Response did not contain 'OctoPrint'"
53+
echo " FAIL: Wizard page did not contain 'OctoPrint'"
5454
exit 1
5555
fi

0 commit comments

Comments
 (0)