Testing in Kubernetes environments can be complex and challenging. Developers frequently encounter difficulties configuring testing tools, accessing clusters, and managing multiple tools with different reporting formats, complicating the overall testing process.
CI/CDs, unfortunately, don't make these challenges much easier. Fortunately, platforms like Testkube provide a unified framework specifically designed to run natively in Kubernetes, streamlining the testing process. This blog post delves into the latest Test Workflow feature, highlighting their potential to revolutionize Kubernetes testing.
Test Workflows provide a comprehensive, purpose-built solution for managing the full lifecycle of running tests against your applications and their components. This includes everything from provisioning necessary infrastructure components to running tests in parallel to maximize throughput, integrating seamlessly with other testing tools, and orchestrating complex tests.
Test Workflows use Kubernetes-native capabilities to run all types of testing, from integrations tests, load testing, security tests and end-to-end tests. It executes and orchestrates all tests in a very scalable way and then collects all test data for you. Including logs, artifacts and all results in real-time while showing them to you in a very convenient dashboard.
Test Workflows are single-YAML files that comprise everything required to define a test workflow. These are stored as custom resources in your cluster, making them easy to manage using existing Kubernetes tools and GitOps pipelines.
Test Workflows has a powerful templating engine that allows you to define common testing configurations, ensuring standardization and consistency across your testing efforts.
Test Workflows improve the testing experience by providing greater flexibility and usability and accommodating simple and complex configurations. Here is how Test Workflows enhance the testing experience:
Testkube integrates with most of the well-known CI/CD tools like GitHub Actions, Jenkins, Azure DevOps, and CircleCI, to name a few. Check out our Integrations documentation to learn more.
Test workflows provide multiple benefits for increasing the effectiveness of your testing efforts. Some of the benefits include:
spec:
services:
db:
timeout: 5m
image: mongo:latest
env:
- name: MONGO_INITDB_ROOT_USERNAME
value: root
- name: MONGO_INITDB_ROOT_PASSWORD
value: p4ssw0rd
readinessProbe:
tcpSocket:
port: 27017
periodSeconds: 1
Read more about Test Workflows to see how they empower developers to deliver high-quality software faster by centralizing and streamlining the testing process.
After learning about Test Workflows and their benefits, let's see how they work. This short demo will show how to create a test workflow to execute a test and streamline the testing lifecycle.
In this post, we will walk you through creating a basic k6 Test Workflow.
Once the prerequisites are met, you should be able to launch a target Kubernetes cluster with a configured Testkube agent.
A “Create a Test Workflow” dialog appears that provides you with four options to create a test workflow:
A new dialog appears, offering a list of tests to select from. We will go with k6.
The spec section provides detailed specifications for your test workflow. The default spec file for k6 is shown below:
kind: TestWorkflow
apiVersion: testworkflows.testkube.io/v1
metadata:
name: k6-test
namespace: testkube
labels:
docs: example
spec:
content:
files:
- path: /data/example.js
content: |-
import http from 'k6/http';
import { sleep } from 'k6';
export default function () {
http.get('https://test.k6.io');
sleep(1);
};
steps:
- name: Run Tests
workingDir: /data
run:
image: grafana/k6:0.49.0
env:
- name: K6_WEB_DASHBOARD
value: 'true'
- name: K6_WEB_DASHBOARD_EXPORT
value: k6-test-report.html
args:
- run
- example.js
artifacts:
paths:
- k6-test-report.html
The spec file includes the following components:
You can change the parameters here based on your requirements, but we will not do that now. Read our test workflow document to understand more about the test workflow specification.
You can click on a step in the test workflow to view real-time progress and logs.
After the execution, Testkube collects all artifacts, in this case a k6 log report containing all of the results and outputs.
This was a simple demonstration of how to use test workflows for Kubernetes testing. To maximize the benefits of test workflows, you can create complex test workflows or import custom workflows into Testkube.
Test workflows represent a significant advancement in Kubernetes testing. They combine the entire testing lifecycle into a single, declarative format, allowing teams to improve scalability, streamline test workflows, and standardize testing operations. Improving consistency and making management easier with templating and single specification files are the obvious benefits, among others.
We invite you to try Test Workflows. Visit the Testkube website to get started. If you find yourself struggling with anything, feel free to drop a note in our active Slack community, and someone will help you out.
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: