start unit testing your infrastructure now
play

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


  1. Software Development Done Right Start unit testing your infrastructure now! Eric Nieuwenhuijsen

  2. Start unit testing your infrastructure now! This presentation Testing practices applied to Infrastructure as Code What? Why? How? 2

  3. Start unit testing your infrastructure now! About you 3

  4. Start unit testing your infrastructure now! About me Eric Nieuwenhuijsen, 27, IT Architect @ Xebia Worked in various development and operation roles before and now as a consultant for Xebia 4

  5. Start unit testing your infrastructure now! What? Testing practices applied to infrastructure? Blasphemy! 5

  6. Start unit testing your infrastructure now! 6

  7. Start unit testing your infrastructure now! 7

  8. Start unit testing your infrastructure now! Datacenter automation Describing infrastructure as code Increasing velocity of infrastructure deployments by automating many previously manual steps A virtual machine might look like this resource "virtual_machine" "vm" { name = "eric-test" cpu = 2 mem = 4 image = "Centos7.2.1511" } 8

  9. Start unit testing your infrastructure now! Infrastructure testing So how do you test these things? Some example artifacts: 9

  10. Start unit testing your infrastructure now! We’ve all seen this UI testing UI testing Integration testing Integration testing Unit testing Unit testing 10

  11. Start unit testing your infrastructure now! The same applies to IaC testing E2E testing System testing Unit testing 11

  12. Start unit testing your infrastructure now! 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. 12

  13. Start unit testing your infrastructure now! In practice E2E testing System testing Unit testing 13

  14. Start unit testing your infrastructure now! Why? Ok this looks neat, but why would I spend time on it? 14

  15. Start unit testing your infrastructure now! Consumer driven 15 Image from: www.coolinary.nl

  16. Start unit testing your infrastructure now! Providers & consumers 16

  17. Start unit testing your infrastructure now! Use cases Validating promises of supplying party Consumer driven contract testing Validating merged configuration artifacts 17

  18. Start unit testing your infrastructure now! How? I can has moar code? 18

  19. Start unit testing your infrastructure now! 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.) 19

  20. Start unit testing your infrastructure now! 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 20

  21. Start unit testing your infrastructure now! Library pattern Infrastructure Application 21

  22. Start unit testing your infrastructure now! Demo time! 22

  23. Start unit testing your infrastructure now! Pipeline Base Stack App 23

  24. Start unit testing your infrastructure now! Setup Docker daemon Test Jenkins Serverspec subject Data volume 24

  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

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend