TABLE OF CONTENTS
1. whoami
2. the project
3. what do we want to test
4. what is testcontainers
5. code
6. references
Slide 3
Slide 3 text
$whoami
JUG organiser at BarcelonaJUG
Co-Founder of JBCNConf ( Barcelona )
Software Engineer at Red Hat
App. Modernisation and Migration team
@vilojona
jvilalop@redhat.com
aytartana.wordpress.com
github.com/jonathanvila
Slide 4
Slide 4 text
the project
Slide 5
Slide 5 text
Ingress
xavier
KIE Server
- jBPM -
RBAC App
- Security -
S3
bucket A
DB
Postgres
DB
Postgres
Kafka
S3
bucket B
The project
2
1
3 4
5
7
8
9
6
10
Slide 6
Slide 6 text
what do we want to test
Slide 7
Slide 7 text
What do we want to test
End to End tests
+ clients network connections
AWS S3 Kafka PostgreSQL
Slide 8
Slide 8 text
What do we want to test
End to End tests
+ clients network connections
+ external services version
PostgreSQL 9.6
KIE 7.3
Slide 9
Slide 9 text
What do we want to test
End to End tests
+ clients network connections
+ external services version
+ timeouts,params, on clients and listeners
Apache Camel Kafka AWS S3
Slide 10
Slide 10 text
What do we want to test
End to End tests
+ network steps
+ external services version
+ timeouts,params, on clients and listeners
+ background async processes
Insights Apache Camel KIE Server
Slide 11
Slide 11 text
What do we want to test
End to End tests
+ network steps
+ external services version
+ timeouts,params, on clients and listeners
+ background async processes
+ external services specific configuration
Apache Camel KIE Server
Slide 12
Slide 12 text
What do we want to test
End to End tests
+ network steps
+ external services version
+ timeouts,params, on clients and listeners
+ background async processes
+ external services specific configuration
Apache Camel KIE Server
And everything executed
in our CI process
( Github + TravisCI )
Slide 13
Slide 13 text
Have the whole test in CI
Slide 14
Slide 14 text
Testcontainers to the rescue
Testcontainers ( not TestContainers )
www.testcontainers.org
@testcontainers
Slide 15
Slide 15 text
what is Testcontainers
Slide 16
Slide 16 text
Testcontai...what ?
Testcontainers is a Java library that supports JUnit tests, providing lightweight,
throwaway instances of common databases, Selenium web browsers, or anything
else that can run in a Docker container.
Your APP JUnit test
Testcontainer
module
Docker
for Java
Docker
Container
Ingress xavier KIE Server
- jBPM -
RBAC App
- Security -
Minio
bucket A
DB
Postgres
DB
Postgres
Kafka
Localstack
bucket B
REAL
SUBSTITUTE
Components to have similar Prod env
2
1
3 4
5
7
8
9
6
10
Slide 19
Slide 19 text
Tasks with containers
Definition
OOTB Module, Docker image, Dockerfile
Start
JUnit rule, Manual, Manual parallel
Logging
Manually, SLF4J consumer
Connection
Shared network, IP & port
Finish
Manual, Automatic
Connecting to a container
Connecting
containers to a same
local network
Getting container
host and random
exposed port
Slide 25
Slide 25 text
Waiting to be ready
Wait strategy : specify the condition to consider a container as useful for testing
vs
Startup strategy : always always means wait until container is running
Slide 26
Slide 26 text
Passing properties to Spring Boot
Overriding properties
from config file
with values
from containers
Setting the context
initializer for Spring
Slide 27
Slide 27 text
Finishing the containers
Manually
Automatically
Slide 28
Slide 28 text
Ok, Ok, but …
Slide 29
Slide 29 text
The code
Slide 30
Slide 30 text
References
Slide 31
Slide 31 text
References
Testcontainers : www.testcontainers.org
@testcontainers
Docker for Java : https://github.com/docker-java/docker-java
Repository used in this presentation : https://github.com/project-xavier/xavier-integration.git
( class EndToEndTest.java )
Slide 32
Slide 32 text
Books ( devs not only consume tech )
Sci Fy
Mind
Novel
Slide 33
Slide 33 text
@vilojona
jvilalop@redhat.com
aytartana.wordpress.com
github.com/jonathanvila
Thank you :) THE
END