test-driven infrastructure with cloudformation and cucumber

21
COPYRIGHT © 2012 Stelligent Systems LLC Unauthorized duplication is not permitted. Test-Driven Infrastructure w/ CloudFormation and Cucumber Paul Duvall, Stelligent CTO Author of Continuous Integration and DevOps in the Cloud Tuesday, July 24, 2012 Stelligent Monthly Cloud Delivery Webinar Series

Upload: stelligent

Post on 30-Nov-2014

1.247 views

Category:

Technology


1 download

DESCRIPTION

Test-Driven Infrastructure with CloudFormation and Cucumber.

TRANSCRIPT

Page 1: Test-Driven Infrastructure with CloudFormation and Cucumber

COPYRIGHT © 2012 Stelligent Systems LLC Unauthorized duplication is not permitted.

Test-Driven Infrastructure w/ CloudFormation and Cucumber

Paul Duvall, Stelligent CTO Author of Continuous Integration and DevOps in the Cloud Tuesday, July 24, 2012

Stelligent Monthly Cloud Delivery Webinar Series

Page 2: Test-Driven Infrastructure with CloudFormation and Cucumber

COPYRIGHT © 2012 Stelligent Systems LLC Unauthorized duplication is not permitted.

Introduction

Stelligent

Linkedin

Next Webinar

August 28th: Scripted Deployment with Capistrano http://stelligent.com/cap with Brian Jakovich

Continuous Delivery in the Cloud: http://linkd.in/Pfbf1h

Cloud Delivery: Migration, Training and Operations

Materials Powerpoint and other resources will be emailed to attendees and available in Linkedin group

June Webinar

Recording of last month’s webinar: http://www.stelligent.com/aws-webinar/

Page 3: Test-Driven Infrastructure with CloudFormation and Cucumber

COPYRIGHT © 2012 Stelligent Systems LLC Unauthorized duplication is not permitted.

About Me

Page 4: Test-Driven Infrastructure with CloudFormation and Cucumber

COPYRIGHT © 2012 Stelligent Systems LLC Unauthorized duplication is not permitted.

Continuous Delivery

http://bit.ly/cdwebinar1

Page 5: Test-Driven Infrastructure with CloudFormation and Cucumber

COPYRIGHT © 2012 Stelligent Systems LLC Unauthorized duplication is not permitted.

Continuous Delivery

Page 6: Test-Driven Infrastructure with CloudFormation and Cucumber

COPYRIGHT © 2012 Stelligent Systems LLC Unauthorized duplication is not permitted.

Page 7: Test-Driven Infrastructure with CloudFormation and Cucumber

COPYRIGHT © 2012 Stelligent Systems LLC Unauthorized duplication is not permitted.

5 Steps to Continuous Delivery

Continuous

Document

Test

Version

Script

Document to automate

Write an automated test to verify behavior

Automate to a single command

Version all scripts

Run headless with every change

Page 8: Test-Driven Infrastructure with CloudFormation and Cucumber

COPYRIGHT © 2012 Stelligent Systems LLC Unauthorized duplication is not permitted.

Business Value of Test-Driven Infrastructure

•  Learn of problems earlier by integrating CI with infrastructure - Infrastructure changes integrated with rest of software system

•  Scripted Infrastructure becomes Documentation •  Remove Gatekeepers •  Isolate Destructive Changes •  Canonical System •  Quickly get back to earlier version of Infrastructure •  Infrastructure as Code: Apply rigorous practices

similar to writing application code

Page 9: Test-Driven Infrastructure with CloudFormation and Cucumber

COPYRIGHT © 2012 Stelligent Systems LLC Unauthorized duplication is not permitted.

Test-Driven Infrastructure within Delivery Pipeline

•  Manually Configure and Document Environment

•  Write Acceptance Test •  Script the Environment

provisioning •  Version the infrastructure

automation (Checkin the Script(s))

•  Run as part of a Continuous Process

•  Make “pre-baked” environments available to team members and CD system

Page 10: Test-Driven Infrastructure with CloudFormation and Cucumber

COPYRIGHT © 2012 Stelligent Systems LLC Unauthorized duplication is not permitted.

CI Server

Target Environment

Instances Version-Control

Repository

Sidebar: Continuous Integration Process

Developer

Tester

Operations

DBA

Polling

Create Environments

Deploy Build

Tests

Page 11: Test-Driven Infrastructure with CloudFormation and Cucumber

COPYRIGHT © 2012 Stelligent Systems LLC Unauthorized duplication is not permitted.

Test-Driven Infrastructure: Success

Jenkins Environment Job

Environment Email SSH

Working App Deployment Email

Page 12: Test-Driven Infrastructure with CloudFormation and Cucumber

COPYRIGHT © 2012 Stelligent Systems LLC Unauthorized duplication is not permitted.

Test-Driven Infrastructure: Failure •  Notified soon after

infrastructure script is committed to version-control repository

•  Since all infrastructure scripts and config are versioned, can simply revert to previous known-good version

•  Failure is identified, scripts are changed and committed back to version-control system

•  Infrastructure changes are integrated with rest of software system

Page 13: Test-Driven Infrastructure with CloudFormation and Cucumber

COPYRIGHT © 2012 Stelligent Systems LLC Unauthorized duplication is not permitted.

Non-Automated Test Scenario •  Environment is manually created by

running through a series of steps to install/configure OS, networking, servers, etc.

•  In some cases, these steps are documented. Often, the documentation is not regularly updated

•  New environments – based on the “initial environment” – are created by going through similar manual steps

•  No canonical state of environments – each environment is unique

•  Software is deployed to environments (Dev, QA, Stage, etc.). Deployments fail. Root cause is unclear.

•  Troubleshooting and patch work ensue. State remains dubious. Team members apply superstition to root cause.

Page 14: Test-Driven Infrastructure with CloudFormation and Cucumber

COPYRIGHT © 2012 Stelligent Systems LLC Unauthorized duplication is not permitted.

Sidebar: Test-Driven Development with JUnit

Page 15: Test-Driven Infrastructure with CloudFormation and Cucumber

COPYRIGHT © 2012 Stelligent Systems LLC Unauthorized duplication is not permitted.

Scripted Infrastructure (Code) •  Walkthrough of production.template CloudFormation template

Page 16: Test-Driven Infrastructure with CloudFormation and Cucumber

COPYRIGHT © 2012 Stelligent Systems LLC Unauthorized duplication is not permitted.

Cucumber BDD Basics

•  Philosophy •  Executable Specifications •  Continuous Traceability

•  Cucumber Components (1)

•  Business Facing •  Features •  Scenarios •  Steps

•  Technology Facing •  Step Definitions •  Support Code •  Automation Library •  Syntax Rules: Gherkin

From “The Cucumber Book” (Wynne and Hellesoy; Pragmatic Bookshelf, 2012)

Page 17: Test-Driven Infrastructure with CloudFormation and Cucumber

COPYRIGHT © 2012 Stelligent Systems LLC Unauthorized duplication is not permitted.

TDI BDD Components

Jenkins

Cucumber

CloudFormation

Step Definitions

Page 18: Test-Driven Infrastructure with CloudFormation and Cucumber

COPYRIGHT © 2012 Stelligent Systems LLC Unauthorized duplication is not permitted.

TDI Cucumber Examples

•  Walkthrough of production.feature Cucumber feature

Page 19: Test-Driven Infrastructure with CloudFormation and Cucumber

COPYRIGHT © 2012 Stelligent Systems LLC Unauthorized duplication is not permitted.

Other TDI Tools

•  Cucumber Nagios: http://auxesis.github.com/cucumber-nagios/ •  Cucumber Chef: http://www.cucumber-chef.org/

Page 20: Test-Driven Infrastructure with CloudFormation and Cucumber

COPYRIGHT © 2012 Stelligent Systems LLC Unauthorized duplication is not permitted.

Question and Answer

August Webinar

Blog

Social

Solutions

CD Video

http://www.stelligent.com/blog/

@stelligent @paulduvall facebook.com/Stelligent

http://bit.ly/cdwebinar1

http://www.stelligent.com/solutions/

http://www.stelligent.com/cap/

Training http://www.stelligent.com/cd-training/

Page 21: Test-Driven Infrastructure with CloudFormation and Cucumber

COPYRIGHT © 2012 Stelligent Systems LLC Unauthorized duplication is not permitted.

Infrastructure Components CloudFormation Template

Amazon Simple Notification Service

(SNS)

Elastic IP

Security Group IAM Route 53 EC2 SimpleDB

Config

Tomcat Apache HTTPD

Jenkins

Linux OS S3

Version-Control Repo Cucumber