Skip to content

Commit d2e026f

Browse files
committed
Refactor e2e tests to use shared CustomPiOS distro_testing framework
Replace standalone testing scripts with the shared framework from CustomPiOS/src/distro_testing/. The CI workflow now checks out CustomPiOS and copies the shared scripts into the build context. OctoPi-specific logic moves into hooks/ (haproxy IPv4 patching, headless browser screenshot). Removes run-test.sh and testing/scripts/ (now provided by the framework).
1 parent caf03f9 commit d2e026f

11 files changed

Lines changed: 93 additions & 387 deletions

File tree

.github/workflows/build.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,24 @@ jobs:
7676
steps:
7777
- uses: actions/checkout@v4
7878

79+
- name: Checkout CustomPiOS
80+
uses: actions/checkout@v4
81+
with:
82+
repository: 'guysoft/CustomPiOS'
83+
path: CustomPiOS
84+
7985
- name: Download arm64 image from build
8086
uses: actions/download-artifact@v4
8187
with:
8288
name: octopi-arm64
8389
path: image/
8490

91+
- name: Prepare testing context
92+
run: |
93+
mkdir -p testing/custompios
94+
cp -r CustomPiOS/src/distro_testing/scripts testing/custompios/scripts
95+
cp -r CustomPiOS/src/distro_testing/tests testing/custompios/tests
96+
8597
- name: Build test Docker image
8698
run: DOCKER_BUILDKIT=0 docker build -t octopi-e2e-test ./testing/
8799

@@ -94,6 +106,7 @@ jobs:
94106
-v "$PWD/artifacts:/output" \
95107
-v "$(realpath $IMG):/input/image.img:ro" \
96108
-e ARTIFACTS_DIR=/output \
109+
-e DISTRO_NAME="OctoPi" \
97110
-e KEEP_ALIVE=true \
98111
octopi-e2e-test
99112

testing/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
images/
2+
custompios/
3+
*.png

testing/Dockerfile

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,19 @@ FROM ptrsr/pi-ci:latest
22

33
ENV LIBGUESTFS_BACKEND=direct
44

5-
RUN apt-get update && apt-get install -y --no-install-recommends sshpass openssh-client curl && rm -rf /var/lib/apt/lists/*
5+
RUN apt-get update && apt-get install -y --no-install-recommends \
6+
sshpass openssh-client curl socat imagemagick \
7+
&& rm -rf /var/lib/apt/lists/*
68

7-
COPY scripts/ /test/scripts/
9+
# Shared framework from CustomPiOS (copied into build context by CI)
10+
COPY custompios/scripts/ /test/scripts/
11+
COPY custompios/tests/ /test/tests/
12+
13+
# OctoPi-specific tests and hooks
814
COPY tests/ /test/tests/
9-
RUN chmod +x /test/scripts/*.sh /test/tests/*.sh
15+
COPY hooks/ /test/hooks/
16+
17+
RUN chmod +x /test/scripts/*.sh /test/tests/*.sh; \
18+
chmod +x /test/hooks/*.sh 2>/dev/null || true
1019

1120
ENTRYPOINT ["/test/scripts/entrypoint.sh"]

testing/hooks/prepare-image.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
set -e
3+
IMAGE_FILE="${1:?Usage: $0 <image.qcow2>}"
4+
5+
export LIBGUESTFS_BACKEND=direct
6+
export LIBGUESTFS_DEBUG=0
7+
export LIBGUESTFS_TRACE=0
8+
9+
echo '=== OctoPi-specific image patches ==='
10+
11+
echo 'Downloading haproxy config for IPv4 patching...'
12+
guestfish -a "$IMAGE_FILE" <<GFEOF
13+
run
14+
mount /dev/sda2 /
15+
download /etc/haproxy/haproxy.cfg /tmp/haproxy.cfg
16+
umount /
17+
GFEOF
18+
19+
echo 'Fixing haproxy for IPv4-only (QEMU has no IPv6)...'
20+
sed -i 's/bind :::80 v4v6/bind *:80/' /tmp/haproxy.cfg
21+
sed -i 's/bind :::443 v4v6/bind *:443/' /tmp/haproxy.cfg
22+
23+
guestfish -a "$IMAGE_FILE" <<GFEOF2
24+
run
25+
mount /dev/sda2 /
26+
upload /tmp/haproxy.cfg /etc/haproxy/haproxy.cfg
27+
umount /
28+
GFEOF2
29+
30+
echo 'OctoPi patches applied'

testing/hooks/screenshot.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
set -e
3+
SSH_HOST="${1:-localhost}"
4+
SSH_PORT="${2:-2222}"
5+
ARTIFACTS_DIR="${3:-/output}"
6+
7+
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}"
8+
9+
echo "Capturing OctoPrint web UI artifacts..."
10+
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 "")
13+
14+
if [ -n "$BODY" ]; then
15+
echo "$BODY" > "$ARTIFACTS_DIR/octoprint-ui.html"
16+
echo " Saved OctoPrint HTML to artifacts"
17+
fi
18+
19+
# Attempt headless screenshot from inside the container if a browser is available
20+
HTTP_PORT="${QEMU_HTTP_PORT:-8080}"
21+
for BROWSER in chromium chromium-browser google-chrome; do
22+
if command -v "$BROWSER" &>/dev/null; then
23+
echo " Using $BROWSER for headless screenshot..."
24+
"$BROWSER" --headless --disable-gpu --no-sandbox \
25+
--virtual-time-budget=10000 \
26+
--screenshot="$ARTIFACTS_DIR/screenshot.png" \
27+
--window-size=1280,720 \
28+
"http://localhost:${HTTP_PORT}" 2>/dev/null || true
29+
if [ -f "$ARTIFACTS_DIR/screenshot.png" ]; then
30+
echo " Browser screenshot saved"
31+
exit 0
32+
fi
33+
fi
34+
done
35+
36+
echo " No headless browser available in container (HTML artifact saved instead)"

testing/run-test.sh

Lines changed: 0 additions & 82 deletions
This file was deleted.

testing/scripts/boot-qemu.sh

Lines changed: 0 additions & 29 deletions
This file was deleted.

testing/scripts/entrypoint.sh

Lines changed: 0 additions & 112 deletions
This file was deleted.

0 commit comments

Comments
 (0)