# 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"