SlideShare a Scribd company logo
Code review and automated
testing for Puppet code
Maxim Burgerhout
Solution Architect Linux and Open Source
Inter Access
Puppetcamp Amsterdam 2014
Agenda
● Who? Me?
● Code review for Puppet
● Gerrit, a code review tool
● Jenkins, a continuous integration tool
● Puppet workflow with code review and testing
● The downsides of Gerrit
● A live demo
Who? Me?
● Maxim Burgerhout
● Solution Architect Linux and Open Source
● Linux migrations are a big part of my job
● Puppet plays an important role in that
● Open source fanatic!
Place of work
● Inter Access
● Recently acquired by SLTN
● Together we are a fairly large IT
services provider and software reseller
● We focus on implementations of cloud
platforms, Linux, and Puppet
Code review for Puppet
What is code review?
“Systematic examination of computer
source code, intended to find and fix
mistakes overlooked in the
development phase.”
-- Wikipedia
Why do code review?
● Two people see (and know) more
than one
● Increase skill of both people involved
● Enforce coding standards
● Keep bad commits out of your repo!
● Write better code*
Ok, what is 'better' code?
● In the Puppet domain, most likely:
– Code that's not WET
– Code that follows the style guide
– Code without deprecated syntax
– Code that's portable
– Code without data mixed in
So, how to review code
● Previous points are key in reviewing
● Also, apply site specific knowledge
to code
● And make review teams combining
experienced and less experienced
people
Things to look for
Puppet DSL pitfalls
● For example: the fact that Facter
always returns strings
if $::is_virtual {   =>  if str2bool($::is_virtual) {
     do_something    =>    do_something
}                    =>  }
What more to look for
● Syntactically correct, but not
optimal
● For example: no default in case
statements or selectors
Default case example
case $::timezone {
  'CET': { do_something }
}
case $::timezone {
  'CET': { do_something }
  default: { fail('unknown part of the world') }
}
One more: Overreaching
● Modules should aim to manage one
thing, and not try to do everything
● This is probably not what you want
class loganalyzer {
  package { 'mysql­server': ensure => installed, }
  .. goes on to manage entire database setup ..
}
Gerrit
Some background
● Code review and discussion
platform
● Started in 2008 as a fork of Rietveld
● Gerrit is used in many large open
source projects today
● Focused towards git
Gerrit & git
● Gerrit is also hosts your git repositories
● Can set granular ACL's per repository
● Push to Gerrit with Git and Gerrit starts the
review process automatically
● Made a mistake? Gerrit allows you to
update an already submitted patch
● Problem but already merged? Revert!
Gerrit == floodgates
● Submitted patches kept in purgatory upon
review
● Patch needs a code review and a set of
successful tests to be merged
● Code review is voted on between -2 and +2,
tests are voted on between -1 and +1
● A failed test (-1) or negative review (-2) blocks
merging a patch completely
Jenkins
Some background
● Started in 2011 as a fork of Hudson
● Used as a CI tool at lots of sites
● Can test code, time based or event
triggered (i.e. upon commit)
● Can execute just about every test
you can think of
Jenkins: Testing Puppet
● Per repository in Gerrit, we create a 'job'
in Jenkins
● Job defines where the code comes from,
and which tests to run on it
● Jenkins gets triggered to build upon
every submitted patch in Gerrit
● When done, Jenkins votes -1 or +1
Puppet tests in Jenkins
● Can be simple
– Syntax checks for .pp files:
for file in $(find ­name '*.pp'); do
  puppet parser validate ${file}
  puppet­lint ­­log­format “..” ${file} 
done
– Syntax checks for .erb files:
for file in $(fine ­name '*.erb); do
  erb ­P ­x ­T '­' ${file} | ruby ­c
done
Puppet tests in Jenkins
● Or more complex
– Smoke tests
● Execute your module's tests/init.pp with --noop, make
sure it doesn't blow up
– rspec-puppet
● Tests the logic of your module by mocking parameters
and facts
● Very powerful. Highly recommended.
– Fire up Vagrant VM's from Jenkins
● Cool, but admittedly not something I do a lot
Workflow
Engineer
Gerrit
Submits review request to Gerrit
Engineer
Peer Review
Jenkins Tests
Gerrit
Submits review request to Gerrit
Creates review
and triggers Jenkins
Engineer
Peer Review
Jenkins Tests
Gerrit
Submits review request to Gerrit
Creates review
and triggers Jenkins
JudgementResults
Engineer
Peer Review
Jenkins Tests
Gerrit
Submits review request to Gerrit
Creates review
and triggers Jenkins
JudgementResults
Change is
merged
Improvement
needed
Ack
Nack
Engineer
Peer Review
Jenkins Tests
Gerrit
Submits review request to Gerrit
Creates review
and triggers Jenkins
JudgementResults
Change is
merged
Improvement
needed
Ack
Nack
Cycle restarts, engineers pulls, commits, pushes for review
Engineer
Peer Review
Jenkins Tests
Gerrit
Creates review
and triggers Jenkins
JudgementResults
Change is
merged
Improvement
needed
Ack
Nack
Cycle restarts, engineers pulls, commits, pushes for review
Submits review request to Gerrit
Engineer
Peer Review
Jenkins Tests
Gerrit
Creates review
and triggers Jenkins
JudgementResults
Change is
merged
Improvement
needed
Ack
Nack
Cycle restarts, engineers pulls, commits, pushes for review
Submits review request to Gerrit
Engineer
Peer Review
Jenkins Tests
Gerrit
Creates review
and triggers Jenkins
JudgementResults
Change is
merged
Improvement
needed
Ack
Nack
Cycle restarts, engineers pulls, commits, pushes for review
Submits review request to Gerrit
The downsides
Nothing is perfect
● Looking for a reviewer can be
annoying
● Reviewing everything slows things
down
● Gerrit implements some functionality
through plugins; not a pleasant
experience
Demo
● Want to show you the interaction
between two users and Gerrit
– An engineer writing code
– An engineer reviewing that code
● Quick walkthrough through the
Gerrit interface
Wrap up
● Gerrit and Jenkins are great to work
with and helped us a lot
● Solid building blocks for CI and CD
● Jenkins and Gerrit can be used to
go full continuous deployment
● How far you take it? It's up to you!
You made it!
● You're still alive. So am I! Yay!
● Questions?
README
● More information here:
– http://code.google.com/p/gerrit/
– http://jenkins-ci.org/
– http://rspec-puppet.com/
– http://git-scm.com/
– http://bit.ly/pc_cr_2014 (link to study on code review)
– Thanks to Walter Heck for the inspiration for the bad
code examples

More Related Content

What's hot

De-centralise and Conquer: Masterless Puppet in a Dynamic Environment
De-centralise and Conquer: Masterless Puppet in a Dynamic EnvironmentDe-centralise and Conquer: Masterless Puppet in a Dynamic Environment
De-centralise and Conquer: Masterless Puppet in a Dynamic Environment
Puppet
 
Puppet Camp Berlin 2015: Andrea Giardini | Configuration Management @ CERN: G...
Puppet Camp Berlin 2015: Andrea Giardini | Configuration Management @ CERN: G...Puppet Camp Berlin 2015: Andrea Giardini | Configuration Management @ CERN: G...
Puppet Camp Berlin 2015: Andrea Giardini | Configuration Management @ CERN: G...
NETWAYS
 
DrupalCon Los Angeles - Continuous Integration Toolbox
DrupalCon Los Angeles - Continuous Integration ToolboxDrupalCon Los Angeles - Continuous Integration Toolbox
DrupalCon Los Angeles - Continuous Integration Toolbox
Andrii Podanenko
 
Full Stack Automation with Katello & The Foreman
Full Stack Automation with Katello & The ForemanFull Stack Automation with Katello & The Foreman
Full Stack Automation with Katello & The Foreman
Weston Bassler
 
Killer R10K Workflow - PuppetConf 2014
Killer R10K Workflow - PuppetConf 2014Killer R10K Workflow - PuppetConf 2014
Killer R10K Workflow - PuppetConf 2014
Puppet
 
Drupal contrib module maintaining
Drupal contrib module maintainingDrupal contrib module maintaining
Drupal contrib module maintaining
Andrii Podanenko
 
Modern Infrastructure from Scratch with Puppet
Modern Infrastructure from Scratch with PuppetModern Infrastructure from Scratch with Puppet
Modern Infrastructure from Scratch with Puppet
Puppet
 
Puppet Camp Paris 2015: Continuous Integration of Puppet Code (Intermediate)
Puppet Camp Paris 2015: Continuous Integration of Puppet Code (Intermediate) Puppet Camp Paris 2015: Continuous Integration of Puppet Code (Intermediate)
Puppet Camp Paris 2015: Continuous Integration of Puppet Code (Intermediate)
Puppet
 
Foreman in Your Data Center :OSDC 2015
Foreman in Your Data Center :OSDC 2015Foreman in Your Data Center :OSDC 2015
Foreman in Your Data Center :OSDC 2015
Stephen Benjamin
 
openQA hands on with openSUSE Leap 42.1 - openSUSE.Asia Summit ID 2016
openQA hands on with openSUSE Leap 42.1 - openSUSE.Asia Summit ID 2016openQA hands on with openSUSE Leap 42.1 - openSUSE.Asia Summit ID 2016
openQA hands on with openSUSE Leap 42.1 - openSUSE.Asia Summit ID 2016
Ben Chou
 
Live deployment, ci, drupal
Live deployment, ci, drupalLive deployment, ci, drupal
Live deployment, ci, drupal
Andrii Podanenko
 
Trevor McDonald - Nagios XI Under The Hood
Trevor McDonald  - Nagios XI Under The HoodTrevor McDonald  - Nagios XI Under The Hood
Trevor McDonald - Nagios XI Under The Hood
Nagios
 
Continuous Integration and DevOps with Open Build Service(OBS)
Continuous Integration and DevOps with Open Build Service(OBS)Continuous Integration and DevOps with Open Build Service(OBS)
Continuous Integration and DevOps with Open Build Service(OBS)
Ralf Dannert
 
Tp install anything
Tp install anythingTp install anything
Tp install anything
Alessandro Franceschi
 
Openstack il2014 staypuft- your friendly foreman openstack installer
Openstack il2014   staypuft- your friendly foreman openstack installerOpenstack il2014   staypuft- your friendly foreman openstack installer
Openstack il2014 staypuft- your friendly foreman openstack installerArthur Berezin
 
Beyond Puppet
Beyond PuppetBeyond Puppet
Beyond Puppet
Kris Buytaert
 
MoldCamp - multidimentional testing workflow. CIBox.
MoldCamp  - multidimentional testing workflow. CIBox.MoldCamp  - multidimentional testing workflow. CIBox.
MoldCamp - multidimentional testing workflow. CIBox.
Andrii Podanenko
 
LXC on Ganeti
LXC on GanetiLXC on Ganeti
LXC on Ganeti
kawamuray
 
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
Puppet
 
CIbox - OpenSource solution for making your #devops better
CIbox - OpenSource solution for making your #devops betterCIbox - OpenSource solution for making your #devops better
CIbox - OpenSource solution for making your #devops better
Andrii Podanenko
 

What's hot (20)

De-centralise and Conquer: Masterless Puppet in a Dynamic Environment
De-centralise and Conquer: Masterless Puppet in a Dynamic EnvironmentDe-centralise and Conquer: Masterless Puppet in a Dynamic Environment
De-centralise and Conquer: Masterless Puppet in a Dynamic Environment
 
Puppet Camp Berlin 2015: Andrea Giardini | Configuration Management @ CERN: G...
Puppet Camp Berlin 2015: Andrea Giardini | Configuration Management @ CERN: G...Puppet Camp Berlin 2015: Andrea Giardini | Configuration Management @ CERN: G...
Puppet Camp Berlin 2015: Andrea Giardini | Configuration Management @ CERN: G...
 
DrupalCon Los Angeles - Continuous Integration Toolbox
DrupalCon Los Angeles - Continuous Integration ToolboxDrupalCon Los Angeles - Continuous Integration Toolbox
DrupalCon Los Angeles - Continuous Integration Toolbox
 
Full Stack Automation with Katello & The Foreman
Full Stack Automation with Katello & The ForemanFull Stack Automation with Katello & The Foreman
Full Stack Automation with Katello & The Foreman
 
Killer R10K Workflow - PuppetConf 2014
Killer R10K Workflow - PuppetConf 2014Killer R10K Workflow - PuppetConf 2014
Killer R10K Workflow - PuppetConf 2014
 
Drupal contrib module maintaining
Drupal contrib module maintainingDrupal contrib module maintaining
Drupal contrib module maintaining
 
Modern Infrastructure from Scratch with Puppet
Modern Infrastructure from Scratch with PuppetModern Infrastructure from Scratch with Puppet
Modern Infrastructure from Scratch with Puppet
 
Puppet Camp Paris 2015: Continuous Integration of Puppet Code (Intermediate)
Puppet Camp Paris 2015: Continuous Integration of Puppet Code (Intermediate) Puppet Camp Paris 2015: Continuous Integration of Puppet Code (Intermediate)
Puppet Camp Paris 2015: Continuous Integration of Puppet Code (Intermediate)
 
Foreman in Your Data Center :OSDC 2015
Foreman in Your Data Center :OSDC 2015Foreman in Your Data Center :OSDC 2015
Foreman in Your Data Center :OSDC 2015
 
openQA hands on with openSUSE Leap 42.1 - openSUSE.Asia Summit ID 2016
openQA hands on with openSUSE Leap 42.1 - openSUSE.Asia Summit ID 2016openQA hands on with openSUSE Leap 42.1 - openSUSE.Asia Summit ID 2016
openQA hands on with openSUSE Leap 42.1 - openSUSE.Asia Summit ID 2016
 
Live deployment, ci, drupal
Live deployment, ci, drupalLive deployment, ci, drupal
Live deployment, ci, drupal
 
Trevor McDonald - Nagios XI Under The Hood
Trevor McDonald  - Nagios XI Under The HoodTrevor McDonald  - Nagios XI Under The Hood
Trevor McDonald - Nagios XI Under The Hood
 
Continuous Integration and DevOps with Open Build Service(OBS)
Continuous Integration and DevOps with Open Build Service(OBS)Continuous Integration and DevOps with Open Build Service(OBS)
Continuous Integration and DevOps with Open Build Service(OBS)
 
Tp install anything
Tp install anythingTp install anything
Tp install anything
 
Openstack il2014 staypuft- your friendly foreman openstack installer
Openstack il2014   staypuft- your friendly foreman openstack installerOpenstack il2014   staypuft- your friendly foreman openstack installer
Openstack il2014 staypuft- your friendly foreman openstack installer
 
Beyond Puppet
Beyond PuppetBeyond Puppet
Beyond Puppet
 
MoldCamp - multidimentional testing workflow. CIBox.
MoldCamp  - multidimentional testing workflow. CIBox.MoldCamp  - multidimentional testing workflow. CIBox.
MoldCamp - multidimentional testing workflow. CIBox.
 
LXC on Ganeti
LXC on GanetiLXC on Ganeti
LXC on Ganeti
 
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
 
CIbox - OpenSource solution for making your #devops better
CIbox - OpenSource solution for making your #devops betterCIbox - OpenSource solution for making your #devops better
CIbox - OpenSource solution for making your #devops better
 

Similar to Code review and automated testing for Puppet code

Gerrit Code Review
Gerrit Code ReviewGerrit Code Review
Gerrit Code Review
Johannes Barop
 
Microservices at Mercari
Microservices at MercariMicroservices at Mercari
Microservices at Mercari
Google Cloud Platform - Japan
 
Creating a reasonable project boilerplate
Creating a reasonable project boilerplateCreating a reasonable project boilerplate
Creating a reasonable project boilerplate
Stanislav Petrov
 
Modern Web-site Development Pipeline
Modern Web-site Development PipelineModern Web-site Development Pipeline
Modern Web-site Development Pipeline
GlobalLogic Ukraine
 
Keeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldKeeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository world
Roberto Pérez Alcolea
 
Yet Another Continuous Integration Story
Yet Another Continuous Integration StoryYet Another Continuous Integration Story
Yet Another Continuous Integration Story
Anton Serdyuk
 
How to plan and define your CI-CD pipeline
How to plan and define your CI-CD pipelineHow to plan and define your CI-CD pipeline
How to plan and define your CI-CD pipeline
ElasTest Project
 
KubeCon EU 2022 Istio, Flux & Flagger.pdf
KubeCon EU 2022 Istio, Flux & Flagger.pdfKubeCon EU 2022 Istio, Flux & Flagger.pdf
KubeCon EU 2022 Istio, Flux & Flagger.pdf
Weaveworks
 
End-end tests as first class citizens - SeleniumConf 2020
End-end tests as first class citizens - SeleniumConf 2020End-end tests as first class citizens - SeleniumConf 2020
End-end tests as first class citizens - SeleniumConf 2020
Abhijeet Vaikar
 
High Performance Software Engineering Teams
High Performance Software Engineering TeamsHigh Performance Software Engineering Teams
High Performance Software Engineering Teams
Lars Thorup
 
Keeping code clean
Keeping code cleanKeeping code clean
Keeping code clean
Brett Child
 
Github Copilot vs Amazon CodeWhisperer for Java developers at JCON 2023
Github Copilot vs Amazon CodeWhisperer for Java developers at JCON 2023Github Copilot vs Amazon CodeWhisperer for Java developers at JCON 2023
Github Copilot vs Amazon CodeWhisperer for Java developers at JCON 2023
Vadym Kazulkin
 
Continuous integration and delivery for java based web applications
Continuous integration and delivery for java based web applicationsContinuous integration and delivery for java based web applications
Continuous integration and delivery for java based web applications
Sunil Dalal
 
Que nos espera a los ALM Dudes para el 2013?
Que nos espera a los ALM Dudes para el 2013?Que nos espera a los ALM Dudes para el 2013?
Que nos espera a los ALM Dudes para el 2013?
Bruno Capuano
 
Dev ops presentation
Dev ops presentationDev ops presentation
Dev ops presentation
Ahmed Kamel
 
Product development and tools
Product development and toolsProduct development and tools
Product development and toolsroelofr
 
The-Git-Tutorial.ppt.pptx
The-Git-Tutorial.ppt.pptxThe-Git-Tutorial.ppt.pptx
The-Git-Tutorial.ppt.pptx
MohammadSamiuddin12
 
Continuous Delivery at Snyk
Continuous Delivery at SnykContinuous Delivery at Snyk
Continuous Delivery at Snyk
Anton Drukh
 
Debugging 2013- Lars pedersen
Debugging 2013- Lars pedersenDebugging 2013- Lars pedersen
Debugging 2013- Lars pedersen
Mediehuset Ingeniøren Live
 
GitLab Commit 2020: Ubiquitous quality through continuous testing pipelines
GitLab Commit 2020: Ubiquitous quality through continuous testing pipelinesGitLab Commit 2020: Ubiquitous quality through continuous testing pipelines
GitLab Commit 2020: Ubiquitous quality through continuous testing pipelines
Joseph Lust
 

Similar to Code review and automated testing for Puppet code (20)

Gerrit Code Review
Gerrit Code ReviewGerrit Code Review
Gerrit Code Review
 
Microservices at Mercari
Microservices at MercariMicroservices at Mercari
Microservices at Mercari
 
Creating a reasonable project boilerplate
Creating a reasonable project boilerplateCreating a reasonable project boilerplate
Creating a reasonable project boilerplate
 
Modern Web-site Development Pipeline
Modern Web-site Development PipelineModern Web-site Development Pipeline
Modern Web-site Development Pipeline
 
Keeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldKeeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository world
 
Yet Another Continuous Integration Story
Yet Another Continuous Integration StoryYet Another Continuous Integration Story
Yet Another Continuous Integration Story
 
How to plan and define your CI-CD pipeline
How to plan and define your CI-CD pipelineHow to plan and define your CI-CD pipeline
How to plan and define your CI-CD pipeline
 
KubeCon EU 2022 Istio, Flux & Flagger.pdf
KubeCon EU 2022 Istio, Flux & Flagger.pdfKubeCon EU 2022 Istio, Flux & Flagger.pdf
KubeCon EU 2022 Istio, Flux & Flagger.pdf
 
End-end tests as first class citizens - SeleniumConf 2020
End-end tests as first class citizens - SeleniumConf 2020End-end tests as first class citizens - SeleniumConf 2020
End-end tests as first class citizens - SeleniumConf 2020
 
High Performance Software Engineering Teams
High Performance Software Engineering TeamsHigh Performance Software Engineering Teams
High Performance Software Engineering Teams
 
Keeping code clean
Keeping code cleanKeeping code clean
Keeping code clean
 
Github Copilot vs Amazon CodeWhisperer for Java developers at JCON 2023
Github Copilot vs Amazon CodeWhisperer for Java developers at JCON 2023Github Copilot vs Amazon CodeWhisperer for Java developers at JCON 2023
Github Copilot vs Amazon CodeWhisperer for Java developers at JCON 2023
 
Continuous integration and delivery for java based web applications
Continuous integration and delivery for java based web applicationsContinuous integration and delivery for java based web applications
Continuous integration and delivery for java based web applications
 
Que nos espera a los ALM Dudes para el 2013?
Que nos espera a los ALM Dudes para el 2013?Que nos espera a los ALM Dudes para el 2013?
Que nos espera a los ALM Dudes para el 2013?
 
Dev ops presentation
Dev ops presentationDev ops presentation
Dev ops presentation
 
Product development and tools
Product development and toolsProduct development and tools
Product development and tools
 
The-Git-Tutorial.ppt.pptx
The-Git-Tutorial.ppt.pptxThe-Git-Tutorial.ppt.pptx
The-Git-Tutorial.ppt.pptx
 
Continuous Delivery at Snyk
Continuous Delivery at SnykContinuous Delivery at Snyk
Continuous Delivery at Snyk
 
Debugging 2013- Lars pedersen
Debugging 2013- Lars pedersenDebugging 2013- Lars pedersen
Debugging 2013- Lars pedersen
 
GitLab Commit 2020: Ubiquitous quality through continuous testing pipelines
GitLab Commit 2020: Ubiquitous quality through continuous testing pipelinesGitLab Commit 2020: Ubiquitous quality through continuous testing pipelines
GitLab Commit 2020: Ubiquitous quality through continuous testing pipelines
 

Recently uploaded

GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 

Recently uploaded (20)

GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 

Code review and automated testing for Puppet code

  • 1. Code review and automated testing for Puppet code Maxim Burgerhout Solution Architect Linux and Open Source Inter Access Puppetcamp Amsterdam 2014
  • 2. Agenda ● Who? Me? ● Code review for Puppet ● Gerrit, a code review tool ● Jenkins, a continuous integration tool ● Puppet workflow with code review and testing ● The downsides of Gerrit ● A live demo
  • 3. Who? Me? ● Maxim Burgerhout ● Solution Architect Linux and Open Source ● Linux migrations are a big part of my job ● Puppet plays an important role in that ● Open source fanatic!
  • 4. Place of work ● Inter Access ● Recently acquired by SLTN ● Together we are a fairly large IT services provider and software reseller ● We focus on implementations of cloud platforms, Linux, and Puppet
  • 6. What is code review? “Systematic examination of computer source code, intended to find and fix mistakes overlooked in the development phase.” -- Wikipedia
  • 7. Why do code review? ● Two people see (and know) more than one ● Increase skill of both people involved ● Enforce coding standards ● Keep bad commits out of your repo! ● Write better code*
  • 8. Ok, what is 'better' code? ● In the Puppet domain, most likely: – Code that's not WET – Code that follows the style guide – Code without deprecated syntax – Code that's portable – Code without data mixed in
  • 9. So, how to review code ● Previous points are key in reviewing ● Also, apply site specific knowledge to code ● And make review teams combining experienced and less experienced people
  • 11. Puppet DSL pitfalls ● For example: the fact that Facter always returns strings if $::is_virtual {   =>  if str2bool($::is_virtual) {      do_something    =>    do_something }                    =>  }
  • 12. What more to look for ● Syntactically correct, but not optimal ● For example: no default in case statements or selectors
  • 14. One more: Overreaching ● Modules should aim to manage one thing, and not try to do everything ● This is probably not what you want class loganalyzer {   package { 'mysql­server': ensure => installed, }   .. goes on to manage entire database setup .. }
  • 16. Some background ● Code review and discussion platform ● Started in 2008 as a fork of Rietveld ● Gerrit is used in many large open source projects today ● Focused towards git
  • 17. Gerrit & git ● Gerrit is also hosts your git repositories ● Can set granular ACL's per repository ● Push to Gerrit with Git and Gerrit starts the review process automatically ● Made a mistake? Gerrit allows you to update an already submitted patch ● Problem but already merged? Revert!
  • 18. Gerrit == floodgates ● Submitted patches kept in purgatory upon review ● Patch needs a code review and a set of successful tests to be merged ● Code review is voted on between -2 and +2, tests are voted on between -1 and +1 ● A failed test (-1) or negative review (-2) blocks merging a patch completely
  • 20. Some background ● Started in 2011 as a fork of Hudson ● Used as a CI tool at lots of sites ● Can test code, time based or event triggered (i.e. upon commit) ● Can execute just about every test you can think of
  • 21. Jenkins: Testing Puppet ● Per repository in Gerrit, we create a 'job' in Jenkins ● Job defines where the code comes from, and which tests to run on it ● Jenkins gets triggered to build upon every submitted patch in Gerrit ● When done, Jenkins votes -1 or +1
  • 22. Puppet tests in Jenkins ● Can be simple – Syntax checks for .pp files: for file in $(find ­name '*.pp'); do   puppet parser validate ${file}   puppet­lint ­­log­format “..” ${file}  done – Syntax checks for .erb files: for file in $(fine ­name '*.erb); do   erb ­P ­x ­T '­' ${file} | ruby ­c done
  • 23. Puppet tests in Jenkins ● Or more complex – Smoke tests ● Execute your module's tests/init.pp with --noop, make sure it doesn't blow up – rspec-puppet ● Tests the logic of your module by mocking parameters and facts ● Very powerful. Highly recommended. – Fire up Vagrant VM's from Jenkins ● Cool, but admittedly not something I do a lot
  • 26. Engineer Peer Review Jenkins Tests Gerrit Submits review request to Gerrit Creates review and triggers Jenkins
  • 27. Engineer Peer Review Jenkins Tests Gerrit Submits review request to Gerrit Creates review and triggers Jenkins JudgementResults
  • 28. Engineer Peer Review Jenkins Tests Gerrit Submits review request to Gerrit Creates review and triggers Jenkins JudgementResults Change is merged Improvement needed Ack Nack
  • 29. Engineer Peer Review Jenkins Tests Gerrit Submits review request to Gerrit Creates review and triggers Jenkins JudgementResults Change is merged Improvement needed Ack Nack Cycle restarts, engineers pulls, commits, pushes for review
  • 30. Engineer Peer Review Jenkins Tests Gerrit Creates review and triggers Jenkins JudgementResults Change is merged Improvement needed Ack Nack Cycle restarts, engineers pulls, commits, pushes for review Submits review request to Gerrit
  • 31. Engineer Peer Review Jenkins Tests Gerrit Creates review and triggers Jenkins JudgementResults Change is merged Improvement needed Ack Nack Cycle restarts, engineers pulls, commits, pushes for review Submits review request to Gerrit
  • 32. Engineer Peer Review Jenkins Tests Gerrit Creates review and triggers Jenkins JudgementResults Change is merged Improvement needed Ack Nack Cycle restarts, engineers pulls, commits, pushes for review Submits review request to Gerrit
  • 34. Nothing is perfect ● Looking for a reviewer can be annoying ● Reviewing everything slows things down ● Gerrit implements some functionality through plugins; not a pleasant experience
  • 35. Demo ● Want to show you the interaction between two users and Gerrit – An engineer writing code – An engineer reviewing that code ● Quick walkthrough through the Gerrit interface
  • 36. Wrap up ● Gerrit and Jenkins are great to work with and helped us a lot ● Solid building blocks for CI and CD ● Jenkins and Gerrit can be used to go full continuous deployment ● How far you take it? It's up to you!
  • 37. You made it! ● You're still alive. So am I! Yay! ● Questions?
  • 38. README ● More information here: – http://code.google.com/p/gerrit/ – http://jenkins-ci.org/ – http://rspec-puppet.com/ – http://git-scm.com/ – http://bit.ly/pc_cr_2014 (link to study on code review) – Thanks to Walter Heck for the inspiration for the bad code examples