liveBook · Manning

Integration test

As explained in Infrastructure as Code, Patterns and Practices: With examples in Python and Terraform

Integration testing is the evaluation of interactions among multiple infrastructure resources or modules against expected configuration and behavior.

An integration test applies infrastructure modules or configuration to a testing environment, then dynamically checks whether multiple resources interact and reach the expected state. section 6.4

Use an infrastructure integration test to:

  • Render configuration when necessary and deploy the change to isolated or persistent test infrastructure. section 6.4.1 section 6.4.2
  • Query the infrastructure provider’s API and compare active resources with the intended IaC configuration. section 6.4.1
  • Verify creation, updates, configuration, dependencies, availability, or runtime state rather than duplicating a tool’s acceptance tests. section 6.4.3 section 6.8
  • Remove temporary resources after validation, or retain a persistent environment when creation is costly, dependency-heavy, or unsafe to repeat. section 6.4.1 section 6.4.3

Choose the lifecycle according to risk and dependency structure. Low-level modules such as networks or DNS often benefit from realistic in-place updates, while simpler modules can use create-test-delete runs. Persistent environments protect production when resources are long-lived, expensive, or hazardous to destroy. section 6.4.2 section 6.4.3

Combine integration tests with unit and contract tests for modules, or with unit and end-to-end tests for complex environment configurations. Run them after faster checks and before production delivery; remove unreliable or redundant tests. section 6.7.1 section 6.7.2 section 6.7.3

GCP server module

A Python test generates a server configuration, applies it to a testing environment, waits for provisioning, queries Google Cloud through Libcloud, and passes only when the server reports a running state. A fixture then destroys the server and removes its generated configuration. The demonstrated run completes four tests in about three minutes. section 6.4.1

Figure 6.10 Integration tests usually create and update infrastructure resources in a testing environment, test their configuration and status for correctness or availability, and remove them after the tests.

Use the lifecycle diagram to trace the standard create-or-update, verify, and cleanup flow. section 6.4.1

How Infrastructure as Code, Patterns and Practices: With examples in Python and Terraform covers it

How deep it goes
Explains deployment, provider-API comparison, lifecycle choices, and teardown, but defers provider-specific implementation details beyond examples.
Examples
Uses GCP server provisioning, DNS record validation, database deployment, pytest output, and persistent testing environments.
What it assumes
Assumes infrastructure-as-code modules, provider APIs, and testing environments, while distinguishing integration checks from unit, contract, and end-to-end tests.
What you can do after
Diagnose module or configuration failures by deploying test infrastructure, checking provider state, and validating resource interactions.
How it connects
Connects unit testing, contract testing, end-to-end testing, acceptance testing, testing environments, and continuous delivery.

Also explained in

Compare how 31 books explain integration test →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Infrastructure as Code, Patterns and Practices: With examples in Python and Terraform. The section links point to the parts of the book it draws on.