Run Tests
This guide explains how to run Garden Linux tests in various environments including chroot, QEMU, cloud providers, OCI containers, and Kubernetes clusters.
Quick Start
The main entry point is ./test in the Garden Linux root directory (symlink to tests/util/run.sh). It automatically detects the image type and runs appropriate tests:
# For chroot testing (tar files)
./test .build/$image.tar
# For QEMU VM testing (raw files)
./test .build/$image.raw
# For cloud provider testing (raw files only)
./test --cloud aws .build/$image.raw
./test --cloud gcp .build/$image.raw
./test --cloud azure .build/$image.raw
./test --cloud ali .build/$image.rawTIP
Use ./test --help to see all available options and examples.
Test Environments
Garden Linux supports testing in multiple environments, each with different characteristics:
Chroot Testing
Runs tests directly in the extracted image filesystem.
Characteristics:
- Fastest execution method
- Limited to filesystem-level tests
- No boot process involved
- No network or services running
Usage:
./test .build/image.tarQEMU Testing
Boots the image in a local QEMU virtual machine.
Characteristics:
- Full system testing including boot process
- SSH access available on localhost:2222
- Supports various architectures and boot modes
- Suitable for local development and testing
Usage:
# Basic QEMU testing
./test .build/image.raw
# With SSH access
./test --ssh .build/image.raw
# With debug window
./test --debug .build/image.raw
# Keep VM running after tests
./test --ssh --skip-cleanup .build/image.rawCloud Testing
Deploys the image to cloud infrastructure using OpenTofu.
Characteristics:
- Real-world environment testing
- Automatic resource cleanup (unless
--skip-cleanupis used) - Supports AWS, GCP, Azure, Alibaba Cloud, and OpenStack
- Tests cloud-specific integrations
Usage:
# Test on AWS
./test --cloud aws .build/image.raw
# Test on Azure
./test --cloud azure .build/image.raw
# Test on GCP
./test --cloud gcp .build/image.raw
# Test on Alibaba Cloud
./test --cloud ali .build/image.raw
# Skip cleanup to inspect resources
./test --cloud aws --skip-cleanup .build/image.rawSee Test in Cloud for detailed cloud provider setup and authentication.
OCI Testing
Runs tests in containers based on a Base Image.
Characteristics:
- Very fast execution method
- Limited to Base Image (Bare Flavors are not currently supported)
- Limited to unbooted system
- Suitable for quick validation
Usage:
./test .build/container-amd64-today-local.ociKubernetes Cluster Testing
The test framework can run directly on a live Gardener cluster (or any Kubernetes cluster running Garden Linux nodes).
Deploy the following YAML:
apiVersion: v1
kind: Pod
metadata:
name: test
spec:
hostPID: true
restartPolicy: Never
containers:
- name: test
image: ghcr.io/gardenlinux/test:nightly
securityContext:
privileged: true
args: ["./run_tests", "--system-booted", "--expected-users", "gardener"]After deployment, retrieve test results from pod logs:
kubectl logs testTo get JUnit Extensible Markup Language (XML) output, adjust the args and mount a volume:
args:
[
"./run_tests",
"--junit-xml",
"output/test.xml",
"--system-booted",
"--expected-users",
"gardener",
]:::note The ghcr.io/gardenlinux/test:nightly container is built and published daily to provide the most up-to-date variant of the test framework. Per-release variants will be available in future releases. :::
Common Command-Line Options
General Options
--help : Show help message and exit.
--skip-cleanup : Skip cleanup of cloud resources after testing.
- QEMU VM: Stop and cleanup the VM with
ctrl + cafter running or skipping tests. - Cloud: Re-run without the flag or use
--only-cleanupto clean up cloud resources.
--skip-tests : Skip running the actual test suite (useful for infrastructure setup only).
--test-args : Pass any command-line argument to pytest. Put multiple arguments inside "".
Example:
./test --test-args "test_ssh.py -v" .build/image.rawExamples
Run chroot tests on a tar image:
./test .build/aws-gardener_prod-amd64-today-13371337.tarRun OCI container tests on Base Image:
./test .build/container-amd64-today-local.ociRun QEMU tests with SSH access and skip cleanup:
./test --ssh --skip-cleanup .build/aws-gardener_prod-amd64-today-13371337.rawRun cloud tests on AWS, skipping cleanup:
./test --cloud aws --skip-cleanup .build/aws-gardener_prod-amd64-today-13371337.rawRun cloud tests but skip the test execution and cleanup:
./test --cloud aws --skip-tests --skip-cleanup .build/aws-gardener_prod-amd64-today-13371337.rawRun QEMU tests and only run test_ssh.py in verbose mode:
./test --test-args "test_ssh.py -v" .build/aws-gardener_prod-amd64-today-13371337.rawRun cloud tests, skip cleanup, and only run test_ssh.py and test_aws.py in verbose mode:
./test --cloud aws --skip-cleanup --test-args "test_ssh.py test_aws.py -v" .build/aws-gardener_prod-amd64-today-13371337.rawSpin up an existing cloud image using image requirements file:
./test --cloud aws --skip-cleanup --skip-tests --cloud-image \
--image-requirements-file .build/aws-gardener_prod-amd64-today-local.requirements \
ami-07f977508ed36098e