Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Move fast and don’t break things! Testing with docker, ansible and jenkins


Published on

How to set up your testing infrastructure using Docker, Ansible and Jenkins to run multiple tests from different environments and optimize for speed. A good example of what Continuous Integration means and how to integrate a complete test suite with Github. Jumpstart your tests by using Docker images and automate with Ansible playbooks.

Published in: Internet
  • Be the first to comment

Move fast and don’t break things! Testing with docker, ansible and jenkins

  1. 1. Testing with Jenkins, Docker and Ansible
  2. 2. Move fast, but don’t break things ● Agile development ● Continuous Integration ● But don’t break production ● Testing, testing, testing
  3. 3. Goals ● Test everything after committing to master ● Test on different platforms ● Reduce testing time ● Automate and re-use
  4. 4. But why so many tests? ● Test the deployment of the app in a clean environment, a fresh build. ● Test the deployment in a staging environment and ensure backwards compatibility ● Test the interface against multiple browsers
  5. 5. Jenkins ● Mature and widely used ● Very flexible ● Easily extendable via plugins ● Github integration
  6. 6. Docker ● Fast and lightweight containers ● Docker images can jumpstart the process ● Dockerfiles for automation ● Docker repositories let us reuse images
  7. 7. Ansible ● Deployment automation ● Flexible configuration through playbooks ● Orchestration
  8. 8. The Process ● Jenkins responds to Github commits ● Calls Ansible to spawn our test servers ● Servers use Docker images to optimize test speed
  9. 9. Dockerfile example FROM ubuntu:latest MAINTAINER RUN echo "deb precise main universe" > /etc/apt/sources.list RUN apt-get update RUN mkdir MIST RUN cd MIST && git clone WORKDIR MIST/ RUN git pull RUN virtualenv . && ./bin/pip install --upgrade setuptools RUN ./bin/python && ./bin/buildout -N ADD ./ src/mist/io/tests/features/ ADD ./ / ENTRYPOINT ./
  10. 10. Dockerfile example ● FROM Chooses the base image (ubuntu/latest) ● RUN Runs the following commands. ● ADD Adds files from our host machine to the docker image. ● ENTRYPOINT This tells docker to start with ./ script every time we run the image
  11. 11. Ansible hosts file Group your servers in an ansible_hosts file: [testservers] testserver1 ansible_ssh_host= testserver2 ansible_ssh_host= testserver3 ansible_ssh_host=[testservers:vars] ansible_ssh_user=mister ansible_ssh_private_key_file=~/.ssh/testkey
  12. 12. Define docker in playbook - name: Add Docker repository key sudo: True apt_key: url=""- name: Add Docker repository sudo: True apt_repository: repo: 'deb docker main' update_cache: yes- name: Install Docker sudo: True apt: pkg=lxc-docker state=present notify: "Start Docker"
  13. 13. Define docker in playbook - name: Make dir for io docker files command: mkdir -p docker/iotest- name: Copy io Dockerfiles template: src=templates/iotest/Dockerfile.j2 dest=docker/iotest/Dockerfile- name: Copy io init scripts copy: src=templates/iotest/ dest=docker/iotest/ name: Build docker images for io sudo: True command: docker build -t mist/iotest docker/iotest
  14. 14. Thank you! ● Jenkins-Github integration: https://wiki.jenkins- ● Complete code and examples: fast-and-dont-break-things-testing-with ● A more advanced Ansible setup: testing-with-jenkins-ansible-and-docker/