Slide 1

Slide 1 text

SIMPLIFYING CLOUD-NATIVE APP TESTING ACROSS ENVIRONMENTS Mauricio Salatino - @salaboy Laurent Broudoux - @lbroudoux

Slide 2

Slide 2 text

Demo #1

Slide 3

Slide 3 text

Cloud Native Pizza Store https://github.com/salaboy/pizza

Slide 4

Slide 4 text

Placing an order pseudo code

Slide 5

Slide 5 text

Cloud Native Pizza Store (with infra)

Slide 6

Slide 6 text

Mauricio Salatino @salaboy ● Ecosystem Engineer @ Diagrid working on Dapr ● An Open Source addict and contributor Who we are!

Slide 7

Slide 7 text

Laurent Broudoux @lbroudoux ● A Cloud-native guy - from Financial Services to OSS/Cloud vendors ● Loves everything distributed! #API, #OpenAPISpec, #AsyncAPISpec, #Kubernetes, #Integration, #Camel ● An Open Source addict and contributor ● Works at Postman in Open Technologies Dep. ● Dad, Gardener & Pastries lover 🍰 🎂 🧁 🍩 🥧 🍓 Who we are!

Slide 8

Slide 8 text

What we need for an Enterprise Application

Slide 9

Slide 9 text

• Distributed Application Runtime • CNCF Graduated Project • Multi language SDKs • Case Study https://www.cncf.io/case-studies/datagalaxy/

Slide 10

Slide 10 text

Dapr (https://dapr.io)

Slide 11

Slide 11 text

What we used for this demo

Slide 12

Slide 12 text

Let’s start with the basics

Slide 13

Slide 13 text

Service-to-Service Invocation (Store to Kitchen and Delivery)

Slide 14

Slide 14 text

Cloud Native Pizza Store (with Dapr)

Slide 15

Slide 15 text

PubSub from Kitchen and Delivery to Store Service Events

Slide 16

Slide 16 text

Cloud Native Pizza Store (with Dapr)

Slide 17

Slide 17 text

Cloud Native Pizza Store (with Dapr PubSub)

Slide 18

Slide 18 text

Part #1 - Distributed app challenges • #1 Managing cross-cutting concerns (security, resilience, observability, …) • #2 Managing cross-environment concerns (internal vs managed services, AWS vs GCP vs Azure) • Dapr to the rescue!

Slide 19

Slide 19 text

Oops… I added a new service dependency…

Slide 20

Slide 20 text

DevEx & DISTRIBUTED APPS - WHAT A BURDEN! $ mvn spring-boot:run $ ./gradlew bootRun $ npm run dev $ ./mvnw quarkus:dev $ make run $ docker compose up -d $ go run main.go $ ./kafka-server-start.sh $ postgres -D ~/pg-data

Slide 21

Slide 21 text

DevEx & DISTRIBUTED APPS - WHAT THE HELL! The Developerʼs Laptop Service A Service B Service C Database A Database B Database C OK BUT … LOTS OF COMPLEXITY LOTS OF POWER / ENERGY LOTS OF MONEY!

Slide 22

Slide 22 text

DevEx & DISTRIBUTED APPS - TAKING SHORTCUTS • Avoid Testing Integrations • Use mock frameworks only • In-VM vs Network • Rely on your own vision

Slide 23

Slide 23 text

TESTCONTAINERS to the RESCUE!

Slide 24

Slide 24 text

FROM DISTRIBUTED APPS to PROMISES to … Services & APIs Promises Contracts

Slide 25

Slide 25 text

https://microcks.io

Slide 26

Slide 26 text

INGEST PROVIDE MOCKS WELL-KNOWN ARTIFACTS 🧠 SMART MOCKS API Consumer and others MICROCKS Turn Artifacts into light & smart simulations

Slide 27

Slide 27 text

INGEST WELL-KNOWN ARTIFACTS AUTOMATIC TEST SUITE and others VALIDATE REAL API API v1.2 API v1.1 API v1.0 API Provider MICROCKS Turn Artifacts into Contract Testing Suite

Slide 28

Slide 28 text

Docker/AtomicJar partners with software vendors to maintain and certify official modules. Java, NodeJS, Go, …

Slide 29

Slide 29 text

Demo #2

Slide 30

Slide 30 text

Contract Testing in Action! ● Start your Application ● Include a library like RestAssured ● Call API endpoint and check: ○ Response status code ○ Response content-type ○ JSON evaluation ○ JSON response is valid on all paths ○ Loop on next call… Typical approach

Slide 31

Slide 31 text

Contract Testing in Action! ● Include Microcks and OpenAPI ● Launch a Microcks Test ● AssertSuccess Microcks approach ✨ : managed by Microcks Testcontainers tests ● For all operations and examples: ○ Act as an API consumer ○ Validate OpenAPI schema ✨

Slide 32

Slide 32 text

Contract Testing in Action for Async! 😱 ● Include a mocking library ● Prepare Mock object for DaprMessagingTemplate.send() ● Check that messagingTemplate.send() has been called ● Tear-down all resources Typical “lightˮ approach

Slide 33

Slide 33 text

Contract Testing in Action for Async! 😱 Microcks approach ✨ : managed by Microcks Testcontainers tests ● Include Microcks and AsyncAPI ● ● Launch a Microcks Test ● Invoke KitchenService.emitEvent() ● Start a Kafka broker ✨ ● Check that messagingTemplate.send() has been called ● + that message is sent over the wire ● + that message is on correct Kafka topic ● + that message is conformant to schema ● Tear-down all resources ✨

Slide 34

Slide 34 text

Part #2 - Distributed / DX challenges • #3 Managing more dependencies (complex setup, cost, slow, …) • #4 Testability? Confidence? (integration tests, no breaking changes) • Microcks to the rescue!

Slide 35

Slide 35 text

Building resiliency into our applications

Slide 36

Slide 36 text

Building resiliency into our applications

Slide 37

Slide 37 text

Building resiliency into our applications

Slide 38

Slide 38 text

Dapr Workflows for Durable Executions

Slide 39

Slide 39 text

Workflow as Code (Workflow)

Slide 40

Slide 40 text

Workflow as Code (Activity)

Slide 41

Slide 41 text

Jnation 2025: Durable Executions in Serverless Architectures: Cloudflare, SpringBoot & Dapr by Nele Uhlemann, Mauricio Salatino Workflow Runtime

Slide 42

Slide 42 text

Process Order Workflow • Execute each Activity until it's done • Retry in case of failure • Continue from last activity executed if the application crashes

Slide 43

Slide 43 text

Order from Prompt • Reuse workflows and activities • Integrates with your favourite tools such as Spring AI

Slide 44

Slide 44 text

Demo #3

Slide 45

Slide 45 text

Running Ollama locally 2m 40s on 1Gb internet connection!

Slide 46

Slide 46 text

Building OpenAI mocks with Microcks! OpenAPI (Primary) Collections Import Import API / Service metadata operations examples examples Test suite APIExamples {har} 🧠 LLM (Secondary Artifacts)

Slide 47

Slide 47 text

A simple OpenAI completion mock definition

Slide 48

Slide 48 text

Demo #4

Slide 49

Slide 49 text

A new Testing Nightmare? 🤯 ● Prepare an Event object ● Invoke PizzaStore.receiveEvents() handling function ● Include a mocking library ● Prepare Mock object for RestTemplate.put() ● Check that restTemplate.put() has been called ● Tear-down all resources Typical “lightˮ approach

Slide 50

Slide 50 text

A new Testing Nightmare? 🤯 ● Include Microcks and AsyncAPI ● ● ● ● ● Start a workflow instance & check that DeliveryService is called at some point ● Tear-down all resources Microcks approach ✨ : managed by Microcks Testcontainers tests ● Start a Kafka broker ● Publish mock messages on Kafka ● Check that PizzaStore.receiveEvents() is connected and can read message ● Check that consumer deserialization is ok ✨ ✨

Slide 51

Slide 51 text

Wrap-up

Slide 52

Slide 52 text

ALL TOGETHER

Slide 53

Slide 53 text

Inner or Outer Loops: Choice is yours! Setup Code Build Test Push Review Build Conform- ance Security Deploy Inner loop Outer loop Pull/Merge Request Developer Team Microcks Microcks Microcks

Slide 54

Slide 54 text

KEY TAKEAWAYS 🤔 • Building distributed applications is hard… • Making these apps portable across environment is possible using APIs, check out the Dapr SDK! • Still, the Developer Experience can be a pain… • Microcks makes mocks easy & contracts finally useful! for a better Developer Experience, for Java, .Net, etc.

Slide 55

Slide 55 text

SIMPLIFYING CLOUD-NATIVE APP TESTING ACROSS ENVIRONMENTS Mauricio Salatino - @salaboy Laurent Broudoux - @lbroudoux THANK YOU! Feedback is a gift!

Slide 56

Slide 56 text

Demo #1 🪄

Slide 57

Slide 57 text

Wrap-up 🏁

Slide 58

Slide 58 text

No content

Slide 59

Slide 59 text

No content

Slide 60

Slide 60 text

Agenda ● Distributed Applications 20 mins) ○ The Cloud Native Pizza App Demo #1 ○ Sync and Async interactions Small Dapr intro) ○ Testing and Mocking Sync and Async Demo #2 ● Building resilient applications 25 mins) ○ Dapr → Durable executions and Workflows (inner loop) Demo #3 → runs the three services) ○ Testing with real complex examples OpenAI and Dapr Workflows Demo #4 → mocks everywhere .. only store service) ● Takeaways

Slide 61

Slide 61 text

PLACEHOLDER (Part #2) • Building resilient and AI-infused applications challenges • #1 Control of durable executions • Dapr Workflows to the rescue! • #2 Speed & cost when running locally • Microcks to the rescue!

Slide 62

Slide 62 text

PLACEHOLDER (Laurent) • Distributed applications challenges • #3 More dependencies ⇒ DX + laptop setup • #4 How to test things efficiently? How to guarantee your consumers youʼre not introducing breaking changes? • Microcks to the rescue!