5 Testing

 

This chapter covers

  • Identifying which type of tests to write for infrastructure systems
  • Writing tests to verify infrastructure configuration or modules
  • Understanding the cost of different types of tests

Recall from Chapter 1 that infrastructure as code involves an entire process to push a change to a system. You update scripts or configurations with infrastructure changes, push them to a version control system, and apply the changes in an automated way. How do you know that the change worked? You can use all of the patterns for modules and dependency management from the last two chapters, but they won’t guarantee that every change you make will succeed! This chapter reviews some considerations and concepts related to testing infrastructure as code to reduce the rate of change failure and build confidence in infrastructure changes.

The most straightforward form of infrastructure testing involves manually checking configuration. Imagine you configure a network switch with a new network segment. How do you know you didn’t break existing networks and the new network connects successfully? You can test existing networks by pinging each server on each network and verifying their connectivity. To test if you set up the new network correctly, you create a new server on the network and check if it responds when you connect to it.

5.1 The infrastructure testing cycle

 
 
 
 

5.1.1 Static analysis

 
 

5.1.2 Dynamic analysis

 
 
 

5.1.3 Infrastructure testing environments

 
 
 
 

5.2 Unit tests

 
 
 
 

5.2.1 Testing infrastructure configuration

 
 
 

5.2.2 Testing domain-specific languages

 
 
 

5.2.3 When should you write unit tests?

 
 
 

5.3 Contract tests

 

5.4 Integration tests

 
 

5.4.1 Testing modules

 
 
 

5.4.2 Testing configuration for environments

 
 
 

5.4.3 Testing challenges

 

5.5 End-to-end tests

 
 

5.6 Other tests

 
 

5.7 Choosing tests

 

5.8 Summary

 
 
 
sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage
test yourself with a liveTest