deb-bootc-image-builder/scripts/integration-scripts/simple-integration-test.sh
robojerk 126ee1a849
Some checks failed
particle-os CI / Test particle-os (push) Failing after 1s
particle-os CI / Integration Test (push) Has been skipped
particle-os CI / Security & Quality (push) Failing after 1s
Test particle-os Basic Functionality / test-basic (push) Failing after 1s
particle-os CI / Build and Release (push) Has been skipped
cleanup
2025-08-27 12:30:24 -07:00

124 lines
5.3 KiB
Bash
Executable file

#!/bin/bash
# Simple integration test between apt-ostree and deb-bootc-image-builder
# Tests each component individually to identify issues
set -euo pipefail
echo "🧪 Simple Integration Test: apt-ostree + deb-bootc-image-builder"
echo "================================================================"
# Configuration
WORKSPACE_PATH="/home/rob/Documents/Projects/overseer"
APT_OSTREE_PATH="$WORKSPACE_PATH/apt-ostree"
DEB_BOOTC_PATH="$WORKSPACE_PATH/deb-bootc-image-builder"
ATOMIC_CONFIGS_PATH="$WORKSPACE_PATH/debian-atomic-configs"
# Test 1: Verify apt-ostree can create OSTree commits
echo
echo "✅ Test 1: apt-ostree compose tree"
echo "-----------------------------------"
echo "Running apt-ostree compose tree in container..."
# Create a simple working directory
WORKDIR="./test-integration-$(date +%s)"
mkdir -p "$WORKDIR"
# Run apt-ostree compose tree
echo "Command: podman run --rm --privileged -v $APT_OSTREE_PATH:/workspace:z -v $ATOMIC_CONFIGS_PATH:/configs:z -v $WORKDIR:/shared:z apt-ostree-builder:latest bash -c 'cd /workspace && ./target/release/apt-ostree compose tree /configs/treefiles/debian-minimal-apt-ostree.yaml --workdir /shared/apt-ostree-build'"
if podman run --rm --privileged \
-v "$APT_OSTREE_PATH:/workspace:z" \
-v "$ATOMIC_CONFIGS_PATH:/configs:z" \
-v "$WORKDIR:/shared:z" \
apt-ostree-builder:latest \
bash -c "cd /workspace && ./target/release/apt-ostree compose tree /configs/treefiles/debian-minimal-apt-ostree.yaml --workdir /shared/apt-ostree-build"; then
echo "✅ apt-ostree compose tree completed successfully"
# Check what was created
echo
echo "📁 Checking created files:"
if [[ -d "$WORKDIR/apt-ostree-build" ]]; then
echo "✅ apt-ostree-build directory created"
ls -la "$WORKDIR/apt-ostree-build/"
if [[ -d "$WORKDIR/apt-ostree-build/repo" ]]; then
echo "✅ OSTree repository created"
ls -la "$WORKDIR/apt-ostree-build/repo/"
# Test 2: Verify OSTree repository is accessible
echo
echo "✅ Test 2: OSTree repository access"
echo "-----------------------------------"
echo "Testing ostree checkout from repository..."
# Extract the commit hash from the reference
COMMIT_HASH=$(cat "$WORKDIR/apt-ostree-build/repo/refs/heads/debian/14/x86_64/minimal")
if [[ -n "$COMMIT_HASH" ]]; then
echo "Found commit: $COMMIT_HASH"
# Test ostree checkout inside the container to avoid permission issues
ROOTFS_DIR="$WORKDIR/rootfs"
echo "Running ostree checkout in container..."
if podman run --rm --privileged \
-v "$WORKDIR:/shared:z" \
apt-ostree-builder:latest \
bash -c "ostree checkout --repo=/shared/apt-ostree-build/repo --subpath=/ '$COMMIT_HASH' /shared/rootfs"; then
echo "✅ ostree checkout successful"
echo "Rootfs structure:"
ls -la "$ROOTFS_DIR/"
# Test 3: Verify deb-bootc-image-builder can create bootable image
echo
echo "✅ Test 3: deb-bootc-image-builder integration"
echo "---------------------------------------------"
echo "Testing create-ostree-bootable-image..."
OUTPUT_IMAGE="$WORKDIR/debian-atomic-bootable.img"
if "$DEB_BOOTC_PATH/bib/create-ostree-bootable-image" "$ROOTFS_DIR" "$OUTPUT_IMAGE"; then
echo "✅ Bootable image created successfully!"
echo "Image: $OUTPUT_IMAGE"
echo "Size: $(du -h "$OUTPUT_IMAGE" | cut -f1)"
echo
echo "🎉 All integration tests passed!"
echo "✅ apt-ostree compose tree: Working"
echo "✅ OSTree repository access: Working"
echo "✅ deb-bootc-image-builder: Working"
echo
echo "🧪 To test the bootable image:"
echo "qemu-system-x86_64 -m 2G -drive file=$OUTPUT_IMAGE,format=raw -nographic -serial stdio"
# Copy image to persistent location for testing
PERSISTENT_IMAGE="./debian-atomic-bootable-test.img"
cp "$OUTPUT_IMAGE" "$PERSISTENT_IMAGE"
echo "📁 Image copied to: $PERSISTENT_IMAGE"
else
echo "❌ deb-bootc-image-builder failed"
fi
else
echo "❌ ostree checkout failed"
fi
else
echo "❌ No commit found in repository"
fi
else
echo "❌ OSTree repository not created"
fi
else
echo "❌ apt-ostree-build directory not created"
fi
else
echo "❌ apt-ostree compose tree failed"
fi
echo
echo "🧹 Cleaning up test directory..."
rm -rf "$WORKDIR"
echo "✅ Test completed"