JenkinsPipelineUnit. Test your Continuous Delivery Pipeline. Ozan Gunalp - Emmanuel Quincerot

Similar documents
TM DevOps Use Case. 2017TechMinfy All Rights Reserved

TM DevOps Use Case. 2017TechMinfy All Rights Reserved

TM DevOps Use Case TechMinfy All Rights Reserved

Who Moved My Module? 1

Chapter 1 - Continuous Delivery and the Jenkins Pipeline

JetBrains TeamCity Comparison

AEM Code Promotion and Content Synchronization Best Practices

FROM VSTS TO AZURE DEVOPS

Seven Habits of Highly Effective Jenkins Users

Continuous Integration / Continuous Testing

ONAP Developer Typical Setup 2017 July ONAP Virtual Developers Event

DevNet Workshop-Hands-on with CloudCenter and Jenkins

Continuous Delivery of your infrastructure. Christophe

AALOK INSTITUTE. DevOps Training

Con. Continuous Integration

Orchestrating the Continuous Delivery Process

An Architecture for Self-Organizing Continuous Delivery Pipelines

Jenkins: A complete solution. From Continuous Integration to Continuous Delivery For HSBC

Developing and Testing Java Microservices on Docker. Todd Fasullo Dir. Engineering

Building a (resumable and extensible) DSL with Apache Groovy Jesse Glick CloudBees, Inc.

How Can Testing Teams Play a Key Role in DevOps Adoption?

Azure DevOps. Randy Pagels Intelligent Cloud Technical Specialist Great Lakes Region

Continuous Integration using Docker & Jenkins

Continuous Testing at Scale

Test Automation Strategies in Continuous Delivery. Nandan Shinde Test Automation Architect (Tech CoE) Cognizant Technology Solutions

Continuous Integration Ensemble / HealthShare Health Connect

Large-Scale Automation with Jenkins

Belle II - Git migration

Continuous integration & continuous delivery. COSC345 Software Engineering

Disclaimer This presentation may contain product features that are currently under development. This overview of new technology represents no commitme

Continuous Integration and Deployment (CI/CD)

NetApp Jenkins Plugin Documentation

Achieving Continuous Delivery - Micro Services. - Vikram Gadang

Object Oriented Programming. Week 1 Part 2 Git and egit

Using DC/OS for Continuous Delivery

Continuous integration for databases using Red Gate tools

We are ready to serve Latest Testing Trends, Are you ready to learn?? New Batches Info

Empowering Developers to Take Flight Continuous Integration at Gogo

CONTINUOUS DELIVERY IN THE ORACLE CLOUD

Inverting the Pyramid

Jenkins in the Enterprise Building resilient CI infrastructure

Collaboration in Teams: Simulink Projects Demonstration

The Actual Real World at EclipseCon/ALM

Both Sides Now: DevOps and Agile in Oracle Developer Cloud Service for Fusion Middleware Developers

Turbo boost your digital app test automation with Jenkins

Enabling Developers with Open Source Nicholas Parks, Cloud Architect, Kenzan

Jenkins User Conference Israel. #jenkinsconf. CI / Liveperson. Gidi Samuels. July 16, #jenkinsconf

Pipeline as Code for your IAC. Kris

Implementing the Twelve-Factor App Methodology for Developing Cloud- Native Applications

Bitte decken Sie die schraffierte Fläche mit einem Bild ab. Please cover the shaded area with a picture. (24,4 x 7,6 cm)

Disclaimer This presentation may contain product features that are currently under development. This overview of new technology represents no commitme

ci-management Release 1.0.0

Quality Engineering in DevOps world a Strategic Enabler

Continuous Delivery for Cloud Native Applications

Technology Background Development environment, Skeleton and Libraries

Continuous Integration & Code Quality MINDS-ON NUNO 11 APRIL 2017

Strengthen and Scale security using DevSecOps

9 Reasons To Use a Binary Repository for Front-End Development with Bower

DevOps Course Content

Configuration As Code. #jenkinsconf. Jenkins User Conference Europe #jenkinsconf. The Job DSL Plugin. Daniel Spilker CoreMedia

USING GIT FOR AUTOMATION AND COLLABORATION JUSTIN ELLIOTT - MATT HANSEN PENN STATE UNIVERSITY

ThinkPalm s BreakThrough DevOps Capabilities ThinkPalm

Deployment Within a Traditional IT environment

The Seven Steps to Implement DataOps

MAVEN MOCK TEST MAVEN MOCK TEST I

Continuous Integration (CI) with Jenkins

Software configuration management

Redgate Database Lifecycle Management (DLM) vs SQL Server Data Tools (SSDT)

Lab Objective. Lab Assignment. Downloads and Installation

Version Control for PL/SQL

Evolving Database Design and Architecture Patterns and Practices

Continuous Delivery the hard way with Kubernetes. Luke Marsden, Developer

GIT TO DA REPO! VERSION CONTROL, GITLAB, AND ISU

Automatic MySQL Schema Management with Skeema. Evan Elias Percona Live, April 2017

PayPal Delivers World Class Customer Service, Worldwide

Con$nuous Deployment with Docker Andrew Aslinger. Oct

There Should be One Obvious Way to Bring Python into Production. Sebastian Neubauer

Managing Network Configurations with Git and GitLab

Containerised Development of a Scientific Data Management System Ben Leighton, Andrew Freebairn, Ashley Sommer, Jonathan Yu, Simon Cox LAND AND WATER

A deployment pipeline composed of steps from remote servers

Anchore Container Image Scanner Plugin

Continuous Delivery at Liferay A fast lane for your software updates. Rubén Eduardo

DevOps Course Content

Review Version Control Concepts

I keep hearing about DevOps What is it?

AMM Feb/2018. Frederic Marec Embedded Engineer

Introduction: Manual Testing :

Continuous Deployment with Gerrit and Jenkins

Project Automation. If it hurts, automate it! Jan Pool NioCAD University of Stellenbosch 19 March 2008

PHP Composer 9 Benefits of Using a Binary Repository Manager

Lab 5 Exercise Build and continuous integration tools

CONTINUOUS INTEGRATION CONTINUOUS DELIVERY

Fosdem Feb/2018. Frederic Marec Embedded Engineer

Distributed CI: Scaling Jenkins on Mesos and Marathon. Roger Ignazio Puppet Labs, Inc. MesosCon 2015 Seattle, WA

Put Security Into Your DevOps NOW. Or Prepare for the Flood Matthew Fisher Solution Architect, Fortify Federal 08MAR2018

Sunil Shah SECURE, FLEXIBLE CONTINUOUS DELIVERY PIPELINES WITH GITLAB AND DC/OS Mesosphere, Inc. All Rights Reserved.

CPSC 491. Lecture 19 & 20: Source Code Version Control. VCS = Version Control Software SCM = Source Code Management

Git better. Collaborative project management using Git and GitHub. Matteo Sostero March 13, Sant Anna School of Advanced Studies

Simplified CICD with Jenkins and Git on the ZeroStack Platform

An Experimentation Workbench for Replayable Networking Research

Transcription:

JenkinsPipelineUnit Test your Continuous Delivery Pipeline Ozan Gunalp - Emmanuel Quincerot

Who we are Ozan Günalp Emmanuel Quincerot Developer at LesFurets Developer at LesFurets PhD in Computer Science @ozangunalp @EQuincerot

First independant insurance comparison website in France Operating since 2012 50 insurers on Vehicle, Home, Health and Loan products 3M quotes per year

Delivery @ LesFurets 20+ developers 30~ developments in parallel Daily deployment to production since 2014 ~220 releases per year

Continuous delivery @ LesFurets Feature Branching + Continuous Integration One branch per development Continuous merge for staging Daily release of ready branches

Continuous delivery @ LesFurets Feature Branching + Continuous Integration One branch per development Continuous merge for staging Daily release of ready branches Isolated developments Early feedback

Before: Legacy Continuous delivery Build & Deploy Scripts Application Source SCM SCM Build UT + IT DEV DB Package Deploy Acceptance Tests

Before: Legacy Continuous delivery Teamcity + Jenkins (Configuration in UI) Multi-repo (code + deployment scripts) Shared development database Manual database migration No artifact repository Hard-coded notifications on Slack Jobs are broken often by evolutions

After: Jenkins pipeline-as-code SCM Build UT + IT Package Deploy Artifact Repo Acceptance Tests

After: Jenkins pipeline-as-code Jenkins pipelines everywhere Same repository for code & pipeline Automated tests with database on docker Fully automated database migration Lazy packaging with artifact repository Job result feedback with Slack notifications Every evolution is tested separately and released

pipeline-as-code Coordinate tasks Handle errors and retry Parallelize Externalize configuration Separate configuration from workflow No conf in shell scripts

...and they lived happily after

Migration to Jenkins pipelines Pay the price of early adoption : discovering Jenkins pipelines with incomplete documentation

Workspaces and multi-branch One branch validated on many agents One workspace per branch on each agent 100 branches x 1GB No automatic cleanup

Workspaces and multi-branch One branch validated on many agents One workspace per branch on each agent 100 branches x 1GB No automatic cleanup No space left on disk

Workspaces - first try Clean the workspace Disk usage problem solved Clone from scratch, slow and intensive network usage

Workspaces - second try Share the workspace among branches, with: ws('validation') { checkout(scm) sh 'git clean -xdf'... } Quick checkout and workspace reused

DRY Splitting pipeline scripts Script loader // jenkins/step/deploy/flyway.jenkins def execute() { node() { commons.dlfromrepository(scmhash, 'flyway-migrations.zip') sh 'unzip -o flyway-migrations.zip' dir('flyway-migrations') { sh "./flyway-migrate.sh" } } } return this

Development by Trial and Error Replay is your friend...

Development by Trial and Error java.lang.unsupportedoperationexception: no known implementation of interface jenkins.tasks.simplebuildstep is named FooBar... at org.kohsuke.groovy.sandbox.impl.checker$1.call(checker.java:153) at org.kohsuke.groovy.sandbox.impl.checker.checkedcall(checker.java:157) at org.kohsuke.groovy.sandbox.impl.checker.checkedcall(checker.java:127) at com.cloudbees.groovy.cps.sandbox.sandboxinvoker.methodcall(sandboxinvoker.java:17) at Script17.execute(Script17.groovy:14)... at cps.transform (Native Method) at com.cloudbees.groovy.cps.impl.continuationgroup.methodcall(continuationgroup.java:57) at com.cloudbees.groovy.cps.impl.continuationgroup.methodcall(continuationgroup.java:57)...until it is not.

Risky business One change can cause regression Oops! The load test is triggered after deploying the production! We need to test and track the impact of our changes!

JenkinsPipelineUnit

Continuous delivery pipelines are described with code Pipeline code is versioned in our code base JenkinsPipelineUnit Unit tests to check what will be executed https://github.com/lesfurets/jenkinspipelineunit

DEMO

Setup Add dependency from Maven Central com.lesfurets:jenkins-pipeline-unit:1.0 Extend the base class class MyTest extends BasePipelineTest Mock variables binding.setvariable('deploy_to', 'DEV') Mock Jenkins steps helper.registerallowedmethod('sh', [Map], { println "calling sh with $it" })

Features Unit test Debug in IDE Callstack print Non-regression test Jenkinsfile.run() Jenkinsfile.node(groovy.lang.Closure) Jenkinsfile.stage(Checkout, groovy.lang.closure) Jenkinsfile.checkout(...) Jenkinsfile.sh(git clean -xdf) Jenkinsfile.stage(Build and test, groovy.lang.closure) Jenkinsfile.sh(./gradlew build) Jenkinsfile.junit(build/test-results/test/*.xml) Jenkinsfile.stage(Create a Manifest, groovy.lang.closure) Jenkinsfile.sh({returnStdout=true, script=git rev-parse HEAD}) Jenkinsfile.writeFile({file=MANIFEST.txt, text=2345aef}) Jenkinsfile.archive(MANIFEST.txt)

How does it work?

How does it work? Transforms Groovy code to Continuation Passing Style with groovy-cps, as pipelines in Jenkins Runs scripts with GroovyScriptEngine by injecting variables Uses Groovy metaclass to intercept method calls for mocking steps and generating call stack

vs. JenkinsRule JUnit @Rule Spawns Jenkins instance, with plugins Mandatory for UI tests and plugins More representative but slower https://wiki.jenkins.io/display/jenkins/unit+test#unittest-mocking

When to use what? Developing a plugin? JenkinsRule Continuous delivery pipeline of your organization? JenkinsPipelineUnit Global Shared Library? JenkinsPipelineUnit Declarative pipelines? JenkinsPipelineUnit -?

Tested pipeline-as-code Rapid development lifecycle for pipeline code Testing in local before pushing to Jenkins Breaking boundaries between Dev and Ops

Tested pipeline-as-code 2/3 of developer team is contributing to pipelines Optional stages Tests with dockerized database Lazy packaging Cache warmup Shared workspace Slack notifications Deployment scripts optimization Automated commits

Community

JenkinsPipelineUnit Unit test Callstack print Non-regression test Debug in IDE Improved declarative pipelines support Linting

Open Source @ LesFurets github.com/lesfurets JenkinsPipelineUnit git-octopus github.com/lesfurets/lesfurets-conferences @ozangunalp @equincerot