This commit is contained in:
Stephen Simpson
2025-11-26 08:15:00 -06:00
parent 3cbd4525a0
commit bb829c9b63
18 changed files with 2440 additions and 349 deletions

103
README.simple.md Normal file
View File

@@ -0,0 +1,103 @@
# Rocky Linux Testing Framework
Simple, portable testing framework for Rocky Linux using Sparrowdo.
## Quick Start
### Prerequisites
```bash
sudo dnf install -y qemu-kvm libvirt virt-install guestfs-tools rakudo
sudo systemctl enable --now libvirtd
sudo usermod -a -G libvirt $(whoami)
```
### Manual Test
```bash
# Download base image
BASE=$(./scripts/download-image.sh https://download.rockylinux.org/pub/rocky/9/images/x86_64/Rocky-9-GenericCloud-Base.latest.x86_64.qcow2)
# Build golden image (includes Sparrowdo bootstrap)
./scripts/build-golden.sh "$BASE" /var/lib/libvirt/images/golden.qcow2
# Run a test
./scripts/run-test.sh my-test https://github.com/your-org/test-repo.git /var/lib/libvirt/images/golden.qcow2
# Cleanup
./scripts/cleanup-all.sh
```
### Jenkins
1. Create Pipeline job
2. Point to `Jenkinsfile.simple`
3. Set parameters:
- `QCOW2_URL`: Rocky Linux image URL
- `TEST_REPOS`: One repo URL per line
- `MAX_PARALLEL`: Number of concurrent tests
## Scripts
- `download-image.sh` - Download/cache QCOW2 images
- `build-golden.sh` - Create golden image with Sparrowdo
- `run-test.sh` - Run single test in isolated VM
- `provision_vm.sh` - Create and start VM
- `cleanup_vm.sh` - Destroy VM
- `cleanup-all.sh` - Emergency cleanup
## How It Works
1. Download Rocky Linux QCOW2 (cached)
2. Build golden image:
- Install Raku, Sparrowdo, dependencies
- Create `rocky` user with sudo
- Inject SSH keys
- Bootstrap Sparrowdo
3. For each test:
- Provision VM (linked clone, fast)
- Clone test repo
- Run `sparrowdo --no_sudo`
- Cleanup VM
## Test Repository Format
Your test repo needs either `sparrowfile` or `main.raku`:
```raku
#!/usr/bin/env raku
use Sparrowdo;
task-run 'check-service', %(
plugin => 'systemd-service',
args => ['sshd', 'running']
);
```
## Portability
All logic is in shell scripts. Easy to move to:
- GitHub Actions: Call scripts in workflow
- GitLab CI: Call scripts in `.gitlab-ci.yml`
- Windmill: Call scripts as tasks
- Manually: Run scripts directly
## Troubleshooting
```bash
# List VMs
virsh -c qemu:///system list --all
# Get VM IP
virsh -c qemu:///system domifaddr <vm-name>
# SSH to VM
ssh -i ~/.ssh/id_rsa rocky@<ip>
# View VM console
virsh -c qemu:///system console <vm-name>
# Force cleanup
./scripts/cleanup-all.sh
```