Making your own Testcontainers module for fun and profit!

A presentation at All Things Open 2024 in October 2024 in Raleigh, NC, USA by Oleg Šelajev

Slide 1

Slide 1

Making your own Making yourmodule own Testcontainers for fun and profit! Testcontainers module for fun and profit!

Slide 2

Slide 2

What is productivity? The developer-centric approach to measuring and improving productivity. Abi Noda, DX Margaret-Anne Storey, University of Victoria Nicole Forsgren, Microsoft Research Michaela Greiler, DX https://queue.acm.org/detail.cfm?id=3595878

Slide 3

Slide 3

Slide 4

Slide 4

TESTS

Slide 5

Slide 5

Slide 6

Slide 6

Slide 7

Slide 7

Slide 8

Slide 8

Test dependencies as code Testcontainers is an open source library for providing ephemeral, lightweight instances of test dependencies. var redis = new GenericContainer(“redis:6-alpine”).withExposedPorts(6379)

Slide 9

Slide 9

Testcontainers: Test dependencies with real services wrapped in Docker containers var granite = new GenericContainer(“redhat/granite-7b-lab-gguf”).withCommand(“—serve”) Testcontainers Library Testcontainers Desktop Testcontainers Cloud Fast, reasistic, cost-effective dependencies Better local development and debugging experience Operationalize and roll out Testcontainers across the teams

Slide 10

Slide 10

Testcontainers modules Test against any database, message broker, browser… or just about anything that runs in a Docker container!

Slide 11

Slide 11

start.spring.io has it :)

Slide 12

Slide 12

Slide 13

Slide 13

Testcontainers module functionality Container & Service Configuration Lifecycle API Convenience methods

Slide 14

Slide 14

Slide 15

Slide 15

Slide 16

Slide 16

Slide 17

Slide 17

Slide 18

Slide 18

Slide 19

Slide 19

protected void configure()

Slide 20

Slide 20

Convenience methods

Slide 21

Slide 21

TEST! 🔥🔥 🔥 DEMO TIME

Slide 22

Slide 22

Custom Commands

Slide 23

Slide 23

Slide 24

Slide 24

Slide 25

Slide 25

Slide 26

Slide 26

KafkaContainer this.setCommand(new String[]{“-c”, “while [ ! -f /testcontainers_start.sh ]; do sleep 0.1; done; /testcontainers_start.sh”});

Slide 27

Slide 27

KafkaContainer this.setCommand(new String[]{“-c”, “while [ ! -f /testcontainers_start.sh ]; do sleep 0.1; done; /testcontainers_start.sh”});

Slide 28

Slide 28

Networks

Slide 29

Slide 29

Slide 30

Slide 30

Docker configuration

Slide 31

Slide 31

Slide 32

Slide 32

Slide 33

Slide 33

Tools in containers

Slide 34

Slide 34

Tools in containers

Slide 35

Slide 35

TEST! 🔥🔥 🔥 DEMO TIME

Slide 36

Slide 36

https://github.com/testcontainers/java-module-worksh op https://github.com/testcontainers/workshop https://testcontainers.com/desktop https://slack.testcontainers.com

Slide 37

Slide 37

Booth 35!