Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Integration and end-to-end testing with TestСontainers
Search
Nikolay Kuznetsov
June 26, 2019
Programming
0
15
Integration and end-to-end testing with TestСontainers
Nikolay Kuznetsov
June 26, 2019
Tweet
Share
More Decks by Nikolay Kuznetsov
See All by Nikolay Kuznetsov
Integration testing with TestСontainers-Go
nikolayk812
0
120
Integration testing with TestContainers-Go
nikolayk812
0
180
Integration testing with TestСontainers and JUnit 5
nikolayk812
0
150
TestContainers + JUnit 5 = elegant integration and e2e tests for microservices
nikolayk812
2
260
Integration and end-to-end testing with TestСontainers
nikolayk812
0
81
Other Decks in Programming
See All in Programming
複雑なドメインを扱うプロダクトの探索フェーズではいつどのようにテストをするのか / How to testing during exploratory phase
boykush
2
150
Some Quick Ideas To Improve Your Tests ( #jassttokyo )
teyamagu
PRO
2
2.3k
Creating Retro-Style Photos Using Swift
ski
1
370
Ruby製社内ツールのGo移行
bgpat
2
270
Learning PHP and Static Analysis with PHP Parser
inouehi
1
250
生成 AI の中身を覗いてみよう〜基礎から医療現場での応用まで〜
soh9834
2
770
ファイル先頭の use の意味、説明できますか? 〜PHP の namespace と autoloading の関係を正しく理解しよう〜 / namespace and autoloading in php
okashoi
2
470
せっかくモデル図描くのなら、嬉しいことが多い方がいいよね!
kuboaki
1
1.8k
Prepare for Jakarta EE 11 - Performance and Developer Productivity
ivargrimstad
0
530
品質が高いコードって何?Rev2.1
ickx
1
490
AppDeveloperCon 2024 EU: Building polyglot developer experiences in 2024
salaboy
0
380
WebComponentsで フレームワークを1ページに共存させる
webuilder240
0
150
Featured
See All Featured
How to train your dragon (web standard)
notwaldorf
71
5.1k
Designing with Data
zakiwarfel
94
4.8k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
319
20k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
242
20k
The Language of Interfaces
destraynor
150
23k
Code Review Best Practice
trishagee
54
15k
The Cult of Friendly URLs
andyhume
73
5.6k
Fashionably flexible responsive web design (full day workshop)
malarkey
397
65k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
113
18k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
19
1.6k
Put a Button on it: Removing Barriers to Going Fast.
kastner
58
3k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
58
14k
Transcript
Integration and end-to-end testing with TestСontainers Nikolay Kuznetsov @nikolayk812 ContainerDays,
Hamburg, 26 June 2019
About me • Go developer at Zalando Helsinki • Java
developer at Infobip, DevExperts • C developer at Samsung, Motorola
Why integration testing?
Trade-offs Test Runtime
Integration testing evolution • In-memory mocking • Local DBs •
Vagrant • Docker, Docker Compose • Docker API
How to start Docker containers for integration test? • Shell
scripts • Maven plugin • Docker Compose • … • MiniKube, Kubernetes
Shell scripts
Maven plugins github.com/fabric8io/docker-maven-plugin
Docker Compose
None
TestContainers • github.com/testcontainers/testcontainers-java • Wraps docker-java library • Docker environment
discovery • Host port randomization • Containers clean up on JVM shutdown • Waiting strategies
As simple as static PostgreSQLContainer postgres = new PostgreSQLContainer(); static
GenericContainer redis = new GenericContainer("redis:5.0.5") .withExposedPorts(6379);
Docker environment discovery
Host port randomization • To prevent port conflicts • Enables
parallel builds • API to get a host port
Containers cleanup https://github.com/testcontainers/moby-ryuk
Waiting strategies
Demo github.com/nikolayk812/cd-tc-demo
Why end-to-end testing? • Test business flows which go through
multiple microservices before production deployment • Replace a legacy service with a new implementation, make sure business flows hold
E2E setup Item Service User Service Spring Cloud Netflix Eureka
None
Demo github.com/nikolayk812/cd-tc-demo
Hints • Host port forwarding Testcontainers.exposeHostPorts() • Fixed host port
for remote debug GenericContainer.addFixedExposedPort() • Disable Ryuk set env TESTCONTAINERS_RYUK_DISABLED=true
Alternatives to E2E testing Goal is to minimize chances of
breaking production • Staging environments Handling team boundaries? • Canary deployment • Contract testing Spring Cloud Contract
Modules • 10+ DB modules • MockServer • LocalStack =
Atlassian’s local AWS cloud stack • Toxiproxy • Kafka
Takeaways • https://testcontainers.org • Balance between flexibility, speed and features
• Works on Mac, Linux, Windows
Thank you! @nikolayk812 nikolayk812