Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Mocks as code: Modeling AWS service providers w...

Mocks as code: Modeling AWS service providers with Testcontainers, WireMock and Localstack

When managing services at scale, you need automated testing while mocking (or modeling) the parts provided by public clouds, as well as testing entire deployment processes. This session demonstrates how to combine Localstack (for AWS integration testing), WireMock (for service mocking), and Testcontainers, a popular framework for Docker and other container engines, for comprehensive integration testing - all running in a Dev Container on your local machine.

Using Pulumi and Java as examples, you'll see live coding that demonstrates how these tools work together, with the approach applicable to any tech stack. Expect a hands-on workshop format with minimal tool requirements, showcasing developer experience for modern, containerized developer environments and practical techniques you can apply immediately to your own services.

Avatar for Oleg Nenashev

Oleg Nenashev PRO

June 26, 2025
Tweet

Resources

More Decks by Oleg Nenashev

Other Decks in Technology

Transcript

  1. 2 Java All the Way Down Up Application Unit Tests

    Build Definition and Pipelines Integration Tests Infrastructure-as-Code Deployment Pipelines Deployment Tests Production Health Checks Java the stack up all the way
  2. Today at 3 Localstack 1. If Needed: Tools Overviews and

    Integration Testing 2. Mocking and Modeling AWS services in integration tests 3. DYI developer environments with Spring Boot Dev Services 4. Infrastructure as Code (IaC) & Pulumi 5. Testing IaC locally & autotests 6. Advanced Troubleshooting
  3. > whoami @oleg_nenashev oleg-nenashev Dr. Nenashev / Mr. Jenkins Developer

    Tools Hacker Community Builder DevRel Consultant #RussiansAgainstPutin #StandWithUkraine
  4. Tell your story at KCD Suisse Romande! 04-05 December 2025

    - kcd.cloud-native-romandy.ch CFP opens on July 1st
  5. 7 Staging & QA Tests Build Integration tests Build Tests

    Gaining confidence in you software “Shift Left” with modern tools
  6. 10

  7. Workshop Prerequisites • Java 21 & your favorite IDE •

    Testcontainers-compatible Docker environment ◦ Tested on: Docker Desktop ◦ You can (try?) use: Podman, Colima, Rancher Desktop (list) ◦ OR: Testcontainers Cloud • Pulumi CLI + registration ◦ Guide: www.pulumi.com/docs/install/ 12
  8. Ways to do API integration testing 1. Testing against Production/Staging

    servers 2. Testing against a simplified/containerized instance (e.g. Testcontainers) 3. Modeling (aka Mocking) at the API provider level (e.g. WireMock or Microcks) 4. Mocking at the code level Slow Fast Nope Accu- rate * For Testcontainers, see the slides
  9. LocalStack • Local AWS Services emulation OR mocking • “awslocal”

    CLI utility • SDKs for languages and test frameworks 20 docs.localstack.cloud
  10. Some of Them 22 • Emulated: S3, SQS, … •

    Mocked: EC2 (in the FOSS lib) • Thoughts & Prayers: AWS GreenShift ;) • …
  11. 3. Configure the app to use the Mock service 35

    https://github.com/oleg-nenashev/mocks-as-code-demo/blob/main/1_application/src/test/ java/com/testcontainers/demo/MessageListenerTest.java
  12. Ways to do API integration testing 1. Testing against Production/Staging

    servers 2. Testing against a simplified/containerized instance (e.g. Testcontainers) 3. Modeling (aka Mocking) at the API provider level (e.g. WireMock or Microcks) 4. Mocking at the code level Slow Fast Nope Accu- rate * For Testcontainers, see the slides
  13. wiremock.org/docs/stubbing IF (request_url) THEN (response) * * it gets MUCH

    more complex WireMock Config JSON: Client library response request Client App Mock API Server HTTP/2 API Mocking 101
  14. API Mocking Tools Main implementation in Java Native lib, Docker

    images and Testcontainers modules Support for GraalVM Rich Ecosystem Sandbox CNCF Project Golang / Microservice arch Docker image, Testcontainers module, All-in K8s Charts Less Rich Ecosystem
  15. WireMock Ecosystem / Java • Java • Kotlin • Scala

    • Groovy • Clojure • (?)Android 43 • JUnit 4/5 • Testcontainers • Sprint Boot • Spring Cloud Contract • Quarkus • Maven • Spock • Pact
  16. 49

  17. Enter -as-Code Tools! • Infrastructure as Real Code • SDKs

    for programming languages • Standard IDEs • Standard Developer Tools • Extensibility via libraries 52
  18. 58 Java All the Way Down Up Application Unit Tests

    Build Definition and Pipelines Integration Tests Infrastructure-as-Code Deployment Pipelines Deployment Tests Production Health Checks Java the stack up all the way
  19. 65

  20. Pulumi for AWS or AWS Native? • AWS Native configuration

    is not applied for endpoints • APIs are slightly different in the package 66
  21. 67

  22. 72 Java All the Way Down Up Application Unit Tests

    Build Definition and Pipelines Integration Tests Infrastructure-as-Code Deployment Pipelines Deployment Tests Production Health Checks Java the stack up all the way
  23. Deployment Pipelines and Health Checks • There are tools for

    that, too! • Testcontainers modules for k3s and KIND • You can deploy your CI/CD tools there • Modern Java tools have wrappers, too ◦ E.g. Quarkus - docs.quarkiverse.io/quarkus-helm/dev/example-argocd • Health checks via OTel, AWS CloudWatch or CloudTrail ◦ CloudWatch is a free LocalStack plan, CloudTrail is not 73
  24. What I’m looking forward to? • Feedback from Java developers

    • Is Infra-as-Code with Java interesting to you? • Do you want Pulumi-LocalStack for Java productization?
  25. Credits 79 • Siva Prasad Reddy and Oleg Shelajev, Docker

    / ex AtomicJar • Nancy Chauhan and Anca Ghenade, ex LocalStack • The demos are based on: ◦ github.com/testcontainers/tc-guide-testing-aws-service-integrations-using-loca lstack ◦ github.com/testcontainers-community/testcontainers-wiremock-demo ◦ github.com/oleg-nenashev/spring_io_2025-Testcontainers-workshop