Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8fdac31160 |
+1
-65
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
# Test script for slim - boots containers and verifies CMD inference/override.
|
||||
# Requires: podman, qemu-system-x86_64, KVM, curl, and a kernel at
|
||||
# Requires: podman, qemu-system-x86_64, KVM, and a kernel at
|
||||
# $XDG_DATA_HOME/slim-rs/vmlinuz.
|
||||
set -u
|
||||
|
||||
@@ -102,76 +102,12 @@ EOF
|
||||
rm -rf "$work"
|
||||
}
|
||||
|
||||
test_service() {
|
||||
echo "=== Testing nextcloud service ==="
|
||||
|
||||
img="slim-test-nextcloud"
|
||||
host_port=18080
|
||||
work="$(mktemp -d)"
|
||||
|
||||
cat > "$work/Containerfile" <<'EOF'
|
||||
FROM nextcloud:32-apache
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends iproute2 && rm -rf /var/lib/apt/lists/*
|
||||
EOF
|
||||
|
||||
echo "-- Building nextcloud container image..."
|
||||
if ! podman build -t "$img" -f "$work/Containerfile" >/dev/null 2>&1; then
|
||||
report fail "nextcloud service (podman build failed)"
|
||||
rm -rf "$work"
|
||||
return
|
||||
fi
|
||||
|
||||
echo "-- Building slim VM..."
|
||||
if ! "$SLIM_BIN" build qcow2 "$img" >/dev/null 2>&1; then
|
||||
report fail "nextcloud service (slim build failed)"
|
||||
cleanup "$img" "$img"
|
||||
rm -rf "$work"
|
||||
return
|
||||
fi
|
||||
|
||||
echo "-- Booting VM with port forward (host :${host_port} -> guest :80)..."
|
||||
setsid timeout 300 "$SLIM_BIN" run "$img" \
|
||||
--forward "tcp:0.0.0.0:${host_port}-:80" \
|
||||
--memory 2048M >/dev/null 2>&1 &
|
||||
vm_pid=$!
|
||||
|
||||
echo "-- Waiting for Nextcloud to start..."
|
||||
up=0
|
||||
for _ in $(seq 1 60); do
|
||||
if curl -s -o /dev/null -m 2 "http://localhost:${host_port}/" 2>/dev/null; then
|
||||
up=1
|
||||
break
|
||||
fi
|
||||
sleep 3
|
||||
done
|
||||
|
||||
if [ "$up" = "1" ]; then
|
||||
response=$(curl -s -L -m 10 "http://localhost:${host_port}/" 2>/dev/null || true)
|
||||
if echo "$response" | grep -qi "nextcloud"; then
|
||||
report pass "nextcloud service (port forward + content)"
|
||||
else
|
||||
report fail "nextcloud service (port reachable but no 'nextcloud' in response)"
|
||||
fi
|
||||
else
|
||||
report fail "nextcloud service (port not reachable within timeout)"
|
||||
fi
|
||||
|
||||
pkill -f "qemu-system-x86_64.*$img" 2>/dev/null || true
|
||||
kill "$vm_pid" 2>/dev/null || true
|
||||
wait "$vm_pid" 2>/dev/null || true
|
||||
|
||||
cleanup "$img" "$img"
|
||||
rm -rf "$work"
|
||||
}
|
||||
|
||||
echo "Building slim..."
|
||||
cargo build 2>&1
|
||||
|
||||
test_distro "alpine" "alpine:latest" ""
|
||||
test_distro "archlinux" "archlinux:latest" "RUN pacman -Sy --noconfirm iputils iproute2 util-linux; pacman -Sc --noconfirm"
|
||||
|
||||
test_service
|
||||
|
||||
echo ""
|
||||
echo "=== Results: $pass passed, $fail failed ==="
|
||||
[ "$fail" -eq 0 ]
|
||||
|
||||
Reference in New Issue
Block a user