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

Scrum Gathering Portugal 2016 - Containerizing Tests with Docker

Feb 10, 2017

Download

Software

Stefan Teixeira
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Scrum Gathering Portugal 2016 - Containerizing Tests with Docker

Containerizing Tests with Docker 🐳🐙

Stefan Teixeira @stefan_teixeira

[email protected]

Page 2: Scrum Gathering Portugal 2016 - Containerizing Tests with Docker

• 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

Page 3: Scrum Gathering Portugal 2016 - Containerizing Tests with Docker
Page 4: Scrum Gathering Portugal 2016 - Containerizing Tests with Docker

VMs x Containers

https://www.docker.com/whatisdocker

Page 5: Scrum Gathering Portugal 2016 - Containerizing Tests with Docker

Why?

Page 6: Scrum Gathering Portugal 2016 - Containerizing Tests with Docker

Why?

• Reprodutibility

Page 7: Scrum Gathering Portugal 2016 - Containerizing Tests with Docker

Why?

• Reprodutibility

Page 8: Scrum Gathering Portugal 2016 - Containerizing Tests with Docker

Why?

• Scalability

Page 9: Scrum Gathering Portugal 2016 - Containerizing Tests with Docker

Why?

• Scalability

Page 10: Scrum Gathering Portugal 2016 - Containerizing Tests with Docker

Why?

• Containers are (really) fast

Page 11: Scrum Gathering Portugal 2016 - Containerizing Tests with Docker

Why?

• Containers are (really) fast

Page 12: Scrum Gathering Portugal 2016 - Containerizing Tests with Docker

Docker Compose

Page 13: Scrum Gathering Portugal 2016 - Containerizing Tests with Docker

Docker Compose

• Tool for defining and running multi-container applications

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

Page 14: Scrum Gathering Portugal 2016 - Containerizing Tests with Docker

Docker Compose

• Tool for defining and running multi-container applications

• Previously known as Fig

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

Page 15: Scrum Gathering Portugal 2016 - Containerizing Tests with Docker

Docker Compose

• Tool for defining and running multi-container applications

• Previously known as Fig

• YAML ❤

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

Page 16: Scrum Gathering Portugal 2016 - Containerizing Tests with Docker

Compose File

Page 17: Scrum Gathering Portugal 2016 - Containerizing Tests with Docker

Containerizing Tests with Docker

Page 18: Scrum Gathering Portugal 2016 - Containerizing Tests with Docker

Containers != mini-VMs

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

Page 19: Scrum Gathering Portugal 2016 - Containerizing Tests with Docker

Motivation

Page 20: Scrum Gathering Portugal 2016 - Containerizing Tests with Docker

#1

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

¯\_(ツ)_/¯

Page 21: Scrum Gathering Portugal 2016 - Containerizing Tests with Docker

#2

Sometimes, it’s really hard to configure a test environment.

😫

Page 22: Scrum Gathering Portugal 2016 - Containerizing Tests with Docker

“Docker delivers a predictable, reproducible testing environment."

🐳❤

(Laura Frank, Codeship)

Page 23: Scrum Gathering Portugal 2016 - Containerizing Tests with Docker

Examples

Page 24: Scrum Gathering Portugal 2016 - Containerizing Tests with Docker

App A

Page 25: Scrum Gathering Portugal 2016 - Containerizing Tests with Docker

App A

DB

Page 26: Scrum Gathering Portugal 2016 - Containerizing Tests with Docker

App A

DB Mock Service

Page 27: Scrum Gathering Portugal 2016 - Containerizing Tests with Docker

App A

DB Mock Service

API Tests

Page 28: Scrum Gathering Portugal 2016 - Containerizing Tests with Docker

App A

DB Mock Service

API Tests

UI Tests

Page 29: Scrum Gathering Portugal 2016 - Containerizing Tests with Docker

App A

DB Mock Service

API Tests

UI Tests

Security Tests

Page 30: Scrum Gathering Portugal 2016 - Containerizing Tests with Docker

App A

DB Mock Service

API Tests

UI Tests

Security Tests

Smoke Tests

Page 31: Scrum Gathering Portugal 2016 - Containerizing Tests with Docker

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

Page 32: Scrum Gathering Portugal 2016 - Containerizing Tests with Docker

Demo

Page 33: Scrum Gathering Portugal 2016 - Containerizing Tests with Docker

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

Page 34: Scrum Gathering Portugal 2016 - Containerizing Tests with Docker

Points of attention

• Logs

Page 35: Scrum Gathering Portugal 2016 - Containerizing Tests with Docker

Points of attention

• Logs • volumes or data containers

Page 36: Scrum Gathering Portugal 2016 - Containerizing Tests with Docker

Points of attention

• Logs • volumes or data containers

• Startup time

Page 37: Scrum Gathering Portugal 2016 - Containerizing Tests with Docker

Points of attention

• Logs • volumes or data containers

• Startup time • wait-for-it, netcat (nc), curl, wait_for module

(Ansible)

Page 38: Scrum Gathering Portugal 2016 - Containerizing Tests with Docker

Points of attention

• Building images

Page 39: Scrum Gathering Portugal 2016 - Containerizing Tests with Docker

Points of attention

• Building images • minimal base images: Alpine-linux, Phusion

Page 40: Scrum Gathering Portugal 2016 - Containerizing Tests with Docker

Points of attention

• Building images • minimal base images: Alpine-linux, Phusion • automate the process

Page 41: Scrum Gathering Portugal 2016 - Containerizing Tests with Docker

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