Getting Started with Test Driven Infrastructure - SCaLE 14x

64
GETTING STARTED w/ TDI

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

Page 1: Getting Started with Test Driven Infrastructure - SCaLE 14x

GETTING STARTED w/ TDI

Page 2: Getting Started with Test Driven Infrastructure - SCaLE 14x

Hello!I AM CARLOS MEZA

Sysadmin that wants todo things better.

[email protected]@digitalr00ts

Page 3: Getting Started with Test Driven Infrastructure - SCaLE 14x

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

Page 4: Getting Started with Test Driven Infrastructure - SCaLE 14x

1.TEST DRIVEN INFRASTRUCTURE

Why TDI?

Page 5: Getting Started with Test Driven Infrastructure - SCaLE 14x

WHY TDI

TDI applies agile developmentto infrastructure.

○Minimizes Risk○Builds Confidence○Maintains Focus

Page 6: Getting Started with Test Driven Infrastructure - SCaLE 14x

WHY TDI

TDI applies agile developmentto infrastructure.

○Verifiable Behavior - Consistency○Increased Code Quality - Confidence

○Safe Refactoring - Speed○Improved Design - Adaptability

Page 7: Getting Started with Test Driven Infrastructure - SCaLE 14x

SYSADMIN ANTI-PATTERNS

Issues with systemdeployment and maintenance

○Lack of Process○Manual Process○Poor Code

Page 8: Getting Started with Test Driven Infrastructure - SCaLE 14x

2.Configuration Management

Infrastructure As Code

Page 9: Getting Started with Test Driven Infrastructure - SCaLE 14x

CONFIGURATION MANAGEMENT

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

○Visibility○Reliability○Productivity○Scalability

Page 10: Getting Started with Test Driven Infrastructure - SCaLE 14x

CHEF WORKFLOW

Page 11: Getting Started with Test Driven Infrastructure - SCaLE 14x

TOOL OPTIONS

○Puppet○Chef○Salt○Ansible

Page 12: Getting Started with Test Driven Infrastructure - SCaLE 14x

CHEF RECIPE EXAMPLE

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

Page 13: Getting Started with Test Driven Infrastructure - SCaLE 14x

CM SHORTCOMINGS

CM does not prevent badinfrastructure code

○Incomplete Code○Unclear Code○Unintended Consequences

Page 14: Getting Started with Test Driven Infrastructure - SCaLE 14x

3.TEST / BEHAVIORDRIVEN DEVELOPMENT

Principles and Methods

Page 15: Getting Started with Test Driven Infrastructure - SCaLE 14x

TESTDRIVEN DEVELOPMENT

A framework tomanage evolving environments with

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

Page 16: Getting Started with Test Driven Infrastructure - SCaLE 14x

BEHAVIORDRIVEN DEVELOPMENT

Facilitates collaboration between stakeholders and developers by

describing requirements as system behaviors.

○Business Values Prioritized○Tests are Documentation○Improves Communication

Page 17: Getting Started with Test Driven Infrastructure - SCaLE 14x

SERVERSPEC EXAMPLE

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

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

Page 18: Getting Started with Test Driven Infrastructure - SCaLE 14x

RED, GREEN, REFACTOR

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

Page 19: Getting Started with Test Driven Infrastructure - SCaLE 14x

4.CONTINUOUS INTEGRATION

Automating Failure

Page 20: Getting Started with Test Driven Infrastructure - SCaLE 14x

CONTINUOUS INTEGRATION

A practice with short development cycles, automated testing and

code integration

○Detect Issues Sooner○Faster to Implement

Page 21: Getting Started with Test Driven Infrastructure - SCaLE 14x

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)

Page 22: Getting Started with Test Driven Infrastructure - SCaLE 14x

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

1

Page 23: Getting Started with Test Driven Infrastructure - SCaLE 14x

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

2

Page 24: Getting Started with Test Driven Infrastructure - SCaLE 14x

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

35

4

Page 25: Getting Started with Test Driven Infrastructure - SCaLE 14x

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

6

Page 26: Getting Started with Test Driven Infrastructure - SCaLE 14x

TOOL OPTIONS

○Jenkins○Travis CI○Go (ThoughtWorks)

Page 27: Getting Started with Test Driven Infrastructure - SCaLE 14x

CODE REVIEW

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

Page 28: Getting Started with Test Driven Infrastructure - SCaLE 14x

CODE REVIEW

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

Page 29: Getting Started with Test Driven Infrastructure - SCaLE 14x

TOOL ASSISTED OPTIONS

○Garret○Review Board○Phabricator

Page 30: Getting Started with Test Driven Infrastructure - SCaLE 14x

5.TEST DRIVEN INFRASTRUCTURE

Agile Infrastructure

Page 31: Getting Started with Test Driven Infrastructure - SCaLE 14x

PRINCIPLES AND PRACTICES

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

Page 32: Getting Started with Test Driven Infrastructure - SCaLE 14x

TDI WORKFLOWFORK

Page 33: Getting Started with Test Driven Infrastructure - SCaLE 14x

TDI WORKFLOWCODE

Page 34: Getting Started with Test Driven Infrastructure - SCaLE 14x

TDI WORKFLOWCOMMIT

Page 35: Getting Started with Test Driven Infrastructure - SCaLE 14x

TDI WORKFLOWTEST TRIGGERED

Page 36: Getting Started with Test Driven Infrastructure - SCaLE 14x

TDI WORKFLOWTEST JOB

Page 37: Getting Started with Test Driven Infrastructure - SCaLE 14x

TDI WORKFLOWINTEGRATION TEST

Page 38: Getting Started with Test Driven Infrastructure - SCaLE 14x

TDI WORKFLOWFEEDBACK

Page 39: Getting Started with Test Driven Infrastructure - SCaLE 14x

TDI WORKFLOWPULL REQUEST

Page 40: Getting Started with Test Driven Infrastructure - SCaLE 14x

TDI WORKFLOWTO CODE REVIEW

Page 41: Getting Started with Test Driven Infrastructure - SCaLE 14x

6.CONTINUOUS DELIVERY

Delivering to staging environments

Page 42: Getting Started with Test Driven Infrastructure - SCaLE 14x

CONTINUOUS DELIVERY

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

Page 43: Getting Started with Test Driven Infrastructure - SCaLE 14x

CD WORKFLOWCOMMIT PULL REQUEST

Page 44: Getting Started with Test Driven Infrastructure - SCaLE 14x

CD WORKFLOWTEST TRIGGERED

Page 45: Getting Started with Test Driven Infrastructure - SCaLE 14x

CD WORKFLOWTEST JOB

Page 46: Getting Started with Test Driven Infrastructure - SCaLE 14x

CD WORKFLOWiNTEGRATION TEST

Page 47: Getting Started with Test Driven Infrastructure - SCaLE 14x

CD WORKFLOWFEEDBACK

Page 48: Getting Started with Test Driven Infrastructure - SCaLE 14x

CD WORKFLOWDELIVER

Page 49: Getting Started with Test Driven Infrastructure - SCaLE 14x

7.CONTINUOUS DEPLOYMENT

Automating to Production

Page 50: Getting Started with Test Driven Infrastructure - SCaLE 14x

CONTINUOUS DEPLOYMENT

Automating acceptance testing to promote code through pre-productions

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

Page 51: Getting Started with Test Driven Infrastructure - SCaLE 14x

CD WORKFLOW

Dev Staging Prod

Page 52: Getting Started with Test Driven Infrastructure - SCaLE 14x

CD WORKFLOW

Dev Staging Prod

Page 53: Getting Started with Test Driven Infrastructure - SCaLE 14x

CD WORKFLOW

Dev Staging Prod

Page 54: Getting Started with Test Driven Infrastructure - SCaLE 14x

CD WORKFLOW

Dev Staging Prod

Manual(Continuous

Delivery)

Page 55: Getting Started with Test Driven Infrastructure - SCaLE 14x

TOOL OPTIONS

Jenkins Plugins:○Workflow○Pipelines

Chef○Delivery Truck

○Go (ThoughtWorks)

Page 56: Getting Started with Test Driven Infrastructure - SCaLE 14x

8.CHALLENGES

This Will All Fail

Page 57: Getting Started with Test Driven Infrastructure - SCaLE 14x

CHALLENGES

Cultural shift○Workflow Changes○Time Investment○Full Adoption

Page 58: Getting Started with Test Driven Infrastructure - SCaLE 14x

CHALLENGES

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

Page 59: Getting Started with Test Driven Infrastructure - SCaLE 14x

9.CONCLUSION

Wrap It Up

Page 60: Getting Started with Test Driven Infrastructure - SCaLE 14x

Conclusion

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

Page 61: Getting Started with Test Driven Infrastructure - SCaLE 14x

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/

Page 62: Getting Started with Test Driven Infrastructure - SCaLE 14x

SOURCES ANDMORE INFORMATION

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

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

Page 63: Getting Started with Test Driven Infrastructure - SCaLE 14x

THANKS!Special thank you toNed Harris of Chef.io

Page 64: Getting Started with Test Driven Infrastructure - SCaLE 14x

FOLLOWME

@[email protected]