Skip to content

oleg-nenashev/mocks-as-code-demo

Repository files navigation

Mocks as Code for Configuration Management. Demo

Can you do full-stack development with Java? You can! And what about full-stack platform engineering? You can do it too! In this demo, we build a full-Java implementation for all key aspects of an application:

  • The application itself - Spring Boot
  • Build automation - Gradle Build Tool, aka Gradle
  • Test automation - with Testcontainers, WireMock, LocalStack and other Java tools
  • Configuration Management - with Pulumi for Java
  • All the build logic - with Gradle Build Tool, a.k.a Gradle. We will also use Gradle Build Scan for troubleshooting the Pulumi SDK issues.

This demo is created for the Mocks as Code workshop by Oleg Nenashev. The same demo setup can be implemented purely in Kotlin, Golang, Python or any other language supported by Pulumi and Testcontainers.

Presentation

The presentation for this workshop can be found here

Prerequisites

  • Java 17
  • IDE of your choice, tested on Intellij IDEA and VS Code
  • Installed Pulumi CLI application and a created account (Installation Guide)
  • Testcontainers-compatible Docker Engine, preferably Docker Desktop (see the requirements here)
  • Free-tire account on Gradle Build Scan / Develocity

For Java tools, consider using sdkman for the demo to make it easier:

sdk env install
sdk env

Workshop Steps

  1. Setting up the environment
  2. Testing AWS Service Integrations using LocalStack and Testcontainers, similar to this guide
  3. Mocking service APIs with WireMock
  4. Infrastructure-as-Code with Pulumi and Pulumi SDK for Java, and using the same stack for Pulumi deployment integration testing
  5. Advanced troubleshooting and observability of the configurations with Gradle Build Scan

Credits

The code implementation is based on the aws-java-webserver example from pulumi/examples.

Some bits of the demo are inspired by Pulumi CLI fo LocalStack wrapper, which is adapted inside the integration test. The bits of the demo will be converted to a Java implementation for it, contributions are welcome!

Read More

When something fails

To force kill the Pulumi stack:

pulumi stack rm --force oleg-nenashev/mocks-as-code/mocks-as-code-demo

License

Most of the code is licensed under the Apache License v2, unless specified differently.

The application code is based on the Testing AWS Service Integrations using LocalStack demo, and, hence, it uses the MIT License.