SlideShare a Scribd company logo
W11	
  
DevOps	
  &	
  Testing	
  
5/4/16	
  13:45	
  
Continuous	
  Integration	
  Testing	
  
Techniques	
  to	
  Improve	
  Chef	
  Cookbook	
  
Quality	
  
Presented	
  by:	
  
Glenn	
  Buckholz	
  
Coveros,	
  Inc.	
  
Brought	
  to	
  you	
  by:	
  	
  
350	
  Corporate	
  Way,	
  Suite	
  400,	
  Orange	
  Park,	
  FL	
  32073	
  
888-268-8770 904-278-0524 info@techwell.com http://www.stareast.techwell.com/
Glenn	
  Buckholz	
  
Coveros,	
  Inc.	
  
With	
  fifteen	
  years	
  of	
  industry	
  experience,	
  Glenn	
  Buckholz	
  leads	
  continuous	
  
integration	
  and	
  deployment	
  automation	
  efforts	
  at	
  Coveros.	
  His	
  career	
  began	
  as	
  a	
  
consultant	
  implementing	
  automated	
  test	
  frameworks	
  and	
  introducing	
  the	
  
concept	
  of	
  change	
  management	
  to	
  many,	
  many	
  projects.	
  Glenn	
  then	
  decided	
  to	
  
become	
  a	
  part	
  of	
  honest	
  society	
  and	
  settled	
  down	
  at	
  the	
  Public	
  Company	
  
Accounting	
  Oversight	
  Board	
  as	
  their	
  full8 time	
  enterprise	
  change	
  manager.	
  
Several	
  years	
  later,	
  he	
  joined	
  Coveros,	
  where	
  he	
  specializes	
  in	
  implementing	
  agile	
  
practices	
  and	
  CI,	
  and	
  engineering	
  configuration	
  management	
  instead	
  of	
  simply	
  
documenting	
  it.	
  
© Copyright 2016 Coveros, Inc. All rights reserved.
Continuous Integration Testing
Techniques to Improve Chef
Cookbook Quality
STAREAST – 04 May 2016
Glenn Buckholz
glenn.buckholz@coveros.com
© Copyright 2016 Coveros, Inc. All rights reserved.
Agenda
•What did I do?
•What is problem?
•What are the needs?
•Demo
•Architecture
•Workflow
•Testing Techniques and Tools
•Metrics?
•Docker and Cloud
•Discussion
© Copyright 2016 Coveros, Inc. All rights reserved.
What did I do?
● Used a modern CI/CD toolchain to apply
continuous integration testing techniques to
Chef code (CI):
○ Static analysis
○ Chefspec testing
○ Automated Functional Testing
● Introduces the idea of automatically making
cookbooks available when they are ready
(CD).
○ There is still a human gate between
available and in use by way of version
pinning.
© Copyright 2016 Coveros, Inc. All rights reserved.
What is the problem?
● Infrastructure as Code is currently the wild
west with little formal testing methodology.
● Chef lacks coherent CM on its own.
○ Cookbook versions and freezing are not
enough.
● No quick way to advance a piece of
infrastructure from one state to another and
back for purposes of testing.
● No minimal standards and requirements on
cookbook functionality.
© Copyright 2016 Coveros, Inc. All rights reserved.
What are the needs?
YOU ARE CHANGING THE TIRE AT
55MPH AND CAN’T STOP!!!
● Find flaws early.
● Ability to test pieces of an architecture
without having to have a whole system.
○ Unit testing system components.
● Simulate the effect of a deploy on a running
system.
● Dashboarding so you can trend code
quality.
© Copyright 2016 Coveros, Inc. All rights reserved.
Definitions
● Hands Off Deploy - Deployment that is
completely driven by Chef or some other
infrastructure tool.
● Static Analysis - evaluation of the code
without execution.
● Feedback loop - The events between when
a developer commits their code and results
can be observed.
● Application Code - The custom or home
grown software the current IT organization
is curating.
© Copyright 2016 Coveros, Inc. All rights reserved.
Demo
© Copyright 2016 Coveros, Inc. All rights reserved.
Architecture
Local Git Branch
Chefspec
Test Kitchen
Food Critic
Developer Workstation
Docker
Container
Binary Repository
Docker
Repository
Local Testing
Docker
Container
Upload Cookbook
© Copyright 2016 Coveros, Inc. All rights reserved.
Workflow
1. Clone master branch on the developer
machine.
2. Make changes and run static analysis.
3. Run Chefspec and test kitchen locally on a
docker container.
4. Push changes to remote branch.
5. Jenkins detects changes and checks out
branch onto a slave node.
© Copyright 2016 Coveros, Inc. All rights reserved.
Workflow
6. Jenkins merges the code with master
locally.
7. Chef reruns the static analysis.
8. Chef reruns Chefspec and test kitchen.
9. Results and metrics are recorded.
10.Successful tests see code merged into
master.
11.Cookbooks are uploaded to the chef
server.
12.After the code is executed in production,
AMI and Docker containers are
automatically updated from production.
Steps 8-9
automate
integration
testing
© Copyright 2016 Coveros, Inc. All rights reserved.
Reuse of well known patterns
● Feature Branches
○ Small bite sized changes.
● Automated Merging
○ Let the Jenkins objectively merge the
code after certain minimum standards are
achieved by the developer.
● Local tests that mirror a golden standard
○ Give the developers a cheat sheet.
● Short feedback loops.
● Auto Promotion
○ Let Jenkins keep the working cookbooks
in sync with SCM
Smaller changes are
more likely to make it
through the pipeline.
© Copyright 2016 Coveros, Inc. All rights reserved.
Testing Techniques
● Tabula Rasa
○ Start with a base image
○ Apply Security Hardening
○ Install stack fresh
○ Deploy application code
○ Run tests
● Production Approximation
○ Start with a clone from production
○ Run cookbooks
■ Only changes are executed
○ Run test
© Copyright 2016 Coveros, Inc. All rights reserved.
Testing Techniques
● Test in parallel
○ Do not block on critical resources clone
them.
○ VMs and containers are cheap, create
one for every commit you want to test.
○ Make unit and integration test cases
isolated. (Script system state for each
test case do not rely on other tests)
● Test local
○ Very short feedback loop for developers.
○ Reduces most pipeline failures to
integration errors.
© Copyright 2016 Coveros, Inc. All rights reserved.
Testing Tools
● Unit Testing
○ chefspec - extension of Rspec
● Functional Testing
○ BATS or chefspec
● Static Analysis
○ Foodcritic - lint like
● Git hooks
○ Make certain static tests run as a git hook
making them prerequisites to commit or
push.
© Copyright 2016 Coveros, Inc. All rights reserved.
Testing Tools
● Git Branching
○ Let the branch name decide if the CI
stack will run the changes.
○ You may want to use a prefix CI-
branchname
© Copyright 2016 Coveros, Inc. All rights reserved.
Testing Tools - Jenkins Master
● Jenkins master only monitors git.
○ Container on slave in the cloud for quick
tests.
○ VMs in cloud for executing tests in a
production like system.
■ Template AMI matches target machine.
○ All “work” takes place off the master to allow
testing in parallel.
● Create Jenkins jobs to capture production
templates post deployment. (AMI or docker
image)
© Copyright 2016 Coveros, Inc. All rights reserved.
Testing Tools - Developer Workstation
● Provide an easy to install package that includes:
○ Tools - Chefspec, Foodcritic, etc…
○ Docker settings.
○ Access to a docker repository.
○ Templates to create new cookbooks
● Enough memory and CPU to run the tools.
● DO NOT ALLOW COOKBOOK UPLOAD PRIVILEGES!!!!!
● DO NOT ALLOW MERGE TO MASTER PRIVILEGES!!!!!
● The ability for a developer to find mistakes locally is the
most cost effective testing technique available to an
organization. (Short Feedback Loop)
© Copyright 2016 Coveros, Inc. All rights reserved.
Transitioning to the CI Approach
● From the previous slides we have the tools to create
an method for retrofitting a CI driven approach to an
existing Chef infrastructure.
● On a separate branch create cookbooks that install
a piece of the production stack on a server or
container.
● On a feature branch develop just the chef code
needed to deploy your custom application.
● Slowly merge the two once per iteration. Merge one
item from the stack branch and merge your install
code to master.
© Copyright 2016 Coveros, Inc. All rights reserved.
Transitioning to the CI Approach
● Do not try to boil the ocean.
● Start with installing the application code.
● Move up to controlling the application stack
one layer at a time.
● This maps to Agile sprints and iterations.
● Cookbooks should be idempotent.
Master (What is in Chef Server)
Install Code
(Feature
Branch)
Install Code
(Feature
Branch)
Install Code
(Feature
Branch)
Install Code
(Feature
Branch)
Install Code
(Feature
Branch)
Infrastructure or Application Stack Cookbooks (Apache, Tomcat, etc.)
Test
Here
Test
Here
Test
Here
Test
Here
© Copyright 2016 Coveros, Inc. All rights reserved.
Metrics
● Failed Merges
○ How many times did a developer cause a
potential merge conflict?
● Static analysis thresholds
○ How many times did a commit fail?
● Failed rspec tests.
● Failed functional tests.
● How long is the component down during
upgrade.
© Copyright 2016 Coveros, Inc. All rights reserved.
Docker and Cloud
● Docker
○ Can be very fast
○ Need a local Docker repository.
● Cloud
○ You can use a mirror of production
environment.
○ Need to find a way to clone VMs without
downtime or cluster components.
● If production uses docker this is a moot
point, just use docker.
© Copyright 2016 Coveros, Inc. All rights reserved.
Discussion Points
● Tool chain can be complicated.
○ If you already invested in CI you have a sunk cost
with many of the tools already.
● Two major types of transitions:
○ Introducing CI to chef.
○ Introducing Chef and CI to a project.
● Start small, big bang automation is high risk.
● Make the quality gates automated and give the
developers the answer key, don’t change the test, and
let Jenkins proctor the exam.
● Allocate time to sync production changes to testing
images.
© Copyright 2016 Coveros, Inc. All rights reserved.
What Problems Did We Solve?
● Version management - The git cookbook version linkage
provides change traceability. This is enforced by Jenkins.
● Enforcing testing in general for Infrastructure - By ceeding
cookbook upload control to Jenkins we can have a
minimal set of quality standards for all deployments and
changes.
● Making Testing accessible to the developers - By putting a
framework at their fingertips. This makes it easier for
developers to follow the process than circumvent the
process.
● Provide testing metrics so cookbook quality can be
analyzed.
● Provided an automated testing framework to provide quick
feedback on integration errors.
● Disposable infrastructure for rapidly changing server state.
© Copyright 2016 Coveros, Inc. All rights reserved.
What Problems Didn’t We Solve?
● Adoption
○ Change it hard, things can be done to ease
the transition but it cannot be forced. You
still have to convince developers the value
proposition of writing the tests.
● Integration errors
○ While we can find them faster, there is no
tool I know of that can predict code
interaction accurately.
© Copyright 2016 Coveros, Inc. All rights reserved.
Thoughts? Questions?
Thank you for your time.

More Related Content

What's hot (20)

ODP
Jenkinsconf Presentation - Advance jenkins management with multiple projects.
Ohad Basan
 
PDF
Introduction to CICD
Knoldus Inc.
 
PDF
Continuous Deployment To The Cloud @DevoxxPL 2017
Marcin Grzejszczak
 
PPTX
SkyBase - a Devops Platform for Hybrid Cloud
Vlad Kuusk
 
PDF
Continuous Deployment of your Application @jSession#5
Marcin Grzejszczak
 
PDF
AgileDC15 I'm Using Chef So I'm DevOps Right?
Rob Brown
 
PDF
Continuous Deployment of your Application @SpringOne
ciberkleid
 
PDF
Continuous Testing
Crevise Technologies
 
PPTX
DevOps: Sprinkle Dev, Sprinkle Ops, Let's make Cake, not Mud Pies
Centric Consulting
 
PDF
Journée DevOps : De l'intégration continue au déploiement continu avec Jenkins
Publicis Sapient Engineering
 
PPTX
Continuous Testing using Shippable and Docker
Mukta Aphale
 
PPTX
Continuous Deployment to the cloud
VMware Tanzu
 
PPTX
SanDiego_DevOps_Meetup_9212016-v8
Rajwinder Singh
 
PPTX
Transforming Organizations with CI/CD
Cprime
 
PDF
Building a loosely coupled toolchain with Rundeck and Puppet
smeunier114
 
PDF
At Your Service: Using Jenkins in Operations
Mandi Walls
 
PDF
CI CD Pipeline Using Jenkins | Continuous Integration and Deployment | DevOps...
Edureka!
 
PDF
DevOps@Morpho for ParisDevOps - 2nd of December 2014
Jean-Charles JOREL
 
PDF
"DevOps > CI+CD "
Innovation Roots
 
PPTX
Continuous Testing and New Tools for Automation - Presentation from StarWest ...
Sauce Labs
 
Jenkinsconf Presentation - Advance jenkins management with multiple projects.
Ohad Basan
 
Introduction to CICD
Knoldus Inc.
 
Continuous Deployment To The Cloud @DevoxxPL 2017
Marcin Grzejszczak
 
SkyBase - a Devops Platform for Hybrid Cloud
Vlad Kuusk
 
Continuous Deployment of your Application @jSession#5
Marcin Grzejszczak
 
AgileDC15 I'm Using Chef So I'm DevOps Right?
Rob Brown
 
Continuous Deployment of your Application @SpringOne
ciberkleid
 
Continuous Testing
Crevise Technologies
 
DevOps: Sprinkle Dev, Sprinkle Ops, Let's make Cake, not Mud Pies
Centric Consulting
 
Journée DevOps : De l'intégration continue au déploiement continu avec Jenkins
Publicis Sapient Engineering
 
Continuous Testing using Shippable and Docker
Mukta Aphale
 
Continuous Deployment to the cloud
VMware Tanzu
 
SanDiego_DevOps_Meetup_9212016-v8
Rajwinder Singh
 
Transforming Organizations with CI/CD
Cprime
 
Building a loosely coupled toolchain with Rundeck and Puppet
smeunier114
 
At Your Service: Using Jenkins in Operations
Mandi Walls
 
CI CD Pipeline Using Jenkins | Continuous Integration and Deployment | DevOps...
Edureka!
 
DevOps@Morpho for ParisDevOps - 2nd of December 2014
Jean-Charles JOREL
 
"DevOps > CI+CD "
Innovation Roots
 
Continuous Testing and New Tools for Automation - Presentation from StarWest ...
Sauce Labs
 

Similar to Continuous Integration Testing Techniques to Improve Chef Cookbook Quality (20)

PDF
Cfg mgmtcamp c-dwithchef
George Miranda
 
PDF
DOO-009_Powering High Velocity Development for your Infrastructure
decode2016
 
PDF
Zero to Test Driven Infrastructure
Mike Rosado, DevOps, CSM®, CASM™
 
PPTX
What is Test Kitchen
Benoit Caron
 
PPTX
Introduction to Test Kitchen
Nathen Harvey
 
PDF
OSDC 2016 - Kaiten Zushi - Chef at Goodgame Studios by Jan Ulferts
NETWAYS
 
PDF
Testing Your Automation Code (Vagrant Version)
Mischa Taylor
 
PDF
Testable Infrastructure with Chef, Test Kitchen, and Docker
Mandi Walls
 
PDF
CI for Chefs
Nikolay Yurin
 
PPTX
Chef onlinuxonpower
Moya Brannan
 
PPTX
Chef Workflow Demo
Chef
 
PDF
Continuous Integration
Joerg Henning
 
PPTX
Chef tooling and TDD
Sai Kothapalle
 
PDF
MadridDevops September 2014: "From chef09 to chef11, one approach to devops"
Antonio Peña
 
PDF
Chef basics - write infrastructure as code
stevaaa
 
PDF
Using DevOps to Improve Software Quality in the Cloud
TechWell
 
PPTX
IIS Cookbook
Daniel Sablosky
 
PPTX
2019 Chef InSpec Jumpstart Part 1 of 2
Larry Eichenbaum
 
PDF
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20
Michael Lihs
 
PPTX
A Bit of Everything Chef
Mandi Walls
 
Cfg mgmtcamp c-dwithchef
George Miranda
 
DOO-009_Powering High Velocity Development for your Infrastructure
decode2016
 
Zero to Test Driven Infrastructure
Mike Rosado, DevOps, CSM®, CASM™
 
What is Test Kitchen
Benoit Caron
 
Introduction to Test Kitchen
Nathen Harvey
 
OSDC 2016 - Kaiten Zushi - Chef at Goodgame Studios by Jan Ulferts
NETWAYS
 
Testing Your Automation Code (Vagrant Version)
Mischa Taylor
 
Testable Infrastructure with Chef, Test Kitchen, and Docker
Mandi Walls
 
CI for Chefs
Nikolay Yurin
 
Chef onlinuxonpower
Moya Brannan
 
Chef Workflow Demo
Chef
 
Continuous Integration
Joerg Henning
 
Chef tooling and TDD
Sai Kothapalle
 
MadridDevops September 2014: "From chef09 to chef11, one approach to devops"
Antonio Peña
 
Chef basics - write infrastructure as code
stevaaa
 
Using DevOps to Improve Software Quality in the Cloud
TechWell
 
IIS Cookbook
Daniel Sablosky
 
2019 Chef InSpec Jumpstart Part 1 of 2
Larry Eichenbaum
 
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20
Michael Lihs
 
A Bit of Everything Chef
Mandi Walls
 
Ad

More from Josiah Renaudin (20)

PDF
Solve Everyday IT Problems with DevOps
Josiah Renaudin
 
PDF
End-to-End Quality Approach: 14 Levels of Testing
Josiah Renaudin
 
PDF
Product Management: The Innovation Glue for the Lean Enterprise
Josiah Renaudin
 
PDF
Slay the Dragons of Agile Measurement
Josiah Renaudin
 
PDF
Blending Product Discovery and Product Delivery
Josiah Renaudin
 
PDF
Determining Business Value in Agile Development
Josiah Renaudin
 
PDF
Three Things You MUST Know to Transform into an Agile Enterprise
Josiah Renaudin
 
PDF
Internet of Things and the Wisdom of Mobile
Josiah Renaudin
 
PDF
How to Do Kick-Ass Software Development
Josiah Renaudin
 
PDF
The Power of an Agile Mindset
Josiah Renaudin
 
PDF
DevOps and the Culture of High-Performing Software Organizations
Josiah Renaudin
 
PDF
Uncover Untold Stories in Your Data: A Deep Dive on Data Profiling
Josiah Renaudin
 
PDF
Build a Quality Engineering and Automation Framework
Josiah Renaudin
 
PDF
Don’t Be Another Statistic! Develop a Long-Term Test Automation Strategy
Josiah Renaudin
 
PDF
Testing Lessons from the Land of Make Believe
Josiah Renaudin
 
PDF
Finding Success with Test Process Improvement
Josiah Renaudin
 
PDF
Git and GitHub for Testers
Josiah Renaudin
 
PDF
Stay Ahead of the Mobile and Web Testing Maturity Curve
Josiah Renaudin
 
PDF
The Selenium Grid: Run Multiple Automated Tests in Parallel
Josiah Renaudin
 
PDF
Testing at Startup Companies: What, When, Where, and How
Josiah Renaudin
 
Solve Everyday IT Problems with DevOps
Josiah Renaudin
 
End-to-End Quality Approach: 14 Levels of Testing
Josiah Renaudin
 
Product Management: The Innovation Glue for the Lean Enterprise
Josiah Renaudin
 
Slay the Dragons of Agile Measurement
Josiah Renaudin
 
Blending Product Discovery and Product Delivery
Josiah Renaudin
 
Determining Business Value in Agile Development
Josiah Renaudin
 
Three Things You MUST Know to Transform into an Agile Enterprise
Josiah Renaudin
 
Internet of Things and the Wisdom of Mobile
Josiah Renaudin
 
How to Do Kick-Ass Software Development
Josiah Renaudin
 
The Power of an Agile Mindset
Josiah Renaudin
 
DevOps and the Culture of High-Performing Software Organizations
Josiah Renaudin
 
Uncover Untold Stories in Your Data: A Deep Dive on Data Profiling
Josiah Renaudin
 
Build a Quality Engineering and Automation Framework
Josiah Renaudin
 
Don’t Be Another Statistic! Develop a Long-Term Test Automation Strategy
Josiah Renaudin
 
Testing Lessons from the Land of Make Believe
Josiah Renaudin
 
Finding Success with Test Process Improvement
Josiah Renaudin
 
Git and GitHub for Testers
Josiah Renaudin
 
Stay Ahead of the Mobile and Web Testing Maturity Curve
Josiah Renaudin
 
The Selenium Grid: Run Multiple Automated Tests in Parallel
Josiah Renaudin
 
Testing at Startup Companies: What, When, Where, and How
Josiah Renaudin
 
Ad

Recently uploaded (20)

PDF
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
PPTX
Smart Doctor Appointment Booking option in odoo.pptx
AxisTechnolabs
 
PDF
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
PPTX
Build a Custom Agent for Agentic Testing.pptx
klpathrudu
 
PPTX
BB FlashBack Pro 5.61.0.4843 With Crack Free Download
cracked shares
 
PDF
IObit Driver Booster Pro 12.4.0.585 Crack Free Download
henryc1122g
 
PDF
Salesforce Experience Cloud Consultant.pdf
VALiNTRY360
 
PPTX
AEM User Group: India Chapter Kickoff Meeting
jennaf3
 
PDF
4K Video Downloader Plus Pro Crack for MacOS New Download 2025
bashirkhan333g
 
PDF
Best Web development company in india 2025
Greenusys
 
PDF
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
PPTX
From spreadsheets and delays to real-time control
SatishKumar2651
 
PDF
NPD Software -Omnex systems
omnex systems
 
PDF
Ready Layer One: Intro to the Model Context Protocol
mmckenna1
 
PDF
intro_to_cpp_namespace_robotics_corner.pdf
MohamedSaied877003
 
PDF
AOMEI Partition Assistant Crack 10.8.2 + WinPE Free Downlaod New Version 2025
bashirkhan333g
 
PDF
How to Hire AI Developers_ Step-by-Step Guide in 2025.pdf
DianApps Technologies
 
PDF
AI Prompts Cheat Code prompt engineering
Avijit Kumar Roy
 
PDF
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
PDF
ERP Consulting Services and Solutions by Contetra Pvt Ltd
jayjani123
 
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
Smart Doctor Appointment Booking option in odoo.pptx
AxisTechnolabs
 
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
Build a Custom Agent for Agentic Testing.pptx
klpathrudu
 
BB FlashBack Pro 5.61.0.4843 With Crack Free Download
cracked shares
 
IObit Driver Booster Pro 12.4.0.585 Crack Free Download
henryc1122g
 
Salesforce Experience Cloud Consultant.pdf
VALiNTRY360
 
AEM User Group: India Chapter Kickoff Meeting
jennaf3
 
4K Video Downloader Plus Pro Crack for MacOS New Download 2025
bashirkhan333g
 
Best Web development company in india 2025
Greenusys
 
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
From spreadsheets and delays to real-time control
SatishKumar2651
 
NPD Software -Omnex systems
omnex systems
 
Ready Layer One: Intro to the Model Context Protocol
mmckenna1
 
intro_to_cpp_namespace_robotics_corner.pdf
MohamedSaied877003
 
AOMEI Partition Assistant Crack 10.8.2 + WinPE Free Downlaod New Version 2025
bashirkhan333g
 
How to Hire AI Developers_ Step-by-Step Guide in 2025.pdf
DianApps Technologies
 
AI Prompts Cheat Code prompt engineering
Avijit Kumar Roy
 
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
ERP Consulting Services and Solutions by Contetra Pvt Ltd
jayjani123
 

Continuous Integration Testing Techniques to Improve Chef Cookbook Quality

  • 1. W11   DevOps  &  Testing   5/4/16  13:45   Continuous  Integration  Testing   Techniques  to  Improve  Chef  Cookbook   Quality   Presented  by:   Glenn  Buckholz   Coveros,  Inc.   Brought  to  you  by:     350  Corporate  Way,  Suite  400,  Orange  Park,  FL  32073   888-268-8770 904-278-0524 [email protected] http://www.stareast.techwell.com/
  • 2. Glenn  Buckholz   Coveros,  Inc.   With  fifteen  years  of  industry  experience,  Glenn  Buckholz  leads  continuous   integration  and  deployment  automation  efforts  at  Coveros.  His  career  began  as  a   consultant  implementing  automated  test  frameworks  and  introducing  the   concept  of  change  management  to  many,  many  projects.  Glenn  then  decided  to   become  a  part  of  honest  society  and  settled  down  at  the  Public  Company   Accounting  Oversight  Board  as  their  full8 time  enterprise  change  manager.   Several  years  later,  he  joined  Coveros,  where  he  specializes  in  implementing  agile   practices  and  CI,  and  engineering  configuration  management  instead  of  simply   documenting  it.  
  • 3. © Copyright 2016 Coveros, Inc. All rights reserved. Continuous Integration Testing Techniques to Improve Chef Cookbook Quality STAREAST – 04 May 2016 Glenn Buckholz [email protected]
  • 4. © Copyright 2016 Coveros, Inc. All rights reserved. Agenda •What did I do? •What is problem? •What are the needs? •Demo •Architecture •Workflow •Testing Techniques and Tools •Metrics? •Docker and Cloud •Discussion
  • 5. © Copyright 2016 Coveros, Inc. All rights reserved. What did I do? ● Used a modern CI/CD toolchain to apply continuous integration testing techniques to Chef code (CI): ○ Static analysis ○ Chefspec testing ○ Automated Functional Testing ● Introduces the idea of automatically making cookbooks available when they are ready (CD). ○ There is still a human gate between available and in use by way of version pinning.
  • 6. © Copyright 2016 Coveros, Inc. All rights reserved. What is the problem? ● Infrastructure as Code is currently the wild west with little formal testing methodology. ● Chef lacks coherent CM on its own. ○ Cookbook versions and freezing are not enough. ● No quick way to advance a piece of infrastructure from one state to another and back for purposes of testing. ● No minimal standards and requirements on cookbook functionality.
  • 7. © Copyright 2016 Coveros, Inc. All rights reserved. What are the needs? YOU ARE CHANGING THE TIRE AT 55MPH AND CAN’T STOP!!! ● Find flaws early. ● Ability to test pieces of an architecture without having to have a whole system. ○ Unit testing system components. ● Simulate the effect of a deploy on a running system. ● Dashboarding so you can trend code quality.
  • 8. © Copyright 2016 Coveros, Inc. All rights reserved. Definitions ● Hands Off Deploy - Deployment that is completely driven by Chef or some other infrastructure tool. ● Static Analysis - evaluation of the code without execution. ● Feedback loop - The events between when a developer commits their code and results can be observed. ● Application Code - The custom or home grown software the current IT organization is curating.
  • 9. © Copyright 2016 Coveros, Inc. All rights reserved. Demo
  • 10. © Copyright 2016 Coveros, Inc. All rights reserved. Architecture Local Git Branch Chefspec Test Kitchen Food Critic Developer Workstation Docker Container Binary Repository Docker Repository Local Testing Docker Container Upload Cookbook
  • 11. © Copyright 2016 Coveros, Inc. All rights reserved. Workflow 1. Clone master branch on the developer machine. 2. Make changes and run static analysis. 3. Run Chefspec and test kitchen locally on a docker container. 4. Push changes to remote branch. 5. Jenkins detects changes and checks out branch onto a slave node.
  • 12. © Copyright 2016 Coveros, Inc. All rights reserved. Workflow 6. Jenkins merges the code with master locally. 7. Chef reruns the static analysis. 8. Chef reruns Chefspec and test kitchen. 9. Results and metrics are recorded. 10.Successful tests see code merged into master. 11.Cookbooks are uploaded to the chef server. 12.After the code is executed in production, AMI and Docker containers are automatically updated from production. Steps 8-9 automate integration testing
  • 13. © Copyright 2016 Coveros, Inc. All rights reserved. Reuse of well known patterns ● Feature Branches ○ Small bite sized changes. ● Automated Merging ○ Let the Jenkins objectively merge the code after certain minimum standards are achieved by the developer. ● Local tests that mirror a golden standard ○ Give the developers a cheat sheet. ● Short feedback loops. ● Auto Promotion ○ Let Jenkins keep the working cookbooks in sync with SCM Smaller changes are more likely to make it through the pipeline.
  • 14. © Copyright 2016 Coveros, Inc. All rights reserved. Testing Techniques ● Tabula Rasa ○ Start with a base image ○ Apply Security Hardening ○ Install stack fresh ○ Deploy application code ○ Run tests ● Production Approximation ○ Start with a clone from production ○ Run cookbooks ■ Only changes are executed ○ Run test
  • 15. © Copyright 2016 Coveros, Inc. All rights reserved. Testing Techniques ● Test in parallel ○ Do not block on critical resources clone them. ○ VMs and containers are cheap, create one for every commit you want to test. ○ Make unit and integration test cases isolated. (Script system state for each test case do not rely on other tests) ● Test local ○ Very short feedback loop for developers. ○ Reduces most pipeline failures to integration errors.
  • 16. © Copyright 2016 Coveros, Inc. All rights reserved. Testing Tools ● Unit Testing ○ chefspec - extension of Rspec ● Functional Testing ○ BATS or chefspec ● Static Analysis ○ Foodcritic - lint like ● Git hooks ○ Make certain static tests run as a git hook making them prerequisites to commit or push.
  • 17. © Copyright 2016 Coveros, Inc. All rights reserved. Testing Tools ● Git Branching ○ Let the branch name decide if the CI stack will run the changes. ○ You may want to use a prefix CI- branchname
  • 18. © Copyright 2016 Coveros, Inc. All rights reserved. Testing Tools - Jenkins Master ● Jenkins master only monitors git. ○ Container on slave in the cloud for quick tests. ○ VMs in cloud for executing tests in a production like system. ■ Template AMI matches target machine. ○ All “work” takes place off the master to allow testing in parallel. ● Create Jenkins jobs to capture production templates post deployment. (AMI or docker image)
  • 19. © Copyright 2016 Coveros, Inc. All rights reserved. Testing Tools - Developer Workstation ● Provide an easy to install package that includes: ○ Tools - Chefspec, Foodcritic, etc… ○ Docker settings. ○ Access to a docker repository. ○ Templates to create new cookbooks ● Enough memory and CPU to run the tools. ● DO NOT ALLOW COOKBOOK UPLOAD PRIVILEGES!!!!! ● DO NOT ALLOW MERGE TO MASTER PRIVILEGES!!!!! ● The ability for a developer to find mistakes locally is the most cost effective testing technique available to an organization. (Short Feedback Loop)
  • 20. © Copyright 2016 Coveros, Inc. All rights reserved. Transitioning to the CI Approach ● From the previous slides we have the tools to create an method for retrofitting a CI driven approach to an existing Chef infrastructure. ● On a separate branch create cookbooks that install a piece of the production stack on a server or container. ● On a feature branch develop just the chef code needed to deploy your custom application. ● Slowly merge the two once per iteration. Merge one item from the stack branch and merge your install code to master.
  • 21. © Copyright 2016 Coveros, Inc. All rights reserved. Transitioning to the CI Approach ● Do not try to boil the ocean. ● Start with installing the application code. ● Move up to controlling the application stack one layer at a time. ● This maps to Agile sprints and iterations. ● Cookbooks should be idempotent. Master (What is in Chef Server) Install Code (Feature Branch) Install Code (Feature Branch) Install Code (Feature Branch) Install Code (Feature Branch) Install Code (Feature Branch) Infrastructure or Application Stack Cookbooks (Apache, Tomcat, etc.) Test Here Test Here Test Here Test Here
  • 22. © Copyright 2016 Coveros, Inc. All rights reserved. Metrics ● Failed Merges ○ How many times did a developer cause a potential merge conflict? ● Static analysis thresholds ○ How many times did a commit fail? ● Failed rspec tests. ● Failed functional tests. ● How long is the component down during upgrade.
  • 23. © Copyright 2016 Coveros, Inc. All rights reserved. Docker and Cloud ● Docker ○ Can be very fast ○ Need a local Docker repository. ● Cloud ○ You can use a mirror of production environment. ○ Need to find a way to clone VMs without downtime or cluster components. ● If production uses docker this is a moot point, just use docker.
  • 24. © Copyright 2016 Coveros, Inc. All rights reserved. Discussion Points ● Tool chain can be complicated. ○ If you already invested in CI you have a sunk cost with many of the tools already. ● Two major types of transitions: ○ Introducing CI to chef. ○ Introducing Chef and CI to a project. ● Start small, big bang automation is high risk. ● Make the quality gates automated and give the developers the answer key, don’t change the test, and let Jenkins proctor the exam. ● Allocate time to sync production changes to testing images.
  • 25. © Copyright 2016 Coveros, Inc. All rights reserved. What Problems Did We Solve? ● Version management - The git cookbook version linkage provides change traceability. This is enforced by Jenkins. ● Enforcing testing in general for Infrastructure - By ceeding cookbook upload control to Jenkins we can have a minimal set of quality standards for all deployments and changes. ● Making Testing accessible to the developers - By putting a framework at their fingertips. This makes it easier for developers to follow the process than circumvent the process. ● Provide testing metrics so cookbook quality can be analyzed. ● Provided an automated testing framework to provide quick feedback on integration errors. ● Disposable infrastructure for rapidly changing server state.
  • 26. © Copyright 2016 Coveros, Inc. All rights reserved. What Problems Didn’t We Solve? ● Adoption ○ Change it hard, things can be done to ease the transition but it cannot be forced. You still have to convince developers the value proposition of writing the tests. ● Integration errors ○ While we can find them faster, there is no tool I know of that can predict code interaction accurately.
  • 27. © Copyright 2016 Coveros, Inc. All rights reserved. Thoughts? Questions? Thank you for your time.