Fast time-to-market is key for successful businesses, however, delivering high-quality products quickly isn’t easy. The conventional testing processes often prove to be time-consuming, resource-intensive & not easily scalable, thus hampering the delivery process.
Parallel testing is an approach that transforms testing efficiency. By simultaneously executing tests in parallel across environments, parallel testing reduces testing time, optimizes resource usage, and improves scalability.
In this post, we’ll delve further into the concept of Parallel testing and see how Testkube’s Advanced Test Orchestration empowers teams to effortlessly execute tests in parallel, thereby improving their testing practices.
Parallel testing is a testing methodology that involves running multiple tests in parallel simultaneously. These tests can be executed in the same or different environments depending on the use case. By distributing tests across multiple environments, parallel testing overcomes the drawbacks of traditional testing practices that are time-consuming and resource intensive.
Parallel testing comes with a suite of benefits, some of which are:
Testkube is a Kubernetes-native testing framework that allows you to run tests within your Kubernetes clusters by abstracting away the pain of containerizing tests. It allows the test team to store, execute and manage tests on Kubernetes clusters. It defines tests as Kubernetes CRDs to provide a modern solution for managing all your tests and scaling when needed.
Testkube allows you to perform testing either sequentially or in parallel using Advanced Test Orchestration. Through its intuitive drag & drop UI, it makes testing in parallel easier for everyone. One can add any number of tests and move them around to create a scenario that works best for them.
Being a Kubernetes-native test orchestration and execution framework, Testkube has the following benefits:
Let us see how Advanced Test Orchestration works with Testkube .
In order to demonstrate advanced test orchestration capabilities of Testkube, we’ll deploy the sock shop - a popular microservice-based application - on a Kubernetes cluster. We’ll then set up two K6 tests using the Testkube cloud - one to test the latency and the other to generate some load.
Pre-requisites
Perform the pre-requisite steps of creating Kubernetes clusters, and configuring Testkube CLI, and Agent before proceeding.
Clone the repo and deploy the sock shop to the Kubernetes cluster.
```bash
kubectl create -f deploy/kubernetes/manifests/sock-shop-ns.yaml -f deploy/kubernetes/manifests
```
Note: Steps to deploy sock-shop can vary based on your setup. Refer to sock shop documentation for more.
```bash
$ kubectl get pods -n sock-shop
NAME READY STATUS RESTARTS AGE
carts-b4d4ffb5c-h9rfr 1/1 Running 1 (5m8s ago) 21h
carts-db-6c6c68b747-ds8g4 1/1 Running 1 (5m8s ago) 21h
catalogue-759cc6b86-lctkr 1/1 Running 1 (5m8s ago) 21h
catalogue-db-96f6f6b4c-gjlnn 1/1 Running 1 (5m8s ago) 21h
front-end-5c89db9f57-65j2g 1/1 Running 1 (5m8s ago) 21h
orders-7664c64d75-wfq9l 1/1 Running 1 (5m8s ago) 21h
orders-db-659949975f-bwstw 1/1 Running 1 (5m8s ago) 21h
payment-7bcdbf45c9-hmcg2 1/1 Running 1 (8h ago) 21h
queue-master-5f6d6d4796-th489 1/1 Running 1 (5m8s ago) 21h
rabbitmq-5bcbb547d7-5jvbp 2/2 Running 2 (5m8s ago) 21h
session-db-7cf97f8d4f-x2ldg 1/1 Running 1 (8h ago) 21h
shipping-7f7999ffb7-whrb7 1/1 Running 1 (5m8s ago) 21h
user-68df64db9c-9mn9g 1/1 Running 1 (5m8s ago) 21h
user-db-6df7444fc-c77np 1/1 Running 1 (5m8s ago) 21h
```
Access the application on your browser once all the pods come to the `running` state.
Tip: If you’re running this on Minikube, you can use `minikube service list` to get the URL of the application.
To make it easier to test, we will configure a host on which the latency and load tests will run. Hence, we’ll configure the local `/etc/hosts` file and a host `192.168.49.2 django-test.com`. Replace the IP address with your IP address.
Tip: You can use `minikube ip` to get your IP address if you’re using Minikube.
Navigate to Testkube Cloud at https://cloud.testkube.io and log in with your GitHub account.
Testkube asks you to create a new environment. Environments are Kubernetes clusters where you want to execute the tests. These can be hosted on-prem or managed by a cloud provider.
Click on Add your first environment to create one and provide a name.
Configure the Testkube Agent on your cluster by copying the helm code and executing it on the cluster where you want to execute the tests.
Note: We have already configured Testkube CLI as part of the prerequisites.
Execute the command on your local cluster and allow Testkube to configure the agent. This may take a few minutes.
Once the configuration is successful, you will see the same on the dashboard as well. You can see the configured environment on the top left corner of the screen.
Creating tests in Testkube using the dashboard is very simple. Click on the Tests tab and choose `Add a new test`
Create a new test to test the latency of the sock shop application.
Provide the following details:
Test code:
```js
import { check } from 'k6'
import http from "k6/http";
export default function() {
const res = http.get('http://django-test.com:30001/index.html')
check(res, {
'status is 200': (r) => r.status === 200,
'latency is under 500ms': (r) => r.timings.duration <= 500,
})
}
```
Create a new test to perform a load test on the sock shop application.
Provide the following details:
Test code:
```js
import http from 'k6/http';
import { check } from 'k6'
export const options = {
vus: 50,
duration: '20s',
};
export default function() {
const res = http.get('http://django-test.com:30001/index.html')
check(res, {
'status is 200': (r) => r.status === 200,
})
};
```
A Test Suite in Testkube houses multiple tests, and one can plan the order of execution according to their requirements. Testkube’s Advanced Test Orchestration allows us to club tests under a test suite and makes it easy to perform parallel testing.
Navigate to the Test Suite tab and add a new test suite by providing a name for the suite.
The next step is to add the latency and load tests to the test suite.
After you’ve added the two tests, use the `+` button in the graph view to organize your tests. In this case, we click the `+` on the bottom to add a test to execute in parallel.
After adding the tests to the test suite, click “Run Now” to execute the test suite.
You can see the current state of execution of the test suite under the `Recent Executions` tab along with other details like Pass/Fail Ratio, Execution Duration, Failed Executions, and Total Executions.
After the execution is complete, you can view the results of the execution on the same screen.
To view the individual status of the tests, navigate to the Tests tab and choose a test to view its status.
In the world of fast-paced software development, parallel testing emerges as a game changer. It overcomes the issues of traditional sequential testing and allows teams to deliver software faster. Parallel testing dramatically reduces the test time, improves scalability, and optimizes resource utilization.
In the post, we saw how Testkube makes parallel testing extremely easy using Advanced Test Orchestration, thanks to the intuitive UI & a feature-loaded core. Adding & executing tests is quick and everything from logs and results is right there. To experience the full potential of Advanced Test Orchestration on Testkube, we invite you to try Testkube today.
Try out the various test types in Testkube and witness firsthand how Testkube simplifies and empowers your testing process with its Kubernetes-native capabilities. Join our Slack community for guidance and support.
Testkube is a test execution and orchestration framework for Kubernetes that works with any CI/CD system and testing tool you need, empowering teams to deliver on the promise of agile, efficient, and comprehensive testing programs by leveraging all the capabilities of K8s to eliminate CI/CD bottlenecks, perfecting your testing workflow. Get started with Testkube's free trial today!
Related topics:
Join the Testkube Community in one of these channels: