Skip to content

Commit b547ccf

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 b547ccf

11 files changed

Lines changed: 95 additions & 387 deletions

File tree

.github/workflows/build.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ jobs:
2828
uses: actions/checkout@v4
2929
with:
3030
repository: 'guysoft/CustomPiOS'
31+
ref: feature/e2e
3132
path: CustomPiOS
3233

3334
- name: Checkout Project Repository
@@ -76,12 +77,25 @@ jobs:
7677
steps:
7778
- uses: actions/checkout@v4
7879

80+
- name: Checkout CustomPiOS
81+
uses: actions/checkout@v4
82+
with:
83+
repository: 'guysoft/CustomPiOS'
84+
ref: feature/e2e
85+
path: CustomPiOS
86+
7987
- name: Download arm64 image from build
8088
uses: actions/download-artifact@v4
8189
with:
8290
name: octopi-arm64
8391
path: image/
8492

93+
- name: Prepare testing context
94+
run: |
95+
mkdir -p testing/custompios
96+
cp -r CustomPiOS/src/distro_testing/scripts testing/custompios/scripts
97+
cp -r CustomPiOS/src/distro_testing/tests testing/custompios/tests
98+
8599
- name: Build test Docker image
86100
run: DOCKER_BUILDKIT=0 docker build -t octopi-e2e-test ./testing/
87101

@@ -94,6 +108,7 @@ jobs:
94108
-v "$PWD/artifacts:/output" \
95109
-v "$(realpath $IMG):/input/image.img:ro" \
96110
-e ARTIFACTS_DIR=/output \
111+
-e DISTRO_NAME="OctoPi" \
97112
-e KEEP_ALIVE=true \
98113
octopi-e2e-test
99114

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)