Testinit provides isolated provisioning tests and systemd-based E2E tests. Both use shared mock Azure Instance Metadata Service (IMDS) and WireServer handlers.
Warning
Running the ./start-all.sh script will modify your local machine due to how systemd in Docker works! Whenever possible, do not run this system on your personal machine as it completes the full provisioning run found in azure-init. This may affect your local hostname, ssh keys, users, or more. Exercise caution running this system locally!
This project consists of:
- Isolated Tests: The real Cargo-built agent running with stubbed OS commands in disposable, unprivileged containers
- Provisioning Agent: A systemd-based service running the
azure-initbinary in a privileged container - Testing Server: A mock Azure service providing IMDS and WireServer endpoints
The setup creates two Docker networks with Azure-like IP addresses:
imds-network(169.254.0.0/16) - For IMDS communicationwireserver-network(168.63.0.0/16) - For WireServer communication
- Docker and Docker Compose
- WSL2 or Linux environment
- Python 3, Rust, and libudev development headers for isolated tests
The Cargo test runs the real agent with stubbed OS commands and shared mock services, without the privileged Compose setup. From the repository root on Ubuntu:
python3 -B -m unittest discover -s testinit/testing-server -p 'test_*.py' -v
. /etc/os-release
docker build --build-arg "BASE_IMAGE=ubuntu:${VERSION_ID}" \
-f testinit/Dockerfile.isolated -t azure-init-main-tests:local testinit
cargo test --locked --all-features --package azure-init --test testinit \
-- --ignored agent_provisioning_in_containerThis Docker-dependent test is ignored by default. The coverage workflow runs it and uploads combined coverage to Codecov.
Run the start script to launch both services:
./start-all.shThis will:
- Start the testing server container first (creates networks with Azure IP addresses)
- Wait for the testing server to be ready
- Start the provisioning agent
The start-all.sh script also accepts an optional base image parameter for the Azure-init container.
./start-all.sh debian:12Without a base container image argument, start-all defaults to Ubuntu 24.04.
The list of currently tested images can be found in the e2e testing workflow.
Stop all services and clean up:
./stop-all.shThis will:
- Stop the provisioning agent container
- Stop the testing server container
- Remove orphaned containers
- Clean up Docker networks
- Container:
azureinit-provisioning-agent - Image: Built from local Dockerfile
- Service: systemd-based
azure-init.service - Privileges: Runs with
privileged: truefor systemd support - Binary Location: In the container, located at
/usr/bin/azure-init
- Container:
azure-testing-server - Endpoints:
- IMDS:
http://169.254.169.254/metadata/instance - WireServer:
http://168.63.129.16
- IMDS:
- Port: 80 (mapped to host)
Provisioning Agent:
docker compose logs -f provisioning-agentTesting Server:
cd testing-server
docker compose logs -f testing-serverThe systemd Dockerfile builds the repository source with
cargo build and installs azure-init.service.
The isolated Dockerfile contains only the fixture runtime
and shared mock handlers; its agent binary is mounted by the Cargo test.