Start unit testing your infrastructure now! Eric Nieuwenhuijsen - - PowerPoint PPT Presentation

start unit testing your infrastructure now
SMART_READER_LITE
LIVE PREVIEW

Start unit testing your infrastructure now! Eric Nieuwenhuijsen - - PowerPoint PPT Presentation

Software Development Done Right Start unit testing your infrastructure now! Eric Nieuwenhuijsen Start unit testing your infrastructure now! This presentation Testing practices applied to Infrastructure as Code What? Why? How? 2 Start unit


slide-1
SLIDE 1

Software Development Done Right

Start unit testing your infrastructure now!

Eric Nieuwenhuijsen

slide-2
SLIDE 2

This presentation

Testing practices applied to Infrastructure as Code What? Why? How?

Start unit testing your infrastructure now!

2

slide-3
SLIDE 3

About you

Start unit testing your infrastructure now!

3

slide-4
SLIDE 4

About me

Eric Nieuwenhuijsen, 27, IT Architect @ Xebia Worked in various development and operation roles before and now as a consultant for Xebia

Start unit testing your infrastructure now!

4

slide-5
SLIDE 5

What?

Testing practices applied to infrastructure? Blasphemy!

Start unit testing your infrastructure now!

5

slide-6
SLIDE 6

Start unit testing your infrastructure now!

6

slide-7
SLIDE 7

Start unit testing your infrastructure now!

7

slide-8
SLIDE 8

Datacenter automation

Describing infrastructure as code Increasing velocity of infrastructure deployments by automating many previously manual steps A virtual machine might look like this

Start unit testing your infrastructure now!

8

resource "virtual_machine" "vm" { name = "eric-test" cpu = 2 mem = 4 image = "Centos7.2.1511" }

slide-9
SLIDE 9

Infrastructure testing

So how do you test these things? Some example artifacts:

Start unit testing your infrastructure now!

9

slide-10
SLIDE 10

We’ve all seen this

Start unit testing your infrastructure now!

10

Unit testing Integration testing UI testing Unit testing Integration testing UI testing

slide-11
SLIDE 11

The same applies to IaC testing

Start unit testing your infrastructure now!

11

Unit testing System testing E2E testing

slide-12
SLIDE 12

Testing of infrastructure

Effective testing of infrastructure units is notoriously hard You hardly have any conditionals to validate The merged ‘stack’ as an integration test is much more interesting as this often interleaves multiple layers into one ‘unit’ E.g. combining a Packer image template with Terraform files to spin up the instances.

Start unit testing your infrastructure now!

12

slide-13
SLIDE 13

In practice

Start unit testing your infrastructure now!

13

Unit testing System testing E2E testing

slide-14
SLIDE 14

Why?

Ok this looks neat, but why would I spend time on it?

Start unit testing your infrastructure now!

14

slide-15
SLIDE 15

Consumer driven

Start unit testing your infrastructure now!

15

Image from: www.coolinary.nl

slide-16
SLIDE 16

Providers & consumers

Start unit testing your infrastructure now!

16

slide-17
SLIDE 17

Use cases

Validating promises of supplying party Consumer driven contract testing Validating merged configuration artifacts

Start unit testing your infrastructure now!

17

slide-18
SLIDE 18

How?

I can has moar code?

Start unit testing your infrastructure now!

18

slide-19
SLIDE 19

Describing infrastructure

Three main categories of artifacts

  • Configuration definitions (Puppet, Ansible, etc.)
  • Machine images (AWS AMI’s, Docker images, etc.)
  • Resource specifications (Terraform, AWS CloudFormation, etc.)

Start unit testing your infrastructure now!

19

slide-20
SLIDE 20

Pitfall: Restating definitions

Consider the following Dockerfile FROM centos:centos7.2.1511 RUN yum install -y epel-release \ && yum install -y nginx What added benefit does the following spec have? describe "Dockerfile" do describe package('nginx') do it { should be_installed } end end

Start unit testing your infrastructure now!

20

slide-21
SLIDE 21

Library pattern

Start unit testing your infrastructure now!

21

Infrastructure Application

slide-22
SLIDE 22

Demo time!

Start unit testing your infrastructure now!

22

slide-23
SLIDE 23

Pipeline

Start unit testing your infrastructure now!

23

Base App Stack

slide-24
SLIDE 24

Setup

Start unit testing your infrastructure now!

24

Jenkins Docker daemon Serverspec Test subject Data volume

slide-25
SLIDE 25

Software Development Done Right

Any questions?

The code is available on Github https://github.com/enieuw/twc-demo-pipeline

Eric Nieuwenhuijsen / enieuwenhuijsen@xebia.com