SlideShare a Scribd company logo
TESTING DISTRIBUTED
MICRO-SERVICES
Carlos Sanchez
@csanchez csanchez.org
Watch online at carlossg.github.io/presentations
ABOUT ME
Senior So ware Engineer @ CloudBees
Author of Jenkins Kubernetes plugin
Long time OSS contributor at Apache Maven, Eclipse,
Puppet,…
Google Cloud Platform "Expert"
DOCKER DOCKER DOCKER
Testing Distributed Micro Services. Agile Testing Days 2017
OUR USE CASE
Scaling Jenkins
Your mileage may vary
Testing Distributed Micro Services. Agile Testing Days 2017
Testing Distributed Micro Services. Agile Testing Days 2017
Testing Distributed Micro Services. Agile Testing Days 2017
A 2000 JENKINS MASTERS CLUSTER
3 Mesos masters (m3.xlarge: 4 vCPU, 15GB, 2x40 SSD)
317 Mesos slaves (c3.2xlarge, m3.xlarge, m4.4xlarge)
7 Mesos slaves dedicated to ElasticSearch: (c3.8xlarge: 32
vCPU, 60GB)
12.5 TB - 3748 CPU
Running 2000 masters and ~8000 concurrent jobs
ARCHITECTURE
Testing Distributed Micro Services. Agile Testing Days 2017
Isolated Jenkins masters
Isolated build agents and jobs
Memory and CPU limits
Testing Distributed Micro Services. Agile Testing Days 2017
Testing Distributed Micro Services. Agile Testing Days 2017
CLUSTER SCHEDULING
Distribute tasks across a cluster of hosts
HA and fault tolerant
With Docker support of course
INFRASTRUCTURE
Running in public cloud, private cloud, VMs or bare metal
APACHE MESOS & MESOSPHERE
MARATHON
A distributed systems kernel
ALTERNATIVES
Docker Swarm / Kubernetes
"UNIT" TESTING
DOCKER IMAGES
THE DOCKERFILE
A lot like a shell script
RUN comands
COPY files
...
DOCKERFILE
FROM openjdk:8-jdk
RUN apt-get update && apt-get install -y git curl && rm -rf /var/lib/apt/list
ARG JENKINS_VERSION
ENV JENKINS_VERSION ${JENKINS_VERSION:-2.19.3}
ARG JENKINS_SHA=e97670636394092af40cc626f8e07b092105c07b
ARG JENKINS_URL=https://repo.jenkins-ci.org/public/org/jenkins-ci/main/jenkin
RUN curl -fsSL ${JENKINS_URL} -o /usr/share/jenkins/jenkins.war 
&& echo "${JENKINS_SHA} /usr/share/jenkins/jenkins.war" | sha1sum -c -
COPY jenkins-support /usr/local/bin/jenkins-support
COPY jenkins.sh /usr/local/bin/jenkins.sh
ENTRYPOINT ["/usr/local/bin/jenkins.sh"]
Mocking and stubbing are your friends
BUILDING WITH JENKINS DOCKER
PIPELINE
def maven = docker.image('maven:3.3.9-jdk-8');
stage 'Mirror'
maven.pull()
docker.withRegistry('https://secure-registry/',
'docker-registry-login') {
stage 'Build'
maven.inside {
sh "mvn -B clean package"
}
stage 'Bake Docker image'
def pcImg = docker.build(
"examplecorp/spring-petclinic:${env.BUILD_TAG}", 'app')
pcImg.push();
}
TESTING WITH JENKINS DOCKER
PIPELINE
Build + test + promotion
Promotion = different Docker registries for different
environments
dev
staging
production
TESTING WITH JENKINS DOCKER
PIPELINE
pcImg = docker.image("examplecorp/spring-petclinic:dev")
stage 'Test'
docker.withRegistry('https://dev.docker.example.com/',
'docker-registry-login') {
pcImg.withRun { petclinic ->
sh "test -f /var/some_file"
}
}
stage 'Promote'
docker.withRegistry('https://staging.docker.example.com/',
'docker-registry-login') {
pcImg.push()
}
DOCKER WORKFLOW PLUGIN DEMO
https://github.com/jenkinsci/docker-workflow-
plugin/tree/master/demo
USING BATS
Testing using shell scripts!
bats tests/install-plugins.bats
Examples from
https://github.com/jenkinsci/docker/tree/master/tests
BATS
#!/usr/bin/env bats
SUT_IMAGE=bats-jenkins
load 'test_helper/bats-support/load'
load 'test_helper/bats-assert/load'
load test_helpers
@test "plugins are installed with plugins.sh" {
run docker build -t $SUT_IMAGE-plugins $BATS_TEST_DIRNAME/plugins
assert_success
run bash -c "docker run --rm $SUT_IMAGE-plugins ls -1 
/var/jenkins_home/plugins"
assert_success
assert_line 'maven-plugin.jpi'
assert_line 'maven-plugin.jpi.pinned'
assert_line 'ant.jpi'
assert_line 'ant.jpi.pinned'
}
BATS
@test "test jenkins arguments" {
local version=$(grep 'ENV JENKINS_VERSION' Dockerfile | 
sed -e 's/.*:-(.*)}/1/')
# need the last line of output
assert "${version}" docker run --rm --name $SUT_CONTAINER 
-P $SUT_IMAGE --help --version | tail -n 1
}
ISOLATION
There is no 100% isolation
MEMORY ISSUES WITH CONTAINERS
Scheduler needs to account for container memory
requirements and host available memory
Prevent containers for using more memory than allowed
Memory constrains translate to Docker --memory
WHAT DO YOU THINK HAPPENS WHEN?
Your container goes over memory quota?
Testing Distributed Micro Services. Agile Testing Days 2017
WHAT ABOUT THE JVM?
WHAT ABOUT THE CHILD PROCESSES?
END TO END TESTING
OF MULTIPLE
CONTAINERS
JENKINS PIPELINE WITH MULTIPLE CONTAINERS
pcImg = docker.image("examplecorp/spring-petclinic:dev")
stage 'Test'
docker.withRegistry('https://dev.docker.example.com/',
'docker-registry-login') {
pcImg.withRun {petclinic ->
testImg.inside("--link=${petclinic.id}:petclinic") {
wrap([$class: 'Xvnc',
takeScreenshot: true,
useXauthority: true]) {
sh "mvn -B clean test"
}
}
}
}
stage 'Promote'
docker.withRegistry('https://staging.docker.example.com/',
'docker-registry-login') {
pcImg.push()
}
USING CONTAINER GROUPS
DOCKER COMPOSE
Runs multiple containers
Containers can access each other
DOCKER COMPOSE
version: '2'
services:
example:
image: acme/example:latest
ports:
- "5050:5050"
maven:
image: maven:3-jdk-8
command: mvn test
JENKINS KUBERNETES PLUGIN
The Jenkins job can run in a Kubernetes Pod
(group of containers)
Containers in a Pod can access each other at localhost
KUBERNETES PLUGIN PIPELINES
Ex. run maven tests against webapp with Selenium, using
pre-made Docker images
podTemplate(label: 'petclinic', containers: [
containerTemplate(
name: 'maven', image: 'maven:3.3.9-jdk-8-alpine',
ttyEnabled: true, command: 'cat'),
containerTemplate(
name: 'petclinic', image: 'csanchez/petclinic'),
containerTemplate(
name: 'selenium', image: 'selenium/standalone-firefox')
]) {
node ('petclinic') {
stage 'Get a Maven project'
git 'https://github.com/jenkinsci/kubernetes-plugin.git'
container('maven') {
stage 'Build a Maven project'
sh 'cd demo/test && mvn -B clean test'
}
}
}
HOW ARE WE DOING IT
HOW ARE WE DOING IT
On each commit and PR
Provisioning of the infrastructure using Terraform
Installation of the cluster scheduler (Mesos & Marathon)
Continuously creating clusters from scratch
TERRAFORM
Infrastructure-As-Code
TERRAFORM
resource "aws_instance" "worker" {
count = 1
instance_type = "m3.large"
ami = "ami-xxxxxx"
key_name = "tiger-csanchez"
security_groups = ["sg-61bc8c18"]
subnet_id = "subnet-xxxxxx"
associate_public_ip_address = true
tags {
Name = "tiger-csanchez-worker-1"
"cloudbees:pse:cluster" = "tiger-csanchez"
"cloudbees:pse:type" = "worker"
}
root_block_device {
volume_size = 50
}
}
TERRAFORM
State is managed
Runs are idempotent
terraform apply
Sometimes it is too automatic
Changing image id will restart all instances
Testing Distributed Micro Services. Agile Testing Days 2017
IF YOU HAVEN'T AUTOMATICALLY
DESTROYED SOMETHING BY
MISTAKE,
YOU ARE NOT AUTOMATING ENOUGH
HOW ARE WE DOING IT
In AWS and OpenStack
5 different combinations
More combinations on demand
HOW ARE WE DOING IT
A er creation we launch acceptance tests
Some python scripts
Some Selenium tests
Clusters get destroyed at the end
MONITORING IS THE NEW TESTING
We gather from the cluster:
logs
configuration
outputs
Attached to the build to diagnose errors in CI
but also used by our customers to send us information
HOW ARE WE DOING IT
Feedback is published to Github PR
BLUE-GREEN UPGRADES
CANARY DEPLOYMENTS
SCALING
New and interesting problems
AWS
Resource limits: VPCs, S3 snapshots, some instance sizes
Rate limits: affect the whole account
Always use different accounts for testing/production and
possibly different teams
Retrying is your friend, but with exponential backoff
EMBRACE FAILURE!
OPENSTACK
Custom flavors
Custom images
Different CLI commands
There are not two OpenStack installations that are the same
DANKE!
RATE THIS SESSION IN
AGILETESTINGDAYS.COM
csanchez.org
csanchez
carlossg

More Related Content

What's hot (20)

PDF
Scaling Jenkins with Docker and Kubernetes
Carlos Sanchez
 
PPTX
Docker toolbox
Yonghwee Kim
 
PDF
Infrastructure testing with Jenkins, Puppet and Vagrant - Agile Testing Days ...
Carlos Sanchez
 
PDF
Using Containers for Continuous Integration and Continuous Delivery. KubeCon ...
Carlos Sanchez
 
PPTX
Scaling Jenkins with Docker and Kubernetes
Carlos Sanchez
 
PDF
What’s New in Docker - Victor Vieux, Docker
Docker, Inc.
 
PDF
Using Kubernetes for Continuous Integration and Continuous Delivery. Java2days
Carlos Sanchez
 
PDF
Continuous delivery with Jenkins, Docker and Mesos/Marathon - jbcnconf
Julia Mateo
 
PPTX
Delivering eBay's CI Solution with Apache Mesos & Docker - DockerCon 2014
ahunnargikar
 
PDF
Using Containers for Continuous Integration and Continuous Delivery
Carlos Sanchez
 
PDF
Docker Security Deep Dive by Ying Li and David Lawrence
Docker, Inc.
 
PDF
The Golden Ticket: Docker and High Security Microservices by Aaron Grattafiori
Docker, Inc.
 
PDF
Using Docker with Puppet - PuppetConf 2014
Puppet
 
PPTX
Installaling Puppet Master and Agent
Ranjit Avasarala
 
PDF
Continuous Deployment with Jenkins on Kubernetes
Matt Baldwin
 
PDF
Docker on Google App Engine
Docker, Inc.
 
PDF
Un jenkins amélioré avec docker mesos et marathon à Devoxx 2015
Publicis Sapient Engineering
 
PPT
Amazon Web Services and Docker
Paolo latella
 
PDF
Using Kubernetes for Continuous Integration and Continuous Delivery
Carlos Sanchez
 
PPTX
Devoxx France 2015 - The Docker Orchestration Ecosystem on Azure
Patrick Chanezon
 
Scaling Jenkins with Docker and Kubernetes
Carlos Sanchez
 
Docker toolbox
Yonghwee Kim
 
Infrastructure testing with Jenkins, Puppet and Vagrant - Agile Testing Days ...
Carlos Sanchez
 
Using Containers for Continuous Integration and Continuous Delivery. KubeCon ...
Carlos Sanchez
 
Scaling Jenkins with Docker and Kubernetes
Carlos Sanchez
 
What’s New in Docker - Victor Vieux, Docker
Docker, Inc.
 
Using Kubernetes for Continuous Integration and Continuous Delivery. Java2days
Carlos Sanchez
 
Continuous delivery with Jenkins, Docker and Mesos/Marathon - jbcnconf
Julia Mateo
 
Delivering eBay's CI Solution with Apache Mesos & Docker - DockerCon 2014
ahunnargikar
 
Using Containers for Continuous Integration and Continuous Delivery
Carlos Sanchez
 
Docker Security Deep Dive by Ying Li and David Lawrence
Docker, Inc.
 
The Golden Ticket: Docker and High Security Microservices by Aaron Grattafiori
Docker, Inc.
 
Using Docker with Puppet - PuppetConf 2014
Puppet
 
Installaling Puppet Master and Agent
Ranjit Avasarala
 
Continuous Deployment with Jenkins on Kubernetes
Matt Baldwin
 
Docker on Google App Engine
Docker, Inc.
 
Un jenkins amélioré avec docker mesos et marathon à Devoxx 2015
Publicis Sapient Engineering
 
Amazon Web Services and Docker
Paolo latella
 
Using Kubernetes for Continuous Integration and Continuous Delivery
Carlos Sanchez
 
Devoxx France 2015 - The Docker Orchestration Ecosystem on Azure
Patrick Chanezon
 

Viewers also liked (18)

PPT
Agile testingdays2016 finalversion
Luis Gonçalves, CSP
 
PPT
Jenkins on Docker
Craig Trim
 
PDF
Dockerized maven
Matthias Bertschy
 
PDF
What is this "docker"
Jean-Marc Meessen
 
PPTX
Using Docker to Develop, Test and Run Maven Projects - Wouter Danes
NLJUG
 
PPTX
TDC2016SP - Testes unitários e testes de integração de aplicações Java utiliz...
tdc-globalcode
 
ODP
Microservices Manchester: Testing Microservices: Pain or Opportunity? By Davi...
OpenCredo
 
PDF
Scaling without Scale is Possible!
Anton Zotin
 
PDF
Testing Microservices
Nathan Jones
 
PDF
Scaling Jenkins with Docker: Swarm, Kubernetes or Mesos?
Carlos Sanchez
 
PDF
Developing Java based microservices ready for the world of containers
Claus Ibsen
 
PDF
Continuous Integration using Docker & Jenkins
B1 Systems GmbH
 
PDF
Scaling Atlassian - What's New in Data Center
Atlassian
 
PDF
Jenkins Docker
Alex Soto
 
PDF
Using Docker for Testing
Carlos Sanchez
 
PDF
Docker for Java Developers
Imesh Gunaratne
 
PPTX
Microservices Testing
vodQA
 
PPTX
Faster Java EE Builds with Gradle
Ryan Cuprak
 
Agile testingdays2016 finalversion
Luis Gonçalves, CSP
 
Jenkins on Docker
Craig Trim
 
Dockerized maven
Matthias Bertschy
 
What is this "docker"
Jean-Marc Meessen
 
Using Docker to Develop, Test and Run Maven Projects - Wouter Danes
NLJUG
 
TDC2016SP - Testes unitários e testes de integração de aplicações Java utiliz...
tdc-globalcode
 
Microservices Manchester: Testing Microservices: Pain or Opportunity? By Davi...
OpenCredo
 
Scaling without Scale is Possible!
Anton Zotin
 
Testing Microservices
Nathan Jones
 
Scaling Jenkins with Docker: Swarm, Kubernetes or Mesos?
Carlos Sanchez
 
Developing Java based microservices ready for the world of containers
Claus Ibsen
 
Continuous Integration using Docker & Jenkins
B1 Systems GmbH
 
Scaling Atlassian - What's New in Data Center
Atlassian
 
Jenkins Docker
Alex Soto
 
Using Docker for Testing
Carlos Sanchez
 
Docker for Java Developers
Imesh Gunaratne
 
Microservices Testing
vodQA
 
Faster Java EE Builds with Gradle
Ryan Cuprak
 
Ad

Similar to Testing Distributed Micro Services. Agile Testing Days 2017 (20)

PDF
Using containers for continuous integration and continuous delivery - Carlos ...
Paris Container Day
 
PPTX
Taking Jenkins Pipeline to the Extreme
yinonavraham
 
PDF
Jenkins Days - Workshop - Let's Build a Pipeline - Los Angeles
Andy Pemberton
 
PDF
ContainerCon - Test Driven Infrastructure
Yury Tsarev
 
PDF
Continuous Integration/Deployment with Docker and Jenkins
Francesco Bruni
 
PDF
Enabling Hybrid Workflows with Docker/Mesos @Orbitz
Steve Hoffman
 
PDF
CI/CD with Jenkins and Docker - DevOps Meetup Day Thailand
Troublemaker Khunpech
 
PPTX
Jenkins days workshop pipelines - Eric Long
ericlongtx
 
PDF
TestWorks Conf Scalable QA with docker - Maarten van den Ende and Adé Mochtar
Xebia Nederland BV
 
PPTX
Build, Publish, Deploy and Test Docker images and containers with Jenkins Wor...
Docker, Inc.
 
PDF
Effective Data Pipelines with Docker & Jenkins - Brian Donaldson
Docker, Inc.
 
PDF
Building Efficient Parallel Testing Platforms with Docker
Laura Frank Tacho
 
PDF
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
Puppet
 
ODP
Scaling your jenkins master with docker
Christophe Muller
 
PDF
Into The Box 2018 Automate Your Test
Ortus Solutions, Corp
 
PDF
JUC Europe 2015: Scaling Your Jenkins Master with Docker
CloudBees
 
PDF
Docker + jenkins in the enterprise (3)
Kurt Madel
 
PPTX
To Build My Own Cloud with Blackjack…
Sergey Dzyuban
 
PDF
Tap into the power of slaves with Jenkins by Kohsuke Kawaguchi
ZeroTurnaround
 
PDF
Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013
Carlos Sanchez
 
Using containers for continuous integration and continuous delivery - Carlos ...
Paris Container Day
 
Taking Jenkins Pipeline to the Extreme
yinonavraham
 
Jenkins Days - Workshop - Let's Build a Pipeline - Los Angeles
Andy Pemberton
 
ContainerCon - Test Driven Infrastructure
Yury Tsarev
 
Continuous Integration/Deployment with Docker and Jenkins
Francesco Bruni
 
Enabling Hybrid Workflows with Docker/Mesos @Orbitz
Steve Hoffman
 
CI/CD with Jenkins and Docker - DevOps Meetup Day Thailand
Troublemaker Khunpech
 
Jenkins days workshop pipelines - Eric Long
ericlongtx
 
TestWorks Conf Scalable QA with docker - Maarten van den Ende and Adé Mochtar
Xebia Nederland BV
 
Build, Publish, Deploy and Test Docker images and containers with Jenkins Wor...
Docker, Inc.
 
Effective Data Pipelines with Docker & Jenkins - Brian Donaldson
Docker, Inc.
 
Building Efficient Parallel Testing Platforms with Docker
Laura Frank Tacho
 
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
Puppet
 
Scaling your jenkins master with docker
Christophe Muller
 
Into The Box 2018 Automate Your Test
Ortus Solutions, Corp
 
JUC Europe 2015: Scaling Your Jenkins Master with Docker
CloudBees
 
Docker + jenkins in the enterprise (3)
Kurt Madel
 
To Build My Own Cloud with Blackjack…
Sergey Dzyuban
 
Tap into the power of slaves with Jenkins by Kohsuke Kawaguchi
ZeroTurnaround
 
Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013
Carlos Sanchez
 
Ad

More from Carlos Sanchez (13)

PDF
Divide and Conquer: Easier Continuous Delivery using Micro-Services
Carlos Sanchez
 
PDF
Scaling Docker with Kubernetes
Carlos Sanchez
 
PDF
Scaling Docker with Kubernetes
Carlos Sanchez
 
PDF
Continuous Delivery: The Next Frontier
Carlos Sanchez
 
PDF
How to Develop Puppet Modules: From Source to the Forge With Zero Clicks
Carlos Sanchez
 
KEY
Puppet for Java developers - JavaZone NO 2012
Carlos Sanchez
 
PDF
From Dev to DevOps - Codemotion ES 2012
Carlos Sanchez
 
KEY
From Dev to DevOps - FOSDEM 2012
Carlos Sanchez
 
KEY
From Dev to DevOps - ApacheCON NA 2011
Carlos Sanchez
 
KEY
From Dev to DevOps - Apache Barcamp Spain 2011
Carlos Sanchez
 
KEY
Enterprise Build And Test In The Cloud
Carlos Sanchez
 
KEY
Enterprise Build And Test In The Cloud
Carlos Sanchez
 
KEY
Eclipse IAM, Maven Integration For Eclipse
Carlos Sanchez
 
Divide and Conquer: Easier Continuous Delivery using Micro-Services
Carlos Sanchez
 
Scaling Docker with Kubernetes
Carlos Sanchez
 
Scaling Docker with Kubernetes
Carlos Sanchez
 
Continuous Delivery: The Next Frontier
Carlos Sanchez
 
How to Develop Puppet Modules: From Source to the Forge With Zero Clicks
Carlos Sanchez
 
Puppet for Java developers - JavaZone NO 2012
Carlos Sanchez
 
From Dev to DevOps - Codemotion ES 2012
Carlos Sanchez
 
From Dev to DevOps - FOSDEM 2012
Carlos Sanchez
 
From Dev to DevOps - ApacheCON NA 2011
Carlos Sanchez
 
From Dev to DevOps - Apache Barcamp Spain 2011
Carlos Sanchez
 
Enterprise Build And Test In The Cloud
Carlos Sanchez
 
Enterprise Build And Test In The Cloud
Carlos Sanchez
 
Eclipse IAM, Maven Integration For Eclipse
Carlos Sanchez
 

Recently uploaded (20)

PPTX
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
PDF
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
PDF
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
PPTX
Home Care Tools: Benefits, features and more
Third Rock Techkno
 
PPTX
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pptx
Varsha Nayak
 
PDF
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
PDF
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
PPTX
Transforming Mining & Engineering Operations with Odoo ERP | Streamline Proje...
SatishKumar2651
 
PPTX
OpenChain @ OSS NA - In From the Cold: Open Source as Part of Mainstream Soft...
Shane Coughlan
 
PDF
Alarm in Android-Scheduling Timed Tasks Using AlarmManager in Android.pdf
Nabin Dhakal
 
PPTX
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
PDF
Online Queue Management System for Public Service Offices in Nepal [Focused i...
Rishab Acharya
 
PDF
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
PDF
유니티에서 Burst Compiler+ThreadedJobs+SIMD 적용사례
Seongdae Kim
 
PPTX
Homogeneity of Variance Test Options IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
PDF
Revenue streams of the Wazirx clone script.pdf
aaronjeffray
 
PPTX
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
PDF
Download Canva Pro 2025 PC Crack Full Latest Version
bashirkhan333g
 
PDF
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
Home Care Tools: Benefits, features and more
Third Rock Techkno
 
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pptx
Varsha Nayak
 
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
Transforming Mining & Engineering Operations with Odoo ERP | Streamline Proje...
SatishKumar2651
 
OpenChain @ OSS NA - In From the Cold: Open Source as Part of Mainstream Soft...
Shane Coughlan
 
Alarm in Android-Scheduling Timed Tasks Using AlarmManager in Android.pdf
Nabin Dhakal
 
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
Online Queue Management System for Public Service Offices in Nepal [Focused i...
Rishab Acharya
 
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
유니티에서 Burst Compiler+ThreadedJobs+SIMD 적용사례
Seongdae Kim
 
Homogeneity of Variance Test Options IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
Revenue streams of the Wazirx clone script.pdf
aaronjeffray
 
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
Download Canva Pro 2025 PC Crack Full Latest Version
bashirkhan333g
 
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 

Testing Distributed Micro Services. Agile Testing Days 2017

  • 1. TESTING DISTRIBUTED MICRO-SERVICES Carlos Sanchez @csanchez csanchez.org Watch online at carlossg.github.io/presentations
  • 2. ABOUT ME Senior So ware Engineer @ CloudBees Author of Jenkins Kubernetes plugin Long time OSS contributor at Apache Maven, Eclipse, Puppet,… Google Cloud Platform "Expert"
  • 5. OUR USE CASE Scaling Jenkins Your mileage may vary
  • 9. A 2000 JENKINS MASTERS CLUSTER 3 Mesos masters (m3.xlarge: 4 vCPU, 15GB, 2x40 SSD) 317 Mesos slaves (c3.2xlarge, m3.xlarge, m4.4xlarge) 7 Mesos slaves dedicated to ElasticSearch: (c3.8xlarge: 32 vCPU, 60GB) 12.5 TB - 3748 CPU Running 2000 masters and ~8000 concurrent jobs
  • 12. Isolated Jenkins masters Isolated build agents and jobs Memory and CPU limits
  • 15. CLUSTER SCHEDULING Distribute tasks across a cluster of hosts HA and fault tolerant With Docker support of course
  • 16. INFRASTRUCTURE Running in public cloud, private cloud, VMs or bare metal
  • 17. APACHE MESOS & MESOSPHERE MARATHON A distributed systems kernel
  • 20. THE DOCKERFILE A lot like a shell script RUN comands COPY files ...
  • 21. DOCKERFILE FROM openjdk:8-jdk RUN apt-get update && apt-get install -y git curl && rm -rf /var/lib/apt/list ARG JENKINS_VERSION ENV JENKINS_VERSION ${JENKINS_VERSION:-2.19.3} ARG JENKINS_SHA=e97670636394092af40cc626f8e07b092105c07b ARG JENKINS_URL=https://repo.jenkins-ci.org/public/org/jenkins-ci/main/jenkin RUN curl -fsSL ${JENKINS_URL} -o /usr/share/jenkins/jenkins.war && echo "${JENKINS_SHA} /usr/share/jenkins/jenkins.war" | sha1sum -c - COPY jenkins-support /usr/local/bin/jenkins-support COPY jenkins.sh /usr/local/bin/jenkins.sh ENTRYPOINT ["/usr/local/bin/jenkins.sh"]
  • 22. Mocking and stubbing are your friends
  • 23. BUILDING WITH JENKINS DOCKER PIPELINE def maven = docker.image('maven:3.3.9-jdk-8'); stage 'Mirror' maven.pull() docker.withRegistry('https://secure-registry/', 'docker-registry-login') { stage 'Build' maven.inside { sh "mvn -B clean package" } stage 'Bake Docker image' def pcImg = docker.build( "examplecorp/spring-petclinic:${env.BUILD_TAG}", 'app') pcImg.push(); }
  • 24. TESTING WITH JENKINS DOCKER PIPELINE Build + test + promotion Promotion = different Docker registries for different environments dev staging production
  • 25. TESTING WITH JENKINS DOCKER PIPELINE pcImg = docker.image("examplecorp/spring-petclinic:dev") stage 'Test' docker.withRegistry('https://dev.docker.example.com/', 'docker-registry-login') { pcImg.withRun { petclinic -> sh "test -f /var/some_file" } } stage 'Promote' docker.withRegistry('https://staging.docker.example.com/', 'docker-registry-login') { pcImg.push() }
  • 26. DOCKER WORKFLOW PLUGIN DEMO https://github.com/jenkinsci/docker-workflow- plugin/tree/master/demo
  • 27. USING BATS Testing using shell scripts! bats tests/install-plugins.bats Examples from https://github.com/jenkinsci/docker/tree/master/tests
  • 28. BATS #!/usr/bin/env bats SUT_IMAGE=bats-jenkins load 'test_helper/bats-support/load' load 'test_helper/bats-assert/load' load test_helpers @test "plugins are installed with plugins.sh" { run docker build -t $SUT_IMAGE-plugins $BATS_TEST_DIRNAME/plugins assert_success run bash -c "docker run --rm $SUT_IMAGE-plugins ls -1 /var/jenkins_home/plugins" assert_success assert_line 'maven-plugin.jpi' assert_line 'maven-plugin.jpi.pinned' assert_line 'ant.jpi' assert_line 'ant.jpi.pinned' }
  • 29. BATS @test "test jenkins arguments" { local version=$(grep 'ENV JENKINS_VERSION' Dockerfile | sed -e 's/.*:-(.*)}/1/') # need the last line of output assert "${version}" docker run --rm --name $SUT_CONTAINER -P $SUT_IMAGE --help --version | tail -n 1 }
  • 30. ISOLATION There is no 100% isolation
  • 31. MEMORY ISSUES WITH CONTAINERS Scheduler needs to account for container memory requirements and host available memory Prevent containers for using more memory than allowed Memory constrains translate to Docker --memory
  • 32. WHAT DO YOU THINK HAPPENS WHEN? Your container goes over memory quota?
  • 34. WHAT ABOUT THE JVM? WHAT ABOUT THE CHILD PROCESSES?
  • 35. END TO END TESTING OF MULTIPLE CONTAINERS
  • 36. JENKINS PIPELINE WITH MULTIPLE CONTAINERS pcImg = docker.image("examplecorp/spring-petclinic:dev") stage 'Test' docker.withRegistry('https://dev.docker.example.com/', 'docker-registry-login') { pcImg.withRun {petclinic -> testImg.inside("--link=${petclinic.id}:petclinic") { wrap([$class: 'Xvnc', takeScreenshot: true, useXauthority: true]) { sh "mvn -B clean test" } } } } stage 'Promote' docker.withRegistry('https://staging.docker.example.com/', 'docker-registry-login') { pcImg.push() }
  • 38. DOCKER COMPOSE Runs multiple containers Containers can access each other
  • 39. DOCKER COMPOSE version: '2' services: example: image: acme/example:latest ports: - "5050:5050" maven: image: maven:3-jdk-8 command: mvn test
  • 40. JENKINS KUBERNETES PLUGIN The Jenkins job can run in a Kubernetes Pod (group of containers) Containers in a Pod can access each other at localhost
  • 41. KUBERNETES PLUGIN PIPELINES Ex. run maven tests against webapp with Selenium, using pre-made Docker images podTemplate(label: 'petclinic', containers: [ containerTemplate( name: 'maven', image: 'maven:3.3.9-jdk-8-alpine', ttyEnabled: true, command: 'cat'), containerTemplate( name: 'petclinic', image: 'csanchez/petclinic'), containerTemplate( name: 'selenium', image: 'selenium/standalone-firefox') ]) { node ('petclinic') { stage 'Get a Maven project' git 'https://github.com/jenkinsci/kubernetes-plugin.git' container('maven') { stage 'Build a Maven project' sh 'cd demo/test && mvn -B clean test' } } }
  • 42. HOW ARE WE DOING IT
  • 43. HOW ARE WE DOING IT On each commit and PR Provisioning of the infrastructure using Terraform Installation of the cluster scheduler (Mesos & Marathon) Continuously creating clusters from scratch
  • 45. TERRAFORM resource "aws_instance" "worker" { count = 1 instance_type = "m3.large" ami = "ami-xxxxxx" key_name = "tiger-csanchez" security_groups = ["sg-61bc8c18"] subnet_id = "subnet-xxxxxx" associate_public_ip_address = true tags { Name = "tiger-csanchez-worker-1" "cloudbees:pse:cluster" = "tiger-csanchez" "cloudbees:pse:type" = "worker" } root_block_device { volume_size = 50 } }
  • 46. TERRAFORM State is managed Runs are idempotent terraform apply Sometimes it is too automatic Changing image id will restart all instances
  • 48. IF YOU HAVEN'T AUTOMATICALLY DESTROYED SOMETHING BY MISTAKE, YOU ARE NOT AUTOMATING ENOUGH
  • 49. HOW ARE WE DOING IT In AWS and OpenStack 5 different combinations More combinations on demand
  • 50. HOW ARE WE DOING IT A er creation we launch acceptance tests Some python scripts Some Selenium tests Clusters get destroyed at the end
  • 51. MONITORING IS THE NEW TESTING We gather from the cluster: logs configuration outputs Attached to the build to diagnose errors in CI but also used by our customers to send us information
  • 52. HOW ARE WE DOING IT Feedback is published to Github PR
  • 56. AWS Resource limits: VPCs, S3 snapshots, some instance sizes Rate limits: affect the whole account Always use different accounts for testing/production and possibly different teams Retrying is your friend, but with exponential backoff
  • 58. OPENSTACK Custom flavors Custom images Different CLI commands There are not two OpenStack installations that are the same
  • 59. DANKE! RATE THIS SESSION IN AGILETESTINGDAYS.COM csanchez.org csanchez carlossg