Slide 1

Slide 1 text

Oleg Nenashev CNCF Ambassador Modeling AWS service providers with Testcontainers, WireMock and Localstack

Slide 2

Slide 2 text

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

Slide 3

Slide 3 text

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

Slide 4

Slide 4 text

Async Q&A: Testcontainers Slack, WireMock Slack speakerdeck.com/onenashev

Slide 5

Slide 5 text

> whoami @oleg_nenashev oleg-nenashev Dr. Nenashev / Mr. Jenkins Developer Tools Hacker Community Builder DevRel Consultant #RussiansAgainstPutin #StandWithUkraine

Slide 6

Slide 6 text

Tell your story at KCD Suisse Romande! 04-05 December 2025 - kcd.cloud-native-romandy.ch CFP opens on July 1st

Slide 7

Slide 7 text

7 Staging & QA Tests Build Integration tests Build Tests Gaining confidence in you software “Shift Left” with modern tools

Slide 8

Slide 8 text

About You

Slide 9

Slide 9 text

“Shift Left”, they said? YAML, they gave? 9

Slide 10

Slide 10 text

10

Slide 11

Slide 11 text

Our Repository github.com/oleg-nenashev/workshop-aws-mocks-as-code git clone it

Slide 12

Slide 12 text

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

Slide 13

Slide 13 text

Do you `make it`? IT - Integration Tests

Slide 14

Slide 14 text

No content

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

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

Slide 18

Slide 18 text

18 https://martinfowler.com/articles/ mocksArentStubs.html

Slide 19

Slide 19 text

19 Localstack www.localstack.cloud

Slide 20

Slide 20 text

LocalStack ● Local AWS Services emulation OR mocking ● “awslocal” CLI utility ● SDKs for languages and test frameworks 20 docs.localstack.cloud

Slide 21

Slide 21 text

21 x.com/dastbe/status/1303858170155081728

Slide 22

Slide 22 text

Some of Them 22 ● Emulated: S3, SQS, … ● Mocked: EC2 (in the FOSS lib) ● Thoughts & Prayers: AWS GreenShift ;) ● …

Slide 23

Slide 23 text

Demo github.com/oleg-nenashev/workshop-aws-mocks-as-code/tree/main/3 _localstack-application 23

Slide 24

Slide 24 text

No content

Slide 25

Slide 25 text

25 SDKs testcontainers.org … and

Slide 26

Slide 26 text

No content

Slide 27

Slide 27 text

27 LOCAL STACK LocalStack Module K3s Module

Slide 28

Slide 28 text

Our Application 28

Slide 29

Slide 29 text

29 AWS S3 SQS External API Our Application

Slide 30

Slide 30 text

Spring Boot and Dev Services hdocs.spring.io/spring-boot/reference/features/dev-services.html

Slide 31

Slide 31 text

See: Presentation by Moritz Halbritter 31 https://www.youtube.com/watch?v=Yqss7tYP890

Slide 32

Slide 32 text

Demo Time 32 https://github.com/oleg-nenashev/workshop-aws- mocks-as-code/tree/main/2_api-mocking

Slide 33

Slide 33 text

1. Add Testcontainers Test 33 https://github.com/oleg-nenashev/mocks-as-code-demo/blob/main/1_application/src/test/ java/com/testcontainers/demo/MessageListenerTest.java

Slide 34

Slide 34 text

2. Init Localstack containers 34 https://github.com/oleg-nenashev/mocks-as-code-demo/blob/main/1_application/src/test/ java/com/testcontainers/demo/MessageListenerTest.java

Slide 35

Slide 35 text

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

Slide 36

Slide 36 text

4. Write your first test! 36

Slide 37

Slide 37 text

No Implementation? 37 Fake it until you “$ make it”

Slide 38

Slide 38 text

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

Slide 39

Slide 39 text

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

Slide 40

Slide 40 text

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

Slide 41

Slide 41 text

WireMock Ecosystem & Features wiremock.org/docs

Slide 42

Slide 42 text

WireMock Ecosystem wiremock.org/docs

Slide 43

Slide 43 text

WireMock Ecosystem / Java ● Java ● Kotlin ● Scala ● Groovy ● Clojure ● (?)Android 43 ● JUnit 4/5 ● Testcontainers ● Sprint Boot ● Spring Cloud Contract ● Quarkus ● Maven ● Spock ● Pact

Slide 44

Slide 44 text

Standalone WireMock in Java wiremock.org/docs/stubbing

Slide 45

Slide 45 text

45 WireMock has an official Testcontainers module! testcontainers.com/modules/wiremock

Slide 46

Slide 46 text

Example - JUnit 5 46

Slide 47

Slide 47 text

Demo Time 47 github.com/oleg-nenashev/mocks-as-code-demo

Slide 48

Slide 48 text

48 Infrastructure-as-Code, for real

Slide 49

Slide 49 text

49

Slide 50

Slide 50 text

50 And more constructive!

Slide 51

Slide 51 text

HOWTO: JavaDev-Ops 51

Slide 52

Slide 52 text

Enter -as-Code Tools! ● Infrastructure as Real Code ● SDKs for programming languages ● Standard IDEs ● Standard Developer Tools ● Extensibility via libraries 52

Slide 53

Slide 53 text

● Open-Ecosystem Tool for Infra-as-Code ● Open Source SDKs 53

Slide 54

Slide 54 text

● Multiple destinations 54 www.pulumi.com

Slide 55

Slide 55 text

● 120+ extensions: www.pulumi.com/registry/ 55 www.pulumi.com

Slide 56

Slide 56 text

Pulumi for Java 56 pulumi.com/docs/languages-sdks/java/

Slide 57

Slide 57 text

build.gradle 57

Slide 58

Slide 58 text

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

Slide 59

Slide 59 text

59 Localstack

Slide 60

Slide 60 text

Pulumi Local ● github.com/localstack/pulumi-local ● Setting the environment and the configuration right ● Just a script 60 Localstack

Slide 61

Slide 61 text

No content

Slide 62

Slide 62 text

No content

Slide 63

Slide 63 text

Hacking Time! 63 github.com/oleg-nenashev/mocks-as-code-demo/ tree/main/3_deployment

Slide 64

Slide 64 text

Read More 64 ● github.com/localstack-samples/samp le-gradle-pulumi-testcontainers/blo b/main/README.md by Nancy Chauhan and Anca Ghenade Localstack

Slide 65

Slide 65 text

65

Slide 66

Slide 66 text

Pulumi for AWS or AWS Native? ● AWS Native configuration is not applied for endpoints ● APIs are slightly different in the package 66

Slide 67

Slide 67 text

67

Slide 68

Slide 68 text

When it Goes wrong 68

Slide 69

Slide 69 text

No content

Slide 70

Slide 70 text

No content

Slide 71

Slide 71 text

No content

Slide 72

Slide 72 text

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

Slide 73

Slide 73 text

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

Slide 74

Slide 74 text

References ● Main Demo: github.com/oleg-nenashev/mocks-as-code-demo ● This and other presentations: speakerdeck.com/onenashev/

Slide 75

Slide 75 text

Keep Learning Tools 75 * AKA: Burning Out 101

Slide 76

Slide 76 text

No content

Slide 77

Slide 77 text

It’s [always] a great time to contribute! testcontainers.org/contributing wiremock.org/participate 77

Slide 78

Slide 78 text

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?

Slide 79

Slide 79 text

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

Slide 80

Slide 80 text

GitHub: oleg-nenashev Twitter: @oleg_nenashev Thank you! Any questions? Testcontainers Slack 80