Getting Started with Test Driven Infrastructure - SCaLE 14x

Post on 23-Jan-2017

233 views 3 download

Transcript of Getting Started with Test Driven Infrastructure - SCaLE 14x

GETTING STARTED w/ TDI

Hello!I AM CARLOS MEZA

Sysadmin that wants todo things better.

Carlos@digitalr00ts.com@digitalr00ts

ROADMAP

My journey learning TDI1. The Promise of TDI2. Configuration

Management3. Principles of Test

and Behavior Driven Development

4. Continuous Integration

5. Test Driven Infrastructure

6. Continuous Delivery

7. Continuous Deployment

8. Challenges

1.TEST DRIVEN INFRASTRUCTURE

Why TDI?

WHY TDI

TDI applies agile developmentto infrastructure.

○Minimizes Risk○Builds Confidence○Maintains Focus

WHY TDI

TDI applies agile developmentto infrastructure.

○Verifiable Behavior - Consistency○Increased Code Quality - Confidence

○Safe Refactoring - Speed○Improved Design - Adaptability

SYSADMIN ANTI-PATTERNS

Issues with systemdeployment and maintenance

○Lack of Process○Manual Process○Poor Code

2.Configuration Management

Infrastructure As Code

CONFIGURATION MANAGEMENT

CM ensures that a system is in aknown, good, and trusted state

○Visibility○Reliability○Productivity○Scalability

CHEF WORKFLOW

TOOL OPTIONS

○Puppet○Chef○Salt○Ansible

CHEF RECIPE EXAMPLE

package 'explicit_action' do action :removeendpackage 'with_attributes' do version '1.0.0' action :removeend

CM SHORTCOMINGS

CM does not prevent badinfrastructure code

○Incomplete Code○Unclear Code○Unintended Consequences

3.TEST / BEHAVIORDRIVEN DEVELOPMENT

Principles and Methods

TESTDRIVEN DEVELOPMENT

A framework tomanage evolving environments with

highly reliable and maintainable code.○Maintains Scope○Faster Feedback○Reduces Risk andBuilds Trust

BEHAVIORDRIVEN DEVELOPMENT

Facilitates collaboration between stakeholders and developers by

describing requirements as system behaviors.

○Business Values Prioritized○Tests are Documentation○Improves Communication

SERVERSPEC EXAMPLE

describe port(80) do it { should be_listening }end

describe command("lsb_release -d") do it { should return_stdout /wheezy/ }end

RED, GREEN, REFACTOR

http://www.agileapps.co.uk/methodology/continuous.html

4.CONTINUOUS INTEGRATION

Automating Failure

CONTINUOUS INTEGRATION

A practice with short development cycles, automated testing and

code integration

○Detect Issues Sooner○Faster to Implement

TESTING

Unit TestVerifies that individual parts of your code continue to work (Pre-Convergence)Integration TestVerifies the end state of the system post integration (Post-Convergence)

CI WORKFLOWhttps://insights.sei.cmu.edu/devops/2015/01/continuous-integration-in-devops-1.html

1

CI WORKFLOWhttps://insights.sei.cmu.edu/devops/2015/01/continuous-integration-in-devops-1.html

2

CI WORKFLOWhttps://insights.sei.cmu.edu/devops/2015/01/continuous-integration-in-devops-1.html

35

4

CI WORKFLOWhttps://insights.sei.cmu.edu/devops/2015/01/continuous-integration-in-devops-1.html

6

TOOL OPTIONS

○Jenkins○Travis CI○Go (ThoughtWorks)

CODE REVIEW

http://explosm.net/comics/2083/

CODE REVIEW

Peer review of source code○Readability○Maintainability○Knowledge Sharing

TOOL ASSISTED OPTIONS

○Garret○Review Board○Phabricator

5.TEST DRIVEN INFRASTRUCTURE

Agile Infrastructure

PRINCIPLES AND PRACTICES

○Document - Requirements○Test - Describe behavior○Script - Code to pass test○Audit - Version control○Continuous - Automatically test and integrate changes

TDI WORKFLOWFORK

TDI WORKFLOWCODE

TDI WORKFLOWCOMMIT

TDI WORKFLOWTEST TRIGGERED

TDI WORKFLOWTEST JOB

TDI WORKFLOWINTEGRATION TEST

TDI WORKFLOWFEEDBACK

TDI WORKFLOWPULL REQUEST

TDI WORKFLOWTO CODE REVIEW

6.CONTINUOUS DELIVERY

Delivering to staging environments

CONTINUOUS DELIVERY

A practice of delivering every change to a production-like environment.○Increases Ability to Adapt○Increases Reliability○Lowers Risk○Faster to Production

CD WORKFLOWCOMMIT PULL REQUEST

CD WORKFLOWTEST TRIGGERED

CD WORKFLOWTEST JOB

CD WORKFLOWiNTEGRATION TEST

CD WORKFLOWFEEDBACK

CD WORKFLOWDELIVER

7.CONTINUOUS DEPLOYMENT

Automating to Production

CONTINUOUS DEPLOYMENT

Automating acceptance testing to promote code through pre-productions

environments to production.○Quicker Return on Investment○Faster Client Feedback

CD WORKFLOW

Dev Staging Prod

CD WORKFLOW

Dev Staging Prod

CD WORKFLOW

Dev Staging Prod

CD WORKFLOW

Dev Staging Prod

Manual(Continuous

Delivery)

TOOL OPTIONS

Jenkins Plugins:○Workflow○Pipelines

Chef○Delivery Truck

○Go (ThoughtWorks)

8.CHALLENGES

This Will All Fail

CHALLENGES

Cultural shift○Workflow Changes○Time Investment○Full Adoption

CHALLENGES

Poor Testing○Lack of Understanding○Overlooking Test Parameters○Trivial Tests

9.CONCLUSION

Wrap It Up

Conclusion

○Improves Reliability○Increases Speed○Increases in Productivity○Adaptability○Reduces Cost

SOURCES ANDMORE INFORMATION

○5 Things About Configuration Management Your Boss Needs To Knowhttps://www.scriptrock.com/blog/5-configuration-management-boss

○Overview of Test Driven Infrastructure with Chefhttps://www.chef.io/blog/2015/04/21/overview-of-test-driven-infrastructure-with-chef/

○Agile DevOps: Test-driven infrastructurehttp://www.ibm.com/developerworks/library/a-devops5/

SOURCES ANDMORE INFORMATION

○Guide to Agile Practices - http://guide.agilealliance.org

○ThoughtWorks Insights on CDhttps://www.thoughtworks.com/insights/continuous-delivery

THANKS!Special thank you toNed Harris of Chef.io

FOLLOWME

@digitalr00tsCarlos@digitalr00ts.com