Test orchestration
Test orchestration provides one Python entry point for running integration checks against several deployment forms. It prepares a clean test area, selects the environment adapter, runs scenario checks with shared rules, reports useful logs, and removes the temporary environment.
Runner scope
The runner treats each example as a named scenario and each environment as a separate execution mode. It reads the scenario's tests.json, checks whether the selected mode is allowed, then sends the scenario to the matching environment class (tests/main.py• L22-32, tests/main.py• L82-126).
The main execution modes are:
| Mode | System under test |
|---|---|
docker | A scenario-managed Docker Compose stack |
autoconf | A shared Autoconf Compose stack plus the scenario stack |
swarm | A Docker Swarm deployment |
kubernetes | A Kubernetes deployment |
linux | A package installed inside a distribution container |
The runner also accepts ansible as an input value, but tests/main.py has no normal setup or scenario dispatch branch for it. Infrastructure creation and removal use separate Terraform and Ansible scripts (tests/create.sh• L9-46, tests/rm.sh• L9-21).
References: tests/main.py• L22-32 tests/main.py• L82-126 tests/create.sh• L9-46 tests/rm.sh• L9-21
Execution selection
Scenario selection is data driven. A scenario declares its name, supported modes, timeout, optional start delay, optional data-copy rule, and a list of HTTP or TLS checks in examples/…/tests.json (examples/…/tests.json• L1-15). The runner executes matching scenarios in directory order and stops at the first failed scenario.
Each run creates temporary domain names from the test-domain environment values. This keeps parallel or repeated runs away from fixed public names while allowing scenario files to keep stable example names (tests/main.py• L56-80). The selected workflow supplies those values and starts one run for each requested environment or Linux distribution (.github/…/staging-tests.yml• L169-250). For the scenario definitions behind these executions, see Integration test scenarios.
References: examples/…/tests.json• L1-15 tests/main.py• L56-80 tests/main.py• L82-132 .github/…/staging-tests.yml• L169-250
Environment lifecycles
The environment adapters keep a common execution contract while changing how the product is started. Each adapter prepares its platform, waits for readiness, runs the selected scenarios, collects failure evidence, and removes platform resources.
The remaining adapters cover these deployment forms:
| Adapter | Lifecycle role |
|---|---|
AutoconfTest | Starts the shared Autoconf services, then starts each scenario's Autoconf stack (tests/AutoconfTest.py• L26-101, tests/AutoconfTest.py• L122-225). |
SwarmTest | Deploys the shared and scenario stacks, waits for services, and removes the stack and temporary resources (tests/SwarmTest.py• L18-129, tests/SwarmTest.py• L131-249). |
KubernetesTest | Applies the shared Kubernetes deployment, waits for healthy pods, then applies and removes scenario resources (tests/KubernetesTest.py• L18-193, tests/KubernetesTest.py• L195-249). |
References: tests/AutoconfTest.py• L26-225 tests/SwarmTest.py• L18-249 tests/KubernetesTest.py• L18-249
Logging and failure evidence
The logger writes timestamped, flushed lines with a component name and severity marker. Shared lifecycle events use the TEST label. Environment adapters use their own labels so startup, cleanup, and platform failures remain easy to separate in CI output (tests/logger.py• L1-6, tests/Test.py• L27-30).
Failure handling first records the failed assertion or exception. It then asks the active adapter to expose the system's logs: service logs for Swarm and pod logs for Kubernetes (tests/Test.py• L139-200, tests/SwarmTest.py• L239-249, tests/KubernetesTest.py• L242-249).
References: tests/logger.py• L1-6 tests/SwarmTest.py• L239-249 tests/KubernetesTest.py• L242-249
Change checklist
When these files or sections are changed, remember to consider these:
- Keep the mode names accepted by tests/main.py, the
kindsvalues in scenario files, and the workflow input values aligned. - Update both domain replacement and certificate-name expectations when a scenario changes its host names.
- Keep adapter cleanup when adding a new setup resource, because top-level failure paths depend on
end()after scenario failure. - Keep Linux distribution names aligned across package-image preparation and workflow matrix steps.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
A scenario omits the selected mode from kinds | The scenario is skipped without running its checks | Review tests.json mode lists when adding or changing a workflow mode |
| A test-domain value is missing | Generated URLs contain missing domain data and requests fail | Provide the domain variables before invoking tests/main.py |
| The environment does not become healthy during setup | The run stops before scenario checks and adapter diagnostics are printed | Check the platform stack health and its logs first |
ansible is passed to the Python runner | The input is accepted but no normal adapter runs | Use a supported runner mode or the separate provisioning scripts |
Key files
| File | Why to read it |
|---|---|
| tests/main.py | Defines command selection, scenario discovery, domain generation, and top-level cleanup. |
| tests/AutoconfTest.py | Shows the two-stack Autoconf test lifecycle. |
| tests/SwarmTest.py | Shows service readiness and cleanup for Docker Swarm. |
| tests/KubernetesTest.py | Shows cluster deployment, pod readiness, and resource cleanup. |
| examples/…/tests.json | Shows the scenario data contract for mode selection and checks. |
| .github/…/staging-tests.yml | Shows how CI selects modes, supplies domains, prepares images, and invokes the runner. |
| tests/logger.py | Defines the common timestamped log format. |