deb-bootc-image-builder/scripts/build-scripts/full-test-suite.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

156 lines
5.1 KiB
Bash
Executable file
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# Full test suite for comprehensive validation
# This script tests all stages and end-to-end workflows
set -e
echo "🧪 Running full test suite..."
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Test counter
TESTS_PASSED=0
TESTS_FAILED=0
# Create test work directory
TEST_DIR="/tmp/particle-os-test-$(date +%s)"
mkdir -p "$TEST_DIR"
echo "Test work directory: $TEST_DIR"
# Cleanup function
cleanup() {
echo -e "\n🧹 Cleaning up test directories..."
if [ -d "$TEST_DIR" ]; then
sudo rm -rf "$TEST_DIR"
echo "Test directories cleaned up"
fi
}
# Set trap to cleanup on exit
trap cleanup EXIT
# Test function
run_test() {
local test_name="$1"
local test_command="$2"
local work_subdir="$3"
echo -e "\n📋 Test: $test_name"
echo "Command: $test_command"
# Create work subdirectory if specified
if [ -n "$work_subdir" ]; then
local full_work_dir="$TEST_DIR/$work_subdir"
mkdir -p "$full_work_dir"
test_command=$(echo "$test_command" | sed "s|--work-dir [^ ]*|--work-dir $full_work_dir|")
echo "Work directory: $full_work_dir"
fi
if eval "$test_command" >/dev/null 2>&1; then
echo -e "✅ PASS: $test_name"
((TESTS_PASSED++))
else
echo -e "❌ FAIL: $test_name"
((TESTS_FAILED++))
# Show error details for failed tests
echo "Error details:"
eval "$test_command" 2>&1 | head -20
fi
}
# Phase 1: Basic Functionality Testing
echo -e "\n${BLUE}=== Phase 1: Basic Functionality Testing ===${NC}"
run_test "Container listing" "./bib/particle-os container list"
run_test "Container inspection" "./bib/particle-os container inspect debian:trixie-slim"
run_test "Recipe listing" "./bib/particle-os list"
run_test "Recipe validation" "./bib/particle-os validate recipes/minimal-debug.yml"
# Phase 2: Stage Execution Testing
echo -e "\n${BLUE}=== Phase 2: Stage Execution Testing ===${NC}"
echo -e "\n${YELLOW}Note: These tests require the binary to be recompiled with sudo fixes${NC}"
echo "If tests fail with permission errors, the binary needs recompilation"
run_test "apt stage (minimal-debug)" "./bib/particle-os build --work-dir /tmp/test-apt recipes/minimal-debug.yml --verbose" "apt"
run_test "locale stage (minimal-debug-locale)" "./bib/particle-os build --work-dir /tmp/test-locale recipes/minimal-debug-locale.yml --verbose" "locale"
run_test "complete workflow (simple-cli-bootable)" "./bib/particle-os build --work-dir /tmp/test-cli recipes/simple-cli-bootable.yml --verbose" "cli"
# Phase 3: QEMU Stage Testing
echo -e "\n${BLUE}=== Phase 3: QEMU Stage Testing ===${NC}"
run_test "QEMU stage (multiple formats)" "./bib/particle-os build --work-dir /tmp/test-qemu recipes/qemu-test.yml --verbose" "qemu"
# Phase 4: Error Handling Testing
echo -e "\n${BLUE}=== Phase 4: Error Handling Testing ===${NC}"
# Test with invalid recipe (should fail gracefully)
echo -e "\n📋 Test: Invalid recipe handling"
if ./bib/particle-os build --work-dir /tmp/test-error invalid-recipe.yml --verbose 2>&1 | grep -q "error\|failed"; then
echo -e "✅ PASS: Invalid recipe handled gracefully"
((TESTS_PASSED++))
else
echo -e "❌ FAIL: Invalid recipe not handled properly"
((TESTS_FAILED++))
fi
# Phase 5: Resource Validation
echo -e "\n${BLUE}=== Phase 5: Resource Validation ===${NC}"
# Check if any images were created
echo -e "\n📋 Test: Image creation validation"
if find "$TEST_DIR" -name "*.img" -o -name "*.qcow2" -o -name "*.vmdk" -o -name "*.vdi" | grep -q .; then
echo -e "✅ PASS: Images were created successfully"
echo "Created images:"
find "$TEST_DIR" -name "*.img" -o -name "*.qcow2" -o -name "*.vmdk" -o -name "*.vdi" | head -10
((TESTS_PASSED++))
else
echo -e "❌ FAIL: No images were created"
((TESTS_FAILED++))
fi
# Summary
echo -e "\n${BLUE}=== Test Summary ===${NC}"
echo "Tests passed: $TESTS_PASSED"
echo "Tests failed: $TESTS_FAILED"
echo "Total tests: $((TESTS_PASSED + TESTS_FAILED))"
if [ $TESTS_FAILED -eq 0 ]; then
echo -e "\n🎉 All tests passed! particle-os is fully functional."
echo "The tool is ready for production use."
else
echo -e "\n⚠ Some tests failed. Please review the failures and address issues."
echo ""
echo "Common failure causes:"
echo "1. Binary not recompiled with sudo fixes"
echo "2. Insufficient disk space"
echo "3. Missing system tools"
echo "4. Permission issues"
fi
echo -e "\n📝 Next steps:"
if [ $TESTS_FAILED -eq 0 ]; then
echo "1. ✅ All tests passed - tool is production ready"
echo "2. Run performance testing"
echo "3. Test with real-world recipes"
echo "4. Deploy to CI/CD systems"
else
echo "1. Recompile binary with sudo fixes (if permission errors)"
echo "2. Address disk space issues (if space errors)"
echo "3. Install missing tools (if tool errors)"
echo "4. Re-run test suite after fixes"
fi
echo -e "\n📚 Documentation:"
echo "- Testing strategy: docs/TESTING_STRATEGY.md"
echo "- Usage guide: docs/HOW-TO-USE.md"
echo "- CI/CD guide: docs/HOW-TO-USE-AS-CICD.md"
echo "- Project status: todo"