Microservice testing can be complex and time consuming. The following tasks can impose a heavy workload on developers:
- Figuring out what to test
- Test creation and maintenance
- Test environments
- Test execution and analysis
- Assessing root cause
UP9 can reduce the testing workload by automatically creating and updating CI-ready test-code, executing the test-code and analyzing the results, giving developers precious time back.
Automatic Test-Automation for Microservices
First, a big shout out to Weaveworks for creating such an awesome demo microservice application and making it available.
The demo microservice application has 10-20 different microservices performing the various tasks required to operate the demo sock shop.
Let’s start with these steps:
- Install the UP9 CLI
- Install the demo application
- Deploy UP9 on the application’s Docker network
- Show a complete test-automation harness instantly created for the demo application
We’ll need the following prerequisites:
To install the UP9 CLI, we’ll simply run:
npm i -g up9
To verify installation, run:
Read more ways to install the UP9 CLI.
To install Weave Sock and verify installation, run the following commands:
git clone https://github.com/microservices-demo/microservices-demo cd microservices-demo/deploy/docker-compose docker-compose -f docker-compose.yml up
Then open your browser and go to: http://localhost/
To deploy UP9 on the application’s Docker network, first change directory to the docker-compose folder: microservices-demo/deploy/docker-compose, then run the following command in the docker-compose folder:
The operation (that takes less than a minute to complete) generates a new YAML file named: docker-compose-up9.yml.
The new file contains instructions to docker-compose to position UP9 containers for traffic observation.
To run the the demo application together with UP9, run the following command:
docker-compose -f docker-compose.yml -f docker-compose-up9.yml up
That’s it. UP9 is now deployed on the Docker network. For the test-automation to be created, we need to generate traffic. Typically you would deploy UP9 in a traffic-rich environment (e.g. integration) but here everything is deployed on a development environment (e.g. laptop), so we actually have two options to create traffic:
- Manually use the application
- Run a load test (or an end-to-end test)
Luckily, the demo application comes with a load test built in. Let’s run the load test to generate traffic using the following command:
docker run --net=host weaveworksdemos/load-test -h localhost -r 100 -c 2
UP9 automatically generates CI-ready test-code by observing the traffic. Here’s what you can do next:
- View the Observability in-Test Dashboard
- View the CI-ready test-code
- Execute the CI-ready test-code
- View the reliability analysis
The Observability-In-Test dashboard provides observability and relevant insight to the engineers involved in the practice of testing. The dashboard will include information related to test planning, creation, maintenance, execution and analysis.
Service Topology and API contracts
In the Observability-In-Test dashboard, we can look at the service topology and API-contracts.
We can also look at the business-logic that includes a graph of all the service endpoints and their logical and network dependencies.
Finally, we can view the CI-ready test-code that is automatically created. The test-code provides full coverage of the business-logic.
The CI-ready test-code includes a sequence of API calls, traversing the business-logic graph satisfying dependencies and asserting results. A sample test-code snippet looks like this:
If we consider a certain test-flow that is part of the business logic:
This is the test-code that is used to validate the test-span:
As you can see it includes the sequence of service endpoint calls, data extraction and assertions.
Now that I have a ready-to-run test-code, I’d like to run it against the demo application. As you recall, the application is installed on my laptop in a docker-compose setup.
Earlier, when we deployed UP9, we also deployed a test-runner. All I need is to point to it by selecting it in the RUN dialog:
When I execute the test-code, it runs against the demo application that is installed on my laptop without any further assistance.
Once the test-code is executed, I can view the resulting reliability analysis:
Root Cause Analysis
When I’d like to address specific failures and see what caused them, I can take a deeper look:
For example, I can see that a certain failure was caused by an assertion where the response code was expected to be 201 and it was 200. I can dig deeper into the HAR payload to see exactly what had happened:
UP9 provides an out-of-the-box test automation for microservices, kubernetes and cloud-native, replacing the need for developers to constantly build and maintain tests, while providing comprehensive service test-coverage.
- Automatic generation and maintenance of CI-ready test-code, based on service traffic
- Observability into API-contracts, business-logic and service architecture
- Automatic reliability, test-coverage and root-cause analysis
- Machine generated tests include functional, regression, performance and edge-case test-cases, covering all services and all service-endpoints
UP9 offloads the microservice testing workload from developers giving them precious time back.