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

WireMock8s - Mocking your APIs in Kubernetes

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.

WireMock8s - Mocking your APIs in Kubernetes

Distributed and microservice architectures are all about APIs these days, whether you use gRPC, REST API, Websockets or any other interface. There are tools for integration testing that involve API providers, including mocking them based on OpenAPI specifications. There are even Kubernetes native tools like Microcks that are scalable and provide valuable features and observability out of the box. More classic tools, including my favorite WireMock, are available on Kubernetes too.

If you’ve ever developed for JVM or .NET stacks, most likely you’ve heard about WireMock. It is a popular open-source tool and framework for API mock testing, with over 5 million downloads per month. It has implementations and adapters for many languages.

In this talk, I will focus on using WireMock for testing Cloud Native applications in Kubernetes, including using it for common continuous delivery and deployment use-cases. We will see how to use WireMock as a standalone deployment, or as a part of Argo CD and Tekton pipelines. I’ll also show how these approaches can be integrated with WireMock Cloud for those who want to do distributed testing and chaos engineering.

Avatar for Oleg Nenashev

Oleg Nenashev PRO

June 29, 2023
Tweet

Video

More Decks by Oleg Nenashev

Transcript

  1. WireMock Inc.? • Early stage startup • WireMock creator is

    a co-founder of the Inc. • WireMock Cloud - SaaS for end-to-end API mocking • Soon: K8s Edition for managed / on-premises • // We are hiring ;-) wiremock.io
  2. Disclaimer • This is a talk about is NOT about

    “VERSUS” or “OR” • There’s comparison • Your mileage may vary
  3. Outline • APIs in Cloud Native • Microcks and WireMock

    • Comparison • HOWTO: WireMock in Cloud Native app CI/CD These slides
  4. The new ecosystem is about APIs GROWTH IN WEB APIS

    SINCE 2005 Over 90% of developers use APIs. Skyrocket growth of APIs JANUARY 2006 JANUARY 2008 JANUARY 2010 JANUARY 2012 JANUARY 2014 JANUARY 2016 JANUARY 2018 MONTH The growth over time of the Programmable Web API API directory to more than 22,000 entries 22000 20000 18000 16000 14000 12000 10000 8000 6000 4000 2000 0 TOTAL API COUNT Programmable Web * Gartner Hype Cycle for APIs, 2022
  5. Open Standards • Standard specifications for APIs • Developer tools

    for the specification • Ways to share specifications between teams at early stages • Tools for serving APIs based on specifications www.openapis.org www.asyncapi.com
  6. Microcks summary • “Open source Kubernetes Native tool for API

    Mocking and Testing” • Kubernetes native • Runs in Docker and OpenShift too 14 https://microcks.io
  7. Microcks in CI/CD • You provision test APIs in CI/CD

    on-demand • Plugins and environment wrappers • Contract testing for deployed APIs 16 https://microcks.io
  8. ~4M MONTHLY DOWNLOADS OF THE JAVA LIBRARY Downloads Over the

    Last 12 Months For com..github.tomakehurst WireMock 5K STARS IN GITHUB AND GROWING 4.0K 3.0K 2.0K 1.0K 2012 2014 2016 Date 2018 2020 2022 Star history Align timeline Start – history.com Tomakehurst/wiremock 5.0K 3,036 Used by 3,036 Open Source Projects >46M Pulls of WireMock Docker Image 181 Contributors >5M Downloads a month 1.3k Forks
  9. WireMock8s • wiremock/wiremock • wiremock/wiremock-docker • wiremock/helm-charts • wiremock/grpc-wiremock •

    wiremock/wiremock-testcontainers-go Full demo will be here: github.com/oleg-nenashev/wiremock8s 23
  10. WireMock Proxy? Why? • Record & Playback for Request sequences

    • Reverse engineering of legacy undocumented APIs • Emulating complex cases ◦ Overriding particular responses ◦ Emulating response sequences / Stateful behavior ◦ Failure Injection
  11. 32 Deployment / Project WireMock Microcks “Baremetal” “External” projects *

    No JVM Yes No Docker / Container Runtimes Yes Yes K8s / Helm Yes Yes K8s Operator DIY Yes K8s / Cloud Native Scaling DIY Yes Testcontainers Yes DIY SaaS WireMock Cloud N/A Deployment * Rust implementation, .NET Core, Quarkus Native, GraalVM DIY - Do it yourself
  12. Operations / Cloud Native Experience 33 Features / Project WireMock

    Microcks CLI Yes Yes Platform SDKs Yes Code-Generated Scale to Zero DIY Yes (operator) Horizontal scaling DIY Yes (operator) OpenTelemetry integration No Yes Configuration as Code Yes Yes
  13. Features 34 Features / Project WireMock Microcks Request Matching* Yes

    Yes Response templating* Yes Yes Record & Playback Yes No (playback is on the roadmap) Stateful Behavior Yes No Async Behavior DIY (extension) Yes Fault Injection Yes DIY (hook) Chaos Engineering Yes (WireMock Cloud) DIY (hook) * WireMock is more powerful for HTTP(s), but less - for gRPC
  14. Protocols 35 Features / Project WireMock Microcks HTTP / REST

    API * Yes Yes HTTPs / SSL Yes Yes gRPC Adapter Yes GraphQL Yes (extension) Yes Async API Adapter => AWS SNS/SQS, Kafka, RabbitMQ, NATS, PubSub, MQTT No Yes CloudEvents PoC Yes (blog) Websockets No Yes * WireMock is more powerful for HTTP(s), but less - for gRPC
  15. Developer Experience 37 Features / Project WireMock Microcks Web UI

    WireMock UI*, WireMock.NET, WireMock Cloud Yes Editor / IDE integrations WireMocha for IDEA, VSCode plugins, OpenAPI Tooling Async API and OpenAPI tooling Reusable Templates Repo Yes Yes (Just Starting) REST API and OpenAPI Reverse Engineering WireMock Cloud No * Unofficial
  16. Comparison - TL;DR • Microcks is cloud native and K8s

    native • Microcks supports more protocols OOTB • Microcks implements Async API events • WireMock can be used in a cloud native way • WireMock is more powerful as Mocking tool ◦ Better form matching ◦ Record & Playback capabilities ◦ Stateful behavior • WireMock embeds in Unit/Integration tests 39
  17. 41 Testcontainers + WireMock (Docker engine is needed) My approach

    - Choosing Deployment I. Tests inside Java / JVM? II. Other stack? Use WireMock classic (WireMock Java) III. Single team / workspace? IV. Bigger setups? Use WireMock Standalone With Helm / Crossplane / etc.
  18. Repeat after me? 43 • WireMock Cloud - Free Tier

    available, use it ◦ https://www.wiremock.io/product • Demo repository: TODO
  19. WireMock8s initiatives 46 • Testcontainers Go module 1.0 • Helm

    Chart 1.0 • Better extensions support • Better observability / sub-events • Native gRPC and CloudEvents mocking • (?) OpenFeature adoption
  20. Takeaways • API Mocking/Abstraction are great • There is no

    silver bullet • There are tools for Kubernetes! • If you need a cloud native tool OOTB - Microcks • WireMock can be made cloud native too • WireMock Cloud if you need SaaS
  21. References WireMock • Website: wiremock.org • Docs: wiremock.org/docs • WireMock

    on K8s: wiremock.org/docs/solutions/kubernetes/ • WireMock Cloud: www.wiremock.io/product • WireMock and Testcontainers Microcks • Website: microcks.io • Docs: microcks.io/documentation 49