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

Taming and Testing the Cloud Environment for your Java apps with LocalStack & Testcontainers (Java Vienna 2024)

Taming and Testing the Cloud Environment for your Java apps with LocalStack & Testcontainers (Java Vienna 2024)

Presentation given at the Java Vienna meetup on the 8th of January 2024.
Resources used:
Main demo: https://github.com/localstack-samples/sample-shipment-list-demo-lambda-dynamodb-s3
Testcontainers demo using the Java AWS SDK for creating resources: https://github.com/tinyg210/testcontainers-shipment-list-demo
Testcontainers demo using Cloud Pods for pre-seeding the test environment: https://github.com/tinyg210/testcontainers-shipment-list-cloud-pods

Anca Ghenade

January 09, 2024
Tweet

More Decks by Anca Ghenade

Other Decks in Programming

Transcript

  1. Taming and Testing the Cloud Environment for your Java apps

    with LocalStack & Testcontainers 08.01.2024 Vienna
  2. 2. Developing on a local machine, they soon find out

    that there are lots of dependencies with resources in the cloud
  3. 3. They realize that the dev & test loop is

    extremely slow and tedious. Every local change needs to be packaged and uploaded to the cloud for testing.
  4. 4. Now someone has a red build on their feature

    branch, but can’t efficiently test and debug their code in the CI/CD pipeline.
  5. 5. The whole team is using Git flow for development

    - one CI build per feature branch. There is an explosion of different environments required for development (branches x developers).
  6. 6. The manager approaches the team and complains that AWS

    dev/test resources are not being cleaned up properly causing cost spikes.
  7. What is LocalStack and how can it help you? A

    fully functional local cloud stack that was born out of these exact concerns.
  8. • Enables a highly efficient dev & test loop for

    cloud apps • Ships as a Docker image, easy to install and start up • Support for 90 (-ish) services (and growing): ◦ compute (Lambda, ECS, EKS) ◦ various databases (DynamoDB, RDS) ◦ messaging (SQS, Kinesis, MSK) ◦ some sophisticated/exotic APIs (Athena, Glue) • CI integrations & advanced collaboration features • Branching out into other areas: Chaos Engineering, IAM Security Testing, Cloud Ephemeral Environments, 3rd Party Extensions, etc
  9. 2. You use AWS CLI scripts via init hooks. (example:

    https://github.com/tinyg210/stack-bytes-apigw-lambda-s3)
  10. 5. Use a mix of all of the above. -

    export only desired services with Cloud Pods - manage other resources via SDK clients
  11. • Automated Testing • Continuous Deployment • Integration Testing •

    Code Quality Analysis • Infrastructure as Code (IaC) Validation • Containerization and Orchestration • Feature Branch Testing • Rollbacks and Blue/Green Deployments • Performance Testing and Scalability • Automated Documentation Generation
  12. • Automated Testing • Continuous Deployment • Integration Testing •

    Code Quality Analysis • Infrastructure as Code (IaC) Validation • Containerization and Orchestration • Feature Branch Testing • Rollbacks and Blue/Green Deployments • Performance Testing and Scalability • Automated Documentation Generation
  13. Use a waiter to make sure your Lambdas are in

    state ACTIVE and not just created.
  14. Use this nifty configuration to scan the LocalStack logs and

    make sure your instance is in the right state before the tests are allowed to start: