SlideShare a Scribd company logo
© 2021 IBM Corporation
Replicating production on
your laptop using the
magic of containers
Grace Jansen
Developer Advocate
@gracejansen27
Why do we write automated
tests?
To have confidence that our applications
work the way we want them to!
System/
UI testing
Integration testing
UnitTesting
Types of testing
ManualTesting if I have
time and remember
Integration
testing
UnitTesting
What we have
time to do
Problem with just using Unit tests
Tap turns on
Tap turns off
Drain works
Sink does not overflow
Testing with
Containers
The Magic of Containers
• Virtualization from OS level
• Lightweight
• Faster start-up
• Portable with images and config files such as a Dockerfile
• Run Anywhere
• Isolation
• Complexity!
The Magic of Kubernetes
• Automated rollouts and rollbacks
• Automatic scaling of services (containers)
• Health monitoring
• Declarative management
• Deploy anywhere (Hybrid deployments)
What Magic can Developers use?
• Isolated development environments
• Portable
• Preconfigured images available
• Fast start-up of applications
• No need to have so many pre-reqs installed
• Version control of dependencies
• Can develop easily in the cloud
• True-to production testing!
What Magic can Developers use?
• Isolated development environments
• Portable
• Preconfigured images available
• Fast start-up of applications
• No need to have so many pre-reqs installed
• Version control of dependencies
• Can develop easily in the cloud
• True-to production testing!
1. Codebase
2. Dependencies
3. Config
4. Backing Services
5. Build, Release, Run
6. Stateless Processes
7. Port Binding
8. Concurrency
9. Disposability
10. Dev-Prod Parity
11. Logs
12. Admin processes
Dev-Prod Parity
Keep development, staging, and production as similar as possible
Comprised of three common issues:
• The time gap
• The personnel gap
• The tools gap
“The twelve-factor developer resists the urge to use different backing services
between development and production, even when adapters theoretically
abstract away any differences in backing services.”
IT WORKS
ON MY
MACHINE
Testing Problems that Containers can solve
• Data access such access to databases
• Integration testing
• Automatic updating and version control
• Complex setup on local machines
• Portable testing environments (So others can run the
same test easily)
• …
Testcontainers
https://www.testcontainers.org/
my-
app:latest
(app container)
mongo:4.0
(DB container)
Dev/Test env
Production env
integration
tests
end users
my-
app:latest
(app container)
mongo:4.0
(DB container)
Testcontainers
• Integration tests that are easy
to setup, write, and run
• Test your apps the same way
they run in production
• Tests are portable to any
compatible implementation:
• Liberty
• Wildfly
• Payara
• TomEE
• etc…
AvailableTestcontainer Modules:
Database Modules:
• CouchBase
• DB2
• MongoDB
• MySQL
• Postgress etc
Other Modules:
• Docker Compose
• Elasticsearch
• Kafka
• Nginx
• RabbitMQ
MicroShed Testing
http://microshed.org/microshed-testing/
What is MicroShedTesting?
The MicroshedTesting framework allows for true-to-production
integration tests on your local machine.This enables you as a
developer to minimize the amount of test failures due to differences in
dev/test and production environments. Using the magic of containers,
you can replicate what you have in your production environment
without much setup at all.
MicroShed Example
@MicroShedTest
public class MyTest {
// Search for Dockerfile.
// Start app in Container.
// Wait for Container before running tests.
@Container
public static MicroProfileApplication app
= new MicroProfileApplication()
.withAppContextRoot("/myservice");
// Inject JAX-RS REST Client
@RestClient
public static MyService mySvc;
// A test method like any other
@Test
public void testMyService() {
...
}
}
The @MicroShedTest annotation is required so
that the build knows this is a MicroShed test
The @Container annotation is required for setting
up your container to run your tests inside
The @RESTClient annotation is needed to give us
something to test against
The @Test annotation like you would in a normal
JUnit test.
SharableConfiguration
If multiple test classes can share the same container instances, they
can offload their @Container annotated fields to a sperate class like
so:
public class AppContainerConfig implements SharedContainerConfiguration {
@Container
public static ApplicationContainer app = new ApplicationContainer()
.withAppContextRoot("/myservice");
}
@MicroShedTest
@SharedContainerConfig(AppContainerConfig.class)
public class MySimpleTestA {
// ...
}
@MicroShedTest
@SharedContainerConfig(AppContainerConfig.class)
public class MySimpleTestB {
// ...
}
Different RuntimesAvailable
• Open Liberty
• Payara Micro
• Payara Sever
• Wildfly
• Quarkus
True to production
testing with MicroShed
Testing
Skills Network Labs
Skills Network Labs
Interactive Demo
Turning a JUnit test into a MicroShed test
If you would like to follow along at the same time please go to the
following link and select the “Testing a MicroProfile or Jakarta EE
Application” Module
https://openliberty.skillsnetwork.site/cloud-native-java-made-
easy-microprofile-jakarta-ee
Summary
• Containers are great!
• They make developers lives easier (portable, configurable,
lightweight…)
• They can help solve some issues with testing such as dev/test prod
parity
• There are some great open source tools available to utilise testing
with containers
• Helps speed up time to production, making everyone happier!
Resources:
• Run true-to-production tests on your MicroProfile and JakartaEE applications -
https://developer.ibm.com/languages/java/articles/true-to-production-testing-
microprofile-jakarta-ee/
• Five Java frameworks for improving your automated testing -
https://developer.ibm.com/devpractices/continuous-delivery/blogs/five-frameworks-for-
improving-your-java-automated-tests/
• Open Liberty - https://openliberty.io
• MicroShed - https://microshed.org
• Testcontainers - https://www.testcontainers.org/
• MicroProfile - https://microprofile.io/
• Jakarta EE - https://jakarta.ee/
ThankYou
Grace Jansen
@gracejansen27

More Related Content

PPSX
Mobile Suite Presentation English
PDF
apidays LIVE Australia 2021 - A cloud-native approach for open banking in act...
PDF
apidays LIVE London 2021 - Tech adoption in finance and banking by Christina ...
PDF
apidays LIVE Singapore 2021 - A cloud-native approach to open banking in acti...
PDF
T-Byte Digital customer success
PPTX
North America Strategic Modernization Exec Forum
PDF
apidays LIVE Australia 2021 - Unlocking the Internet of Things with Telco API...
PDF
Top 10 tredning technologies to learn in 2021
Mobile Suite Presentation English
apidays LIVE Australia 2021 - A cloud-native approach for open banking in act...
apidays LIVE London 2021 - Tech adoption in finance and banking by Christina ...
apidays LIVE Singapore 2021 - A cloud-native approach to open banking in acti...
T-Byte Digital customer success
North America Strategic Modernization Exec Forum
apidays LIVE Australia 2021 - Unlocking the Internet of Things with Telco API...
Top 10 tredning technologies to learn in 2021

What's hot (20)

PDF
Setup API Introductie
PDF
apidays LIVE Australia 2021 - Tracing across your distributed process boundar...
PDF
apidays LIVE Singapore - Using data to track plastic waste and recovery globa...
PDF
API-led connectivity: How to leverage reusable microservices
PDF
Geo Enabling Enterprises - Powered by Rolta i Perspective and the WSO2 ESB
PPTX
State of enterprise mobile app development 2017
PDF
IntegrationWorks: Grow Your Business with the API Economy
PDF
Infopulse AI, Data Science & RPA Managed Services
PPTX
Pragmatic approach to Microservice Architecture: Role of Middleware
PDF
AI ML by Silver Touch Tech Lab
PDF
Adopting the Right Architecture for IoT Implementation
PDF
Red Hat Mobile
PPTX
apidays LIVE LONDON - Evolving API Management for Event-Driven Digital Bankin...
PDF
apidays LIVE New York 2021 - 5 Pragmatic steps to unlock Open Finance with AP...
PDF
Digital Transformation in a World of Connected Devices
PDF
[2021 Somos Summit] - Rethinking Identity Access Management and The Rise of t...
PDF
The Role of AI and Automation
PPTX
Era of APIs: Why do we need an API strategy?
PDF
apidays LIVE Australia 2021 - How API’s are securing sensitive customer data ...
PDF
Mendix-7-Keynote
Setup API Introductie
apidays LIVE Australia 2021 - Tracing across your distributed process boundar...
apidays LIVE Singapore - Using data to track plastic waste and recovery globa...
API-led connectivity: How to leverage reusable microservices
Geo Enabling Enterprises - Powered by Rolta i Perspective and the WSO2 ESB
State of enterprise mobile app development 2017
IntegrationWorks: Grow Your Business with the API Economy
Infopulse AI, Data Science & RPA Managed Services
Pragmatic approach to Microservice Architecture: Role of Middleware
AI ML by Silver Touch Tech Lab
Adopting the Right Architecture for IoT Implementation
Red Hat Mobile
apidays LIVE LONDON - Evolving API Management for Event-Driven Digital Bankin...
apidays LIVE New York 2021 - 5 Pragmatic steps to unlock Open Finance with AP...
Digital Transformation in a World of Connected Devices
[2021 Somos Summit] - Rethinking Identity Access Management and The Rise of t...
The Role of AI and Automation
Era of APIs: Why do we need an API strategy?
apidays LIVE Australia 2021 - How API’s are securing sensitive customer data ...
Mendix-7-Keynote
Ad

Similar to JBCN_Testing_With_Containers (20)

PPTX
JLove - Replicating production on your laptop using the magic of containers
PDF
Cloud Native Dünyada CI/CD
PDF
Augmenting Software Development with Containerization in Automation Testing.pdf
PDF
Prod-Like Integration Testing for Distributed Containerized Applications
PPTX
DevOps with Elastic Beanstalk - TCCC-2014
PDF
A curtain-raiser to the container world Docker & Kubernetes
PDF
Level Up Your Integration Testing With Testcontainers
PPTX
ma-formation-en-Docker-jlklk,nknkjn.pptx
PPTX
UNITde II - Docker-Containerization.pptx,
PPTX
Devops
PPTX
Containers: DevOp Enablers of Technical Solutions
PDF
Efficient Parallel Testing with Docker
PDF
04_Azure Kubernetes Service: Basic Practices for Developers_GAB2019
PPTX
DEVNET-1169 CI/CT/CD on a Micro Services Applications using Docker, Salt & Ni...
PPTX
What is Docker?
PPTX
Docker - A curtain raiser to the Container world
PDF
Introduction to Docker
PPTX
Running eZ Platform on Kubernetes (presented by Björn Dieding at eZ Conferenc...
PDF
Role of Containerization in Automation Testing
PPTX
IM5- Introduction to DevOps tooools.pptx
JLove - Replicating production on your laptop using the magic of containers
Cloud Native Dünyada CI/CD
Augmenting Software Development with Containerization in Automation Testing.pdf
Prod-Like Integration Testing for Distributed Containerized Applications
DevOps with Elastic Beanstalk - TCCC-2014
A curtain-raiser to the container world Docker & Kubernetes
Level Up Your Integration Testing With Testcontainers
ma-formation-en-Docker-jlklk,nknkjn.pptx
UNITde II - Docker-Containerization.pptx,
Devops
Containers: DevOp Enablers of Technical Solutions
Efficient Parallel Testing with Docker
04_Azure Kubernetes Service: Basic Practices for Developers_GAB2019
DEVNET-1169 CI/CT/CD on a Micro Services Applications using Docker, Salt & Ni...
What is Docker?
Docker - A curtain raiser to the Container world
Introduction to Docker
Running eZ Platform on Kubernetes (presented by Björn Dieding at eZ Conferenc...
Role of Containerization in Automation Testing
IM5- Introduction to DevOps tooools.pptx
Ad

More from Grace Jansen (20)

PPTX
JPrime_JITServer.pptx
PPTX
SwissJUG_15_factor_app.pptx
PPTX
SwissJUG_Bringing the cloud back down to earth.pptx
PPTX
ThroughTheLookingGlass_EffectiveObservability.pptx
PPTX
PittsburgJUG_Cloud-Native Dev Tools: Bringing the cloud back to earth
PPTX
Javaland_JITServerTalk.pptx
PPTX
JavaLand_To InstantOn and Beyond.pptx
PPTX
Jfokus_Bringing the cloud back down to earth.pptx
PPTX
FooConf23_Bringing the cloud back down to earth.pptx
PPTX
DevoxxBelgium_StatefulCloud.pptx
PPTX
UtrechtJUG_Exploring statefulmicroservices in a cloud-native world.pptx
PPTX
JCON_15FactorWorkshop.pptx
PPTX
JCON_Adressing the transaction challenge in a cloud-native world.pptx
PPTX
JavaZone_Addressing the transaction challenge in a cloud-native world.pptx
PPTX
JavaZone_Mother Nature vs Java – the security face off.pptx
PPTX
Boost developer productivity with EE, MP and OL (Devoxx Ukraine 22).pptx
PPTX
Addressing the transaction challenge in a cloud-native world Devoxx Ukraine 2022
PPTX
JBCNConf_Addressing_The_Transaction_Challenge_LRA.pptx
PDF
2022-Devnexus-StatefulMicroservices.pptx.pdf
PPTX
How to become a superhero without even leaving your desk!
JPrime_JITServer.pptx
SwissJUG_15_factor_app.pptx
SwissJUG_Bringing the cloud back down to earth.pptx
ThroughTheLookingGlass_EffectiveObservability.pptx
PittsburgJUG_Cloud-Native Dev Tools: Bringing the cloud back to earth
Javaland_JITServerTalk.pptx
JavaLand_To InstantOn and Beyond.pptx
Jfokus_Bringing the cloud back down to earth.pptx
FooConf23_Bringing the cloud back down to earth.pptx
DevoxxBelgium_StatefulCloud.pptx
UtrechtJUG_Exploring statefulmicroservices in a cloud-native world.pptx
JCON_15FactorWorkshop.pptx
JCON_Adressing the transaction challenge in a cloud-native world.pptx
JavaZone_Addressing the transaction challenge in a cloud-native world.pptx
JavaZone_Mother Nature vs Java – the security face off.pptx
Boost developer productivity with EE, MP and OL (Devoxx Ukraine 22).pptx
Addressing the transaction challenge in a cloud-native world Devoxx Ukraine 2022
JBCNConf_Addressing_The_Transaction_Challenge_LRA.pptx
2022-Devnexus-StatefulMicroservices.pptx.pdf
How to become a superhero without even leaving your desk!

Recently uploaded (20)

PDF
iTop VPN 6.5.0 Crack + License Key 2025 (Premium Version)
PDF
Cost to Outsource Software Development in 2025
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
Complete Guide to Website Development in Malaysia for SMEs
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
DOCX
Greta — No-Code AI for Building Full-Stack Web & Mobile Apps
PDF
AutoCAD Professional Crack 2025 With License Key
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
How to Make Money in the Metaverse_ Top Strategies for Beginners.pdf
PDF
Autodesk AutoCAD Crack Free Download 2025
PDF
Nekopoi APK 2025 free lastest update
PDF
Salesforce Agentforce AI Implementation.pdf
PPTX
Log360_SIEM_Solutions Overview PPT_Feb 2020.pptx
PPTX
Oracle Fusion HCM Cloud Demo for Beginners
PDF
AI-Powered Threat Modeling: The Future of Cybersecurity by Arun Kumar Elengov...
PDF
CapCut Video Editor 6.8.1 Crack for PC Latest Download (Fully Activated) 2025
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
iTop VPN 6.5.0 Crack + License Key 2025 (Premium Version)
Cost to Outsource Software Development in 2025
Odoo Companies in India – Driving Business Transformation.pdf
Complete Guide to Website Development in Malaysia for SMEs
CHAPTER 2 - PM Management and IT Context
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
Greta — No-Code AI for Building Full-Stack Web & Mobile Apps
AutoCAD Professional Crack 2025 With License Key
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
How to Make Money in the Metaverse_ Top Strategies for Beginners.pdf
Autodesk AutoCAD Crack Free Download 2025
Nekopoi APK 2025 free lastest update
Salesforce Agentforce AI Implementation.pdf
Log360_SIEM_Solutions Overview PPT_Feb 2020.pptx
Oracle Fusion HCM Cloud Demo for Beginners
AI-Powered Threat Modeling: The Future of Cybersecurity by Arun Kumar Elengov...
CapCut Video Editor 6.8.1 Crack for PC Latest Download (Fully Activated) 2025
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
Wondershare Filmora 15 Crack With Activation Key [2025
wealthsignaloriginal-com-DS-text-... (1).pdf

JBCN_Testing_With_Containers

  • 1. © 2021 IBM Corporation Replicating production on your laptop using the magic of containers Grace Jansen Developer Advocate @gracejansen27
  • 2. Why do we write automated tests?
  • 3. To have confidence that our applications work the way we want them to!
  • 5. ManualTesting if I have time and remember Integration testing UnitTesting What we have time to do
  • 6. Problem with just using Unit tests Tap turns on Tap turns off Drain works Sink does not overflow
  • 8. The Magic of Containers • Virtualization from OS level • Lightweight • Faster start-up • Portable with images and config files such as a Dockerfile • Run Anywhere • Isolation • Complexity!
  • 9. The Magic of Kubernetes • Automated rollouts and rollbacks • Automatic scaling of services (containers) • Health monitoring • Declarative management • Deploy anywhere (Hybrid deployments)
  • 10. What Magic can Developers use? • Isolated development environments • Portable • Preconfigured images available • Fast start-up of applications • No need to have so many pre-reqs installed • Version control of dependencies • Can develop easily in the cloud • True-to production testing!
  • 11. What Magic can Developers use? • Isolated development environments • Portable • Preconfigured images available • Fast start-up of applications • No need to have so many pre-reqs installed • Version control of dependencies • Can develop easily in the cloud • True-to production testing!
  • 12. 1. Codebase 2. Dependencies 3. Config 4. Backing Services 5. Build, Release, Run 6. Stateless Processes 7. Port Binding 8. Concurrency 9. Disposability 10. Dev-Prod Parity 11. Logs 12. Admin processes
  • 13. Dev-Prod Parity Keep development, staging, and production as similar as possible Comprised of three common issues: • The time gap • The personnel gap • The tools gap “The twelve-factor developer resists the urge to use different backing services between development and production, even when adapters theoretically abstract away any differences in backing services.”
  • 15. Testing Problems that Containers can solve • Data access such access to databases • Integration testing • Automatic updating and version control • Complex setup on local machines • Portable testing environments (So others can run the same test easily) • …
  • 17. my- app:latest (app container) mongo:4.0 (DB container) Dev/Test env Production env integration tests end users my- app:latest (app container) mongo:4.0 (DB container) Testcontainers • Integration tests that are easy to setup, write, and run • Test your apps the same way they run in production • Tests are portable to any compatible implementation: • Liberty • Wildfly • Payara • TomEE • etc…
  • 18. AvailableTestcontainer Modules: Database Modules: • CouchBase • DB2 • MongoDB • MySQL • Postgress etc Other Modules: • Docker Compose • Elasticsearch • Kafka • Nginx • RabbitMQ
  • 20. What is MicroShedTesting? The MicroshedTesting framework allows for true-to-production integration tests on your local machine.This enables you as a developer to minimize the amount of test failures due to differences in dev/test and production environments. Using the magic of containers, you can replicate what you have in your production environment without much setup at all.
  • 21. MicroShed Example @MicroShedTest public class MyTest { // Search for Dockerfile. // Start app in Container. // Wait for Container before running tests. @Container public static MicroProfileApplication app = new MicroProfileApplication() .withAppContextRoot("/myservice"); // Inject JAX-RS REST Client @RestClient public static MyService mySvc; // A test method like any other @Test public void testMyService() { ... } } The @MicroShedTest annotation is required so that the build knows this is a MicroShed test The @Container annotation is required for setting up your container to run your tests inside The @RESTClient annotation is needed to give us something to test against The @Test annotation like you would in a normal JUnit test.
  • 22. SharableConfiguration If multiple test classes can share the same container instances, they can offload their @Container annotated fields to a sperate class like so: public class AppContainerConfig implements SharedContainerConfiguration { @Container public static ApplicationContainer app = new ApplicationContainer() .withAppContextRoot("/myservice"); } @MicroShedTest @SharedContainerConfig(AppContainerConfig.class) public class MySimpleTestA { // ... } @MicroShedTest @SharedContainerConfig(AppContainerConfig.class) public class MySimpleTestB { // ... }
  • 23. Different RuntimesAvailable • Open Liberty • Payara Micro • Payara Sever • Wildfly • Quarkus
  • 24. True to production testing with MicroShed Testing
  • 27. Interactive Demo Turning a JUnit test into a MicroShed test If you would like to follow along at the same time please go to the following link and select the “Testing a MicroProfile or Jakarta EE Application” Module https://openliberty.skillsnetwork.site/cloud-native-java-made- easy-microprofile-jakarta-ee
  • 28. Summary • Containers are great! • They make developers lives easier (portable, configurable, lightweight…) • They can help solve some issues with testing such as dev/test prod parity • There are some great open source tools available to utilise testing with containers • Helps speed up time to production, making everyone happier!
  • 29. Resources: • Run true-to-production tests on your MicroProfile and JakartaEE applications - https://developer.ibm.com/languages/java/articles/true-to-production-testing- microprofile-jakarta-ee/ • Five Java frameworks for improving your automated testing - https://developer.ibm.com/devpractices/continuous-delivery/blogs/five-frameworks-for- improving-your-java-automated-tests/ • Open Liberty - https://openliberty.io • MicroShed - https://microshed.org • Testcontainers - https://www.testcontainers.org/ • MicroProfile - https://microprofile.io/ • Jakarta EE - https://jakarta.ee/