Add comprehensive documentation, recipes, and testing framework
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
Tests / test (1.21.x) (push) Failing after 1s
Tests / test (1.22.x) (push) Failing after 1s
particle-os CI / Build and Release (push) Has been skipped
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
Tests / test (1.21.x) (push) Failing after 1s
Tests / test (1.22.x) (push) Failing after 1s
particle-os CI / Build and Release (push) Has been skipped
- Add extensive documentation covering current status, usage, and testing strategies - Add recipe files for various image configurations (minimal, debug, kernel test, etc.) - Add testing and management scripts for comprehensive testing workflows - Add Go module configuration and updated Go code - Add manual bootable image creation script - Update todo with current project status and next steps
This commit is contained in:
parent
65302755dd
commit
0409f1d67c
34 changed files with 5328 additions and 346 deletions
156
scripts/full-test-suite.sh
Executable file
156
scripts/full-test-suite.sh
Executable file
|
|
@ -0,0 +1,156 @@
|
|||
#!/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"
|
||||
251
scripts/manage-disk-space.sh
Executable file
251
scripts/manage-disk-space.sh
Executable file
|
|
@ -0,0 +1,251 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
# Disk space management script for particle-os builds
|
||||
# This script helps manage disk space and clean up build artifacts
|
||||
|
||||
WORK_DIRS=(
|
||||
"/tmp/particle-os-build"
|
||||
"/tmp/test-*"
|
||||
"/tmp/particle-os-*"
|
||||
"/tmp/deb-bootc-*"
|
||||
"/tmp/test-sudo-fix*"
|
||||
"/tmp/test-improvements*"
|
||||
)
|
||||
|
||||
BUILD_DIRS=(
|
||||
"work/*"
|
||||
"output/*"
|
||||
"*.img"
|
||||
"*.qcow2"
|
||||
"*.vmdk"
|
||||
"*.vdi"
|
||||
)
|
||||
|
||||
# Colors for output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Logging functions
|
||||
log_info() {
|
||||
echo -e "${GREEN}[INFO]${NC} $1"
|
||||
}
|
||||
|
||||
log_warn() {
|
||||
echo -e "${YELLOW}[WARN]${NC} $1"
|
||||
}
|
||||
|
||||
log_error() {
|
||||
echo -e "${RED}[ERROR]${NC} $1"
|
||||
}
|
||||
|
||||
# Check disk space
|
||||
check_disk_space() {
|
||||
local path="$1"
|
||||
local available_gb=$(df -BG "$path" | tail -1 | awk '{print $4}' | sed 's/G//')
|
||||
local used_percent=$(df -h "$path" | tail -1 | awk '{print $5}' | sed 's/%//')
|
||||
|
||||
echo "Disk space for $path:"
|
||||
echo " Available: ${available_gb}GB"
|
||||
echo " Used: ${used_percent}%"
|
||||
|
||||
if [ "$available_gb" -lt 5 ]; then
|
||||
log_warn "Low disk space: ${available_gb}GB available, 5GB recommended for builds"
|
||||
return 1
|
||||
else
|
||||
log_info "Sufficient disk space: ${available_gb}GB available"
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
# Clean up work directories
|
||||
cleanup_work_dirs() {
|
||||
log_info "Cleaning up work directories..."
|
||||
|
||||
local cleaned=0
|
||||
for pattern in "${WORK_DIRS[@]}"; do
|
||||
for dir in $pattern; do
|
||||
if [ -d "$dir" ]; then
|
||||
log_info "Removing: $dir"
|
||||
sudo rm -rf "$dir"
|
||||
cleaned=$((cleaned + 1))
|
||||
fi
|
||||
done
|
||||
done
|
||||
|
||||
if [ $cleaned -eq 0 ]; then
|
||||
log_info "No work directories to clean up"
|
||||
else
|
||||
log_info "Cleaned up $cleaned work directories"
|
||||
fi
|
||||
}
|
||||
|
||||
# Clean up build artifacts
|
||||
cleanup_build_artifacts() {
|
||||
log_info "Cleaning up build artifacts..."
|
||||
|
||||
local cleaned=0
|
||||
for pattern in "${BUILD_DIRS[@]}"; do
|
||||
for file in $pattern; do
|
||||
if [ -e "$file" ]; then
|
||||
log_info "Removing: $file"
|
||||
rm -rf "$file"
|
||||
cleaned=$((cleaned + 1))
|
||||
fi
|
||||
done
|
||||
done
|
||||
|
||||
if [ $cleaned -eq 0 ]; then
|
||||
log_info "No build artifacts to clean up"
|
||||
else
|
||||
log_info "Cleaned up $cleaned build artifacts"
|
||||
fi
|
||||
}
|
||||
|
||||
# Clean up package caches
|
||||
cleanup_package_caches() {
|
||||
log_info "Cleaning up package caches..."
|
||||
|
||||
# Clean apt cache
|
||||
if command -v apt >/dev/null 2>&1; then
|
||||
log_info "Cleaning apt cache..."
|
||||
sudo apt clean
|
||||
sudo apt autoremove -y
|
||||
fi
|
||||
|
||||
# Clean podman cache
|
||||
if command -v podman >/dev/null 2>&1; then
|
||||
log_info "Cleaning podman cache..."
|
||||
podman system prune -f
|
||||
fi
|
||||
|
||||
# Clean docker cache
|
||||
if command -v docker >/dev/null 2>&1; then
|
||||
log_info "Cleaning docker cache..."
|
||||
docker system prune -f
|
||||
fi
|
||||
}
|
||||
|
||||
# Find large files and directories
|
||||
find_large_files() {
|
||||
local path="$1"
|
||||
local size="${2:-100M}"
|
||||
|
||||
log_info "Finding files larger than $size in $path..."
|
||||
|
||||
if [ -d "$path" ]; then
|
||||
find "$path" -type f -size "+$size" -exec ls -lh {} \; 2>/dev/null | head -20
|
||||
else
|
||||
log_warn "Path $path does not exist"
|
||||
fi
|
||||
}
|
||||
|
||||
# Create custom work directory with more space
|
||||
create_custom_work_dir() {
|
||||
local custom_dir="$1"
|
||||
|
||||
if [ -z "$custom_dir" ]; then
|
||||
custom_dir="/tmp/particle-os-custom-$(date +%s)"
|
||||
fi
|
||||
|
||||
log_info "Creating custom work directory: $custom_dir"
|
||||
|
||||
if mkdir -p "$custom_dir"; then
|
||||
log_info "Custom work directory created successfully"
|
||||
echo "Use this directory for builds:"
|
||||
echo " ./bib/particle-os build --work-dir $custom_dir recipes/minimal-debug.yml"
|
||||
echo ""
|
||||
echo "Directory: $custom_dir"
|
||||
else
|
||||
log_error "Failed to create custom work directory"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Show help
|
||||
show_help() {
|
||||
cat << EOF
|
||||
Disk Space Management Script for particle-os
|
||||
|
||||
Usage: $0 [COMMAND] [OPTIONS]
|
||||
|
||||
Commands:
|
||||
check [PATH] Check disk space for PATH (default: /tmp)
|
||||
cleanup Clean up all work directories and build artifacts
|
||||
cleanup-work Clean up only work directories
|
||||
cleanup-builds Clean up only build artifacts
|
||||
cleanup-caches Clean up package and container caches
|
||||
find-large [PATH] Find large files in PATH (default: current directory)
|
||||
create-work-dir [DIR] Create custom work directory with more space
|
||||
status Show current disk space status
|
||||
|
||||
Options:
|
||||
-h, --help Show this help message
|
||||
|
||||
Examples:
|
||||
$0 check /tmp
|
||||
$0 cleanup
|
||||
$0 create-work-dir /home/joe/particle-os-builds
|
||||
$0 find-large /tmp
|
||||
|
||||
EOF
|
||||
}
|
||||
|
||||
# Main execution
|
||||
case "${1:-status}" in
|
||||
"check")
|
||||
path="${2:-/tmp}"
|
||||
check_disk_space "$path"
|
||||
;;
|
||||
"cleanup")
|
||||
cleanup_work_dirs
|
||||
cleanup_build_artifacts
|
||||
cleanup_package_caches
|
||||
check_disk_space "/tmp"
|
||||
;;
|
||||
"cleanup-work")
|
||||
cleanup_work_dirs
|
||||
;;
|
||||
"cleanup-builds")
|
||||
cleanup_build_artifacts
|
||||
;;
|
||||
"cleanup-caches")
|
||||
cleanup_package_caches
|
||||
;;
|
||||
"find-large")
|
||||
path="${2:-.}"
|
||||
size="${3:-100M}"
|
||||
find_large_files "$path" "$size"
|
||||
;;
|
||||
"create-work-dir")
|
||||
create_custom_work_dir "$2"
|
||||
;;
|
||||
"status")
|
||||
echo "=== Disk Space Status ==="
|
||||
check_disk_space "/tmp"
|
||||
echo ""
|
||||
check_disk_space "/opt/Projects/deb-bootc-image-builder"
|
||||
echo ""
|
||||
echo "=== Work Directory Status ==="
|
||||
for pattern in "${WORK_DIRS[@]}"; do
|
||||
for dir in $pattern; do
|
||||
if [ -d "$dir" ]; then
|
||||
size=$(du -sh "$dir" 2>/dev/null | cut -f1)
|
||||
echo " $dir: $size"
|
||||
fi
|
||||
done
|
||||
done
|
||||
;;
|
||||
"-h"|"--help"|"help")
|
||||
show_help
|
||||
;;
|
||||
*)
|
||||
log_error "Unknown command: $1"
|
||||
show_help
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
104
scripts/quick-test-suite.sh
Executable file
104
scripts/quick-test-suite.sh
Executable file
|
|
@ -0,0 +1,104 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Quick test suite for basic functionality
|
||||
# This script tests the core functionality of particle-os
|
||||
|
||||
set -e
|
||||
|
||||
echo "🧪 Running quick 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
|
||||
|
||||
# Test function
|
||||
run_test() {
|
||||
local test_name="$1"
|
||||
local test_command="$2"
|
||||
|
||||
echo -e "\n📋 Test: $test_name"
|
||||
echo "Command: $test_command"
|
||||
|
||||
if eval "$test_command" >/dev/null 2>&1; then
|
||||
echo -e "✅ PASS: $test_name"
|
||||
((TESTS_PASSED++))
|
||||
else
|
||||
echo -e "❌ FAIL: $test_name"
|
||||
((TESTS_FAILED++))
|
||||
fi
|
||||
}
|
||||
|
||||
# Test 1: Basic functionality
|
||||
echo -e "\n${BLUE}=== Test 1: Basic Functionality ===${NC}"
|
||||
|
||||
run_test "Version command" "./bib/particle-os --version"
|
||||
run_test "Help command" "./bib/particle-os --help"
|
||||
run_test "List recipes" "./bib/particle-os list"
|
||||
|
||||
# Test 2: Container operations
|
||||
echo -e "\n${BLUE}=== Test 2: Container Operations ===${NC}"
|
||||
|
||||
run_test "Container list" "./bib/particle-os container list"
|
||||
run_test "Container inspect" "./bib/particle-os container inspect debian:trixie-slim"
|
||||
|
||||
# Test 3: Recipe validation
|
||||
echo -e "\n${BLUE}=== Test 3: Recipe Validation ===${NC}"
|
||||
|
||||
run_test "Validate minimal-debug.yml" "./bib/particle-os validate recipes/minimal-debug.yml"
|
||||
run_test "Validate simple-cli-bootable.yml" "./bib/particle-os validate recipes/simple-cli-bootable.yml"
|
||||
|
||||
# Test 4: Tool availability
|
||||
echo -e "\n${BLUE}=== Test 4: Tool Availability ===${NC}"
|
||||
|
||||
run_test "parted available" "which parted"
|
||||
run_test "mkfs.ext4 available" "which mkfs.ext4"
|
||||
run_test "extlinux available" "which extlinux"
|
||||
run_test "qemu-img available" "which qemu-img"
|
||||
|
||||
# Test 5: System resources
|
||||
echo -e "\n${BLUE}=== Test 5: System Resources ===${NC}"
|
||||
|
||||
# Check sudo access
|
||||
if sudo -n true 2>/dev/null; then
|
||||
echo -e "✅ PASS: Sudo access (passwordless)"
|
||||
((TESTS_PASSED++))
|
||||
else
|
||||
echo -e "⚠️ WARN: Sudo access (may require password)"
|
||||
fi
|
||||
|
||||
# Check disk space
|
||||
TMP_SPACE=$(df -BG /tmp | tail -1 | awk '{print $4}' | sed 's/G//')
|
||||
if [ "$TMP_SPACE" -ge 5 ]; then
|
||||
echo -e "✅ PASS: Sufficient disk space in /tmp (${TMP_SPACE}GB >= 5GB)"
|
||||
((TESTS_PASSED++))
|
||||
else
|
||||
echo -e "❌ FAIL: Insufficient disk space in /tmp (${TMP_SPACE}GB < 5GB)"
|
||||
((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 ready for full testing."
|
||||
echo "Next step: Recompile binary with sudo fixes and run full test suite."
|
||||
else
|
||||
echo -e "\n⚠️ Some tests failed. Please address these issues before proceeding."
|
||||
echo "Failed tests may indicate missing dependencies or configuration issues."
|
||||
fi
|
||||
|
||||
echo -e "\n📝 Next steps:"
|
||||
echo "1. Install Go 1.21+ to recompile binary"
|
||||
echo "2. Recompile binary with sudo fixes"
|
||||
echo "3. Run full test suite: scripts/full-test-suite.sh"
|
||||
echo "4. Execute testing strategy: docs/TESTING_STRATEGY.md"
|
||||
Loading…
Add table
Add a link
Reference in a new issue