Files
resf-testing-repo/README.simple.md
Stephen Simpson ec04f0bec5 Implement Ansible roles for Rocky Linux Testing Framework
- Added `bootstrap_sparrowdo` role for bootstrapping Sparrowdo on a VM.
- Introduced `cleanup_vm` role for cleaning up VMs and disk images.
- Created `download_image` role to download and cache QCOW2 images.
- Developed `golden_image` role for creating and customizing golden images.
- Implemented `provision_vm` role for provisioning VMs as linked clones.
- Added `run_test` role for executing tests with Sparrowdo.
- Created playbooks for building golden images, running single tests, and running test suites.
- Enhanced documentation with usage examples, configuration details, and troubleshooting tips.
- Added support for multiple cloud providers (AWS, Azure) in the test execution workflow.

Signed-off-by: Stephen Simpson <ssimpson89@users.noreply.github.com>
2025-12-29 16:02:39 -06:00

2.1 KiB

Rocky Linux Testing Framework

Simple, portable testing framework for Rocky Linux using Sparrowdo.

Quick Start

Prerequisites

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

# 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

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:

#!/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

# 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