- Create justfile-based testing framework with 20+ test targets - Support different deployment scenarios: container, booted system, disk-based, fresh install - Environment detection for OSTree, container, boot type, and system info - CLI functionality testing for all apt-ostree commands - Error handling and performance testing - Test report generation and cleanup utilities - Comprehensive documentation in TESTING.md - Mindful of system state: booted, container, installed, or disk image
187 lines
9.1 KiB
Makefile
187 lines
9.1 KiB
Makefile
# apt-ostree Testing Suite
|
|
# Comprehensive testing for Debian-based OSTree systems
|
|
|
|
# Default target - show available commands
|
|
default:
|
|
@just --list
|
|
|
|
# Detect system environment and show status
|
|
detect-env:
|
|
@echo "🔍 Detecting system environment..."
|
|
@echo "OSTree Status:"
|
|
@ostree admin status 2>/dev/null || echo " ❌ OSTree not available"
|
|
@echo ""
|
|
@echo "Container Environment:"
|
|
@bash -c 'if [ -f /.dockerenv ] || [ -f /run/.containerenv ]; then echo " 🐳 Running in container"; echo " Container type: $(cat /proc/1/cgroup | grep -o "docker\|podman\|lxc" | head -1 || echo "unknown")"; else echo " 💻 Running on bare metal/VM"; fi'
|
|
@echo ""
|
|
@echo "Boot Status:"
|
|
@bash -c 'if [ -d /sys/firmware/efi ]; then echo " 🔌 UEFI boot detected"; else echo " 💾 Legacy BIOS boot detected"; fi'
|
|
@echo ""
|
|
@echo "System Information:"
|
|
@echo " OS: $(cat /etc/os-release | grep PRETTY_NAME | cut -d'"' -f2 || echo 'unknown')"
|
|
@echo " Kernel: $(uname -r)"
|
|
@echo " Architecture: $(uname -m)"
|
|
|
|
# Test apt-ostree CLI functionality
|
|
test-cli:
|
|
@echo "🧪 Testing apt-ostree CLI functionality..."
|
|
@echo "Testing main help..."
|
|
@apt-ostree --help
|
|
@echo ""
|
|
@echo "Testing version..."
|
|
@apt-ostree --version
|
|
@echo ""
|
|
@echo "Testing command help..."
|
|
@apt-ostree status --help
|
|
@echo ""
|
|
@echo "Testing search functionality..."
|
|
@apt-ostree search bash | head -5
|
|
|
|
# Test OSTree system status
|
|
test-ostree:
|
|
@echo "🌳 Testing OSTree system status..."
|
|
@bash -c 'if command -v ostree >/dev/null 2>&1; then echo "OSTree version: $(ostree --version)"; echo ""; echo "Current deployment:"; ostree admin status 2>/dev/null || echo " ❌ No deployments found"; echo ""; echo "Repository status:"; ostree admin status --repo 2>/dev/null || echo " ❌ Repository not accessible"; else echo "❌ OSTree not installed"; fi'
|
|
|
|
# Test apt-ostree in different environments
|
|
test-environments:
|
|
@echo "🔧 Testing apt-ostree in different environments..."
|
|
@echo ""
|
|
@echo "1. Testing in current environment..."
|
|
@just test-cli
|
|
@echo ""
|
|
@echo "2. Testing OSTree integration..."
|
|
@just test-ostree
|
|
@echo ""
|
|
@echo "3. Testing package search..."
|
|
@apt-ostree search apt | head -3
|
|
|
|
# Test container environment (Podman/Docker)
|
|
test-container:
|
|
@echo "🐳 Testing apt-ostree in container environment..."
|
|
@bash -c 'if [ -f /.dockerenv ] || [ -f /run/.containerenv ]; then echo "✅ Running in container"; just test-cli; just test-ostree; else echo "❌ Not running in container"; echo "To test in container, run: just run-container-test"; fi'
|
|
|
|
# Run container test (creates temporary container)
|
|
run-container-test:
|
|
@echo "🐳 Creating temporary container for testing..."
|
|
@bash -c 'if command -v podman >/dev/null 2>&1; then echo "Using Podman..."; podman run --rm -it --name apt-ostree-test -v $(pwd):/workspace debian:bookworm-slim bash -c "cd /workspace && just test-cli"; elif command -v docker >/dev/null 2>&1; then echo "Using Docker..."; docker run --rm -it --name apt-ostree-test -v $(pwd):/workspace debian:bookworm-slim bash -c "cd /workspace && just test-cli"; else echo "❌ Neither Podman nor Docker found"; fi'
|
|
|
|
# Test booted OSTree system
|
|
test-booted-system:
|
|
@echo "🚀 Testing apt-ostree on booted OSTree system..."
|
|
@bash -c 'if [ -d /ostree ] && [ -d /sysroot ]; then echo "✅ OSTree system detected"; just test-cli; just test-ostree; echo ""; echo "Testing system-specific commands..."; apt-ostree status 2>/dev/null || echo " ❌ Status command failed"; apt-ostree search systemd | head -3; else echo "❌ Not running on booted OSTree system"; echo "This test requires a live OSTree deployment"; fi'
|
|
|
|
# Test disk-based OSTree system (QCOW2, etc.)
|
|
test-disk-system:
|
|
@echo "💾 Testing apt-ostree on disk-based OSTree system..."
|
|
@bash -c 'if [ -f /etc/ostree/ostree.conf ] || [ -d /ostree ]; then echo "✅ OSTree configuration found"; just test-cli; echo ""; echo "Testing disk-specific operations..."; if [ -w /ostree ]; then echo "✅ OSTree directory is writable"; else echo "⚠️ OSTree directory is read-only (may be mounted image)"; fi; else echo "❌ OSTree configuration not found"; echo "This may be a fresh system or non-OSTree system"; fi'
|
|
|
|
# Test fresh installation
|
|
test-fresh-install:
|
|
@echo "🆕 Testing apt-ostree on fresh installation..."
|
|
@bash -c 'if ! command -v ostree >/dev/null 2>&1; then echo "✅ Fresh system detected (no OSTree)"; just test-cli; echo ""; echo "Testing without OSTree dependencies..."; apt-ostree --help; apt-ostree --version; else echo "⚠️ OSTree already installed"; just test-cli; fi'
|
|
|
|
# Comprehensive system test
|
|
test-system:
|
|
@echo "🔍 Running comprehensive system test..."
|
|
@just detect-env
|
|
@echo ""
|
|
@just test-environments
|
|
@echo ""
|
|
@echo "📊 Test Summary:"
|
|
@echo " CLI Tests: $(just test-cli >/dev/null 2>&1 && echo '✅ PASS' || echo '❌ FAIL')"
|
|
@echo " OSTree Tests: $(just test-ostree >/dev/null 2>&1 && echo '✅ PASS' || echo '❌ FAIL')"
|
|
@echo " Environment Tests: $(just test-environments >/dev/null 2>&1 && echo '✅ PASS' || echo '❌ FAIL')"
|
|
|
|
# Test specific apt-ostree commands
|
|
test-commands:
|
|
@echo "📋 Testing specific apt-ostree commands..."
|
|
@echo ""
|
|
@echo "Testing help commands..."
|
|
@apt-ostree --help >/dev/null && echo "✅ Main help" || echo "❌ Main help"
|
|
@apt-ostree status --help >/dev/null && echo "✅ Status help" || echo "❌ Status help"
|
|
@apt-ostree install --help >/dev/null && echo "✅ Install help" || echo "❌ Install help"
|
|
@echo ""
|
|
@echo "Testing search commands..."
|
|
@apt-ostree search bash >/dev/null && echo "✅ Search bash" || echo "❌ Search bash"
|
|
@apt-ostree search systemd >/dev/null && echo "✅ Search systemd" || echo "❌ Search systemd"
|
|
@echo ""
|
|
@echo "Testing status commands..."
|
|
@apt-ostree status >/dev/null 2>&1 && echo "✅ Status command" || echo "❌ Status command"
|
|
|
|
# Test error handling
|
|
test-errors:
|
|
@echo "⚠️ Testing error handling..."
|
|
@echo ""
|
|
@echo "Testing missing arguments..."
|
|
@apt-ostree install 2>&1 | grep -q "No package specified" && echo "✅ Install error handling" || echo "❌ Install error handling"
|
|
@apt-ostree search 2>&1 | grep -q "No query specified" && echo "✅ Search error handling" || echo "❌ Search error handling"
|
|
@echo ""
|
|
@echo "Testing invalid commands..."
|
|
@apt-ostree invalid-command 2>&1 | grep -q "Unknown command" && echo "✅ Invalid command handling" || echo "❌ Invalid command handling"
|
|
|
|
# Performance testing
|
|
test-performance:
|
|
@echo "⚡ Testing performance..."
|
|
@echo ""
|
|
@echo "Help command performance:"
|
|
@bash -c 'start=$(date +%s); apt-ostree --help >/dev/null; end=$(date +%s); echo " Time: $((end - start))s"'
|
|
@echo ""
|
|
@echo "Search command performance:"
|
|
@bash -c 'start=$(date +%s); apt-ostree search bash >/dev/null; end=$(date +%s); echo " Time: $((end - start))s"'
|
|
@echo ""
|
|
@echo "Version command performance:"
|
|
@bash -c 'start=$(date +%s); apt-ostree --version >/dev/null; end=$(date +%s); echo " Time: $((end - start))s"'
|
|
|
|
# Generate test report
|
|
test-report:
|
|
@echo "📊 Generating test report..."
|
|
@echo "Test Report - $(date)" > test-report.txt
|
|
@echo "========================" >> test-report.txt
|
|
@echo "" >> test-report.txt
|
|
@just detect-env >> test-report.txt 2>&1
|
|
@echo "" >> test-report.txt
|
|
@echo "CLI Tests:" >> test-report.txt
|
|
@just test-cli >> test-report.txt 2>&1
|
|
@echo "" >> test-report.txt
|
|
@echo "OSTree Tests:" >> test-report.txt
|
|
@just test-ostree >> test-report.txt 2>&1
|
|
@echo "Report saved to: test-report.txt"
|
|
|
|
# Clean up test artifacts
|
|
clean:
|
|
@echo "🧹 Cleaning up test artifacts..."
|
|
@rm -f test-report.txt
|
|
@echo "✅ Cleanup complete"
|
|
|
|
# Show help
|
|
help:
|
|
@echo "apt-ostree Testing Suite"
|
|
@echo "========================"
|
|
@echo ""
|
|
@echo "Environment Detection:"
|
|
@echo " detect-env - Detect system environment and status"
|
|
@echo " test-environments - Test apt-ostree in different environments"
|
|
@echo ""
|
|
@echo "Specific Tests:"
|
|
@echo " test-cli - Test CLI functionality"
|
|
@echo " test-ostree - Test OSTree integration"
|
|
@echo " test-container - Test in container environment"
|
|
@echo " test-booted-system - Test on booted OSTree system"
|
|
@echo " test-disk-system - Test on disk-based OSTree system"
|
|
@echo " test-fresh-install - Test on fresh installation"
|
|
@echo ""
|
|
@echo "Comprehensive Testing:"
|
|
@echo " test-system - Run comprehensive system test"
|
|
@echo " test-commands - Test specific commands"
|
|
@echo " test-errors - Test error handling"
|
|
@echo " test-performance - Test performance"
|
|
@echo ""
|
|
@echo "Utilities:"
|
|
@echo " test-report - Generate test report"
|
|
@echo " clean - Clean up test artifacts"
|
|
@echo " help - Show this help message"
|
|
@echo ""
|
|
@echo "Examples:"
|
|
@echo " just test-system - Run full system test"
|
|
@echo " just test-cli - Test CLI only"
|
|
@echo " just detect-env - Check system status"
|