Scrum Gathering Portugal 2016 - Containerizing Tests with Docker

42
Containerizing Tests with Docker Stefan Teixeira @stefan_teixeira [email protected]

Transcript of Scrum Gathering Portugal 2016 - Containerizing Tests with Docker

Containerizing Tests with Docker šŸ³šŸ™

Stefan Teixeira @stefan_teixeira

[email protected]

ā€¢ QA Automation Engineer @ Toptal ā€¢ Blogs: stefanteixeira.com.br (pt-br) /

stefanteixeira.com (en)

Contact:ā€¢ E-mail: [email protected] ā€¢ Twitter: twitter.com/stefan_teixeira ā€¢ LinkedIn: linkedin.com/in/stefanteixeira ā€¢ GitHub: github.com/stefanteixeira ā€¢ SlideShare: slideshare.net/stefanteixeira

About me

VMs x Containers

https://www.docker.com/whatisdocker

Why?

Why?

ā€¢ Reprodutibility

Why?

ā€¢ Reprodutibility

Why?

ā€¢ Scalability

Why?

ā€¢ Scalability

Why?

ā€¢ Containers are (really) fast

Why?

ā€¢ Containers are (really) fast

Docker Compose

Docker Compose

ā€¢ Tool for defining and running multi-container applications

https://docs.docker.com/compose/

Docker Compose

ā€¢ Tool for defining and running multi-container applications

ā€¢ Previously known as Fig

https://docs.docker.com/compose/

Docker Compose

ā€¢ Tool for defining and running multi-container applications

ā€¢ Previously known as Fig

ā€¢ YAML ā¤

https://docs.docker.com/compose/

Compose File

Containerizing Tests with Docker

Containers != mini-VMs

https://twitter.com/rhein_wein/status/662995114235678720

Motivation

#1

If tests (except unit tests) are hard to run locally, developers will not run them.

ĀÆ\_(惄)_/ĀÆ

#2

Sometimes, itā€™s really hard to configure a test environment.

šŸ˜«

ā€œDocker delivers a predictable, reproducible testing environment."

šŸ³ā¤

(Laura Frank, Codeship)

Examples

App A

App A

DB

App A

DB Mock Service

App A

DB Mock Service

API Tests

App A

DB Mock Service

API Tests

UI Tests

App A

DB Mock Service

API Tests

UI Tests

Security Tests

App A

DB Mock Service

API Tests

UI Tests

Security Tests

Smoke Tests

https://hub.docker.com/u/selenium/

Demo

Demo

ā€¢ Very simple example, with three containers:

ā€¢ App (a REST API written in Node.js) ā€¢ DB (MongoDB database) ā€¢ API Tests (written with Supertest)

ā€¢ https://github.com/stefanteixeira/demo-testing-compose

Points of attention

ā€¢ Logs

Points of attention

ā€¢ Logs ā€¢ volumes or data containers

Points of attention

ā€¢ Logs ā€¢ volumes or data containers

ā€¢ Startup time

Points of attention

ā€¢ Logs ā€¢ volumes or data containers

ā€¢ Startup time ā€¢ wait-for-it, netcat (nc), curl, wait_for module

(Ansible)

Points of attention

ā€¢ Building images

Points of attention

ā€¢ Building images ā€¢ minimal base images: Alpine-linux, Phusion

Points of attention

ā€¢ Building images ā€¢ minimal base images: Alpine-linux, Phusion ā€¢ automate the process

Referencesā€¢ ā€œStop being lazy and test your softwareā€:

ā€¢ https://www.youtube.com/watch?v=Mx1Il9wIepw ā€¢ http://www.slideshare.net/rheinwein/stop-being-lazy-and-test-

your-software

ā€¢ https://hharnisc.github.io/2016/06/19/integration-testing-with-docker-compose.html

ā€¢ https://docs.docker.com/compose/startup-order/

ā€¢ https://github.com/vishnubob/wait-for-it

ā€¢ https://www.ansible.com/blog/six-ways-ansible-makes-docker-compose-better