Skip to content

test: add Docker-based test suite for setup scripts#2

Open
hermes-denkobot wants to merge 1 commit into
julweber:mainfrom
hermes-denkobot:feat/docker-test-suite
Open

test: add Docker-based test suite for setup scripts#2
hermes-denkobot wants to merge 1 commit into
julweber:mainfrom
hermes-denkobot:feat/docker-test-suite

Conversation

@hermes-denkobot

Copy link
Copy Markdown

Summary

Adds a Docker-based integration test suite for the machine setup automation scripts. Every test runs inside a disposable Ubuntu 24.04 container with systemd — zero impact on the host system.

Features

  • Container lifecycle management — Reusable functions to create, manage, and destroy test containers
  • Assertion library — Functions for checking packages, services, config files, and group membership
  • Idempotency testing — Framework that runs each script twice to verify idempotency
  • Integration tests for: setup-basics, setup-docker, setup-sshd, configure-firewall
  • BATS unit tests for the shared helpers library
  • ShellCheck static analysis in the main runner

Test Architecture

tests/
├── lib/
│   ├── container-manager.sh   # Container lifecycle
│   └── test-helpers.sh        # Assertion library
├── unit/
│   └── test-helpers.bats      # BATS unit tests
└── integration/
    ├── test-basics.sh
    ├── test-docker.sh
    ├── test-sshd.sh
    └── test-firewall.sh

Usage

./tests/run-all.sh              # Run everything
./tests/run-integration.sh test-docker   # Single test
./tests/run-all.sh unit         # Static analysis only

How It Works

  1. Spins up a fresh ubuntu:24.04 --privileged container with systemd
  2. Copies the repo into the container
  3. Creates a test user with passwordless sudo
  4. Runs the setup script
  5. Asserts: packages installed, services running, config correct
  6. Runs the script a second time to verify idempotency
  7. Tears down the container (logs captured on failure)

- Container lifecycle management with systemd support
- Assertion library for package, service, config, and group checks
- Idempotency test framework (runs scripts twice per test)
- Integration tests: setup-basics, setup-docker, setup-sshd, configure-firewall
- BATS unit tests for helpers.sh
- ShellCheck static analysis in run-all.sh

Tests run in disposable Ubuntu 24.04 containers — zero host impact.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant