Infrastructure Testing with Serverspec


3 students completed the lab in ~27m

Total available time: 45m

Be the first to rate this lab!

Lab Overview

An important principle in DevOps is to test your infrastructure. The tests should run as part of your continuous delivery pipeline giving you agility and confidence in your infrastructure changes. Serverspec is one example of an infrastructure testing framework. Serverspec can be used to test local and remote target machines by connecting over SSH or WinRM.

This Lab illustrates how to perform Infrastructure Testing with Serverspec. You will write Serverspec tests to specify the expected behavior of machines running in the reverse-proxy, load-balancing tier and the application tier of a sample application. The tests illustrate how to describe the expected behavior of servers and Docker containers. You will run the tests using Serverspec at the command-line and in a Docker container.

Lab Objectives

Upon completion of this Lab, you will be able to:

  • Understand where automated infrastructure testing fits into DevOps
  • Initialize Serverspec infrastructure test suites
  • Write Serverspec tests for a variety of Serverspec resources including packages, services, ports, and Docker infrastructure
  • Run Serverspec from the command line and in a Docker container

Lab Prerequisites

You should be familiar with:

  • A programming language. Ruby familiarity is most beneficial, but not required.
  • Basic Docker concepts, such as images and containers
  • Basic Linux concepts, such as the command line, processes, packages, and services

Lab Environment

Before completing the Lab instructions, the environment will look as follows:

After completing the Lab instructions, the environment should look similar to:

Follow these steps to learn by building helpful cloud resources

Logging in to the Amazon Web Services Console

Your first step to start the Lab experience

Opening the AWS Cloud9 IDE

Open the AWS Cloud9 browser-based Integrated Development Environment (IDE)

Running a Local Serverspec Test Suite

Initialize a Serverspec test suite to run against the development machine

Testing Remote Infrastructure with Serverspec

Learn how to run Serverspec tests against remote infrastructure

Testing Docker Infrastructure With Serverspec

Test Docker containers and images using Serverspec

Running Serverspec in a Docker Container

Learn how to run Serverspec tests from a Docker container