When testing microservices, creating an environment which closely mirrors production conditions is essential for developer productivity and release cadence.
On-demand environments, in which each developer or team has a separate environment in a Kubernetes cluster or namespace, are often used as a solution.
However, these environments can quickly become complicated to manage and lead to a divergence from production, causing reduced reliability in tests.
Maintaining data across several databases in numerous ephemeral environments is also a significant challenge which can lead to outdated data sets and reduced test effectiveness.
The author suggests using shared environments called “sandboxes”, which offer tunable isolation for each test client within a single shared environment.
This approach reduces resource usage and costs, eliminates ‘it works on my machine’ issues, and provides a more reliable testing environment.
However, context propagation, data isolation, and handling message queues are key considerations for implementation.
Microservices testing with on-demand environments is unsustainable as architectures grow in complexity.
The shared environment approach with sandboxes for isolation provides a more efficient, cost-effective, and scalable testing solution.
The approach has already been successfully implemented by companies such as Brex, Earnest, and DoorDash, and improved developer productivity.