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

In this article, we will demonstrate how to get an instant test-automation harness for the Weave Sock1, a demo microservice application by Weaveworks2.

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:

We’ll need the following prerequisites:

  • Docker
  • Docker-compose

Install the UP9 CLI

To install the UP9 CLI, we’ll simply run:

Copy to clipboard
npm i -g up9

To verify installation, run:

Copy to clipboard
up9 -v

up9 CLI

Read more ways to install the UP9 CLI.

Install Weave Sock

To install Weave Sock and verify installation, run the following commands:

Copy to clipboard

	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/

Weave Sock

Deploying UP9

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:

Copy to clipboard
up9 tap:create-docker-compose [give-your-workspace-a-name]

Deploying UP9 on Docker Compose

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.

UP9 Docker Instructions in YAML

To run the the demo application together with UP9, run the following command:

Copy to clipboard
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:

  1. Manually use the application
  2. 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:

Copy to clipboard
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:

Observability In-Test

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.

Microservices Topology

Business Logic

We can also look at the business-logic that includes a graph of all the service endpoints and their logical and network dependencies.

Microservices Business Logic

CI-ready Test-code

Finally, we can view the CI-ready test-code that is automatically created. The test-code provides full coverage of the business-logic.

CI Ready Test Code

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:

Business Logic Flow

This is the test-code that is used to validate the test-span:

CI Ready Test Code

As you can see it includes the sequence of service endpoint calls, data extraction and assertions.

Running the CI-ready Test-code

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:

Ready To Run

When I execute the test-code, it runs against the demo application that is installed on my laptop without any further assistance.

Ready To Run

Reliability Analysis

Once the test-code is executed, I can view the resulting reliability analysis:

Reliability Analysis

Reliability Analysis

Root Cause Analysis

When I’d like to address specific failures and see what caused them, I can take a deeper look:

Root Cause Analysis

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:

Root Cause Analysis


UP9 is a microservice testing platform for Cloud Native systems that can scale across any number of services. UP9 helps developers prevent software regressions and increase engineering productivity through effortless testing and instant virtualization.

  • Understand how services interact with each other with automatic contract discovery.
  • Ensure system-wide contract adherence with tests that write themselves.
  • Start testing early with test environments as code, automatically mocking all service dependencies.

UP9 offloads the microservice testing workload from developers, giving them precious time back.

You can sign up now for free!

Try microservices contract testing for free with UP9. Sign up now.

Join our webinar about contract testing:
"How Contract Testing Helped Cycode Prevent Software Regressions in their Kubernetes and Kafka Environments". Feb. 17th 11:30 ET / 18:30 Israel.
Sign up now.