This guide explains how to test saidata files on real systems using the saigen test-system command.
The testing framework validates saidata files by:
- Checking package existence in repositories
- Testing installation (optional)
- Verifying service availability
- Validating file locations
Test a single saidata file without modifying the system:
saigen test-system nginx.yamlThis checks if packages exist in repositories but doesn't install anything.
Test with actual installation (requires appropriate permissions):
sudo saigen test-system --real-install nginx.yamlTest all saidata files in a directory:
saigen test-system --batch packages/Human-readable format:
saigen test-system nginx.yamlMachine-readable format for CI/CD:
saigen test-system --format json nginx.yamlFor CI/CD integration:
saigen test-system --format junit -o results.xml nginx.yamlTest across different operating systems using Docker:
docker run --rm -v $(pwd):/data ghcr.io/example42/sai-test-ubuntu:latest \
saigen test-system /data/nginx.yamldocker run --rm -v $(pwd):/data ghcr.io/example42/sai-test-fedora:latest \
saigen test-system /data/nginx.yamldocker run --rm -v $(pwd):/data ghcr.io/example42/sai-test-alpine:latest \
saigen test-system /data/nginx.yamldocker run --rm --privileged -v $(pwd):/data ghcr.io/example42/sai-test-ubuntu:latest \
saigen test-system --real-install /data/nginx.yamlExample workflow for testing saidata files:
name: Test Saidata
on: [pull_request, push]
jobs:
test-linux:
runs-on: ubuntu-latest
strategy:
matrix:
os: [ubuntu, debian, fedora, alpine]
steps:
- uses: actions/checkout@v4
- name: Test saidata
run: |
docker run --rm -v $PWD:/data \
ghcr.io/example42/sai-test-${{ matrix.os }}:latest \
saigen test-system --batch /data/packages
test-macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: Install saigen
run: pip install saigen
- name: Test saidata
run: saigen test-system --batch packages/
test-windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: Install saigen
run: pip install saigen
- name: Test saidata
run: saigen test-system --batch packages/For testing on specific hardware or OS versions, use self-hosted runners:
- Register a self-hosted runner on your lab machine
- Label it appropriately (e.g.,
self-hosted,linux,bare-metal) - Configure the workflow to use it
test-lab:
runs-on: [self-hosted, linux, bare-metal]
steps:
- uses: actions/checkout@v4
- run: saigen test-system --real-install packages/nginx.yaml0- All tests passed1- One or more tests failed2- Tests passed with warnings
The framework runs these validation tests:
- Package Existence - Verifies packages exist in repositories
- Installation - Tests actual installation (with
--real-install) - Services - Checks if services are available
- Files - Validates file locations
============================================================
Test Suite: nginx.yaml
============================================================
Duration: 2.34s
Total: 4 | Passed: 3 | Failed: 0 | Skipped: 1 | Errors: 0
------------------------------------------------------------
✓ package_exists (0.45s)
All packages exist in repositories
✓ services (0.12s)
All services exist
✓ files (0.08s)
All files exist
○ installation (0.00s)
Skipped in dry-run mode
============================================================
- Use dry-run mode during development
- Test locally with Docker before pushing
- Use verbose mode (
-v) for debugging
- Run dry-run tests on every PR
- Use matrix strategy for multi-OS testing
- Generate JUnit XML for test reporting
- Use self-hosted runners for real installation tests
- Schedule periodic full-suite tests
- Test on actual target systems
- Monitor test results and trends
- Keep test environments up to date
If a package isn't found:
- Verify the package name is correct
- Check if the package manager is available
- Ensure repositories are up to date
For installation tests:
- Use
sudoon Linux/macOS - Run as Administrator on Windows
- Use
--privilegedflag with Docker
If tests timeout:
- Check network connectivity
- Verify repository availability
- Increase timeout if needed
Create custom test scripts for complex scenarios:
#!/bin/bash
# test-all.sh
for file in packages/*.yaml; do
echo "Testing $file..."
saigen test-system "$file" || exit 1
doneCombine with other validation tools:
# Validate schema first
saigen validate nginx.yaml
# Then test on system
saigen test-system nginx.yamlTest multiple files in parallel:
find packages/ -name "*.yaml" | \
xargs -P 4 -I {} saigen test-system {}