Testing in Kubernetes is complicated. Configuring your testing tools to work with Kubernetes, giving your tests access to the cluster, and running and debugging them is a significant challenge. Developers often have to deal with multiple testing tools, each with its own reporting format, making it difficult to get a complete picture of test results.
Fortunately, tools like Testkube provide developers with a unified testing framework built for Kubernetes to simplify and streamline the entire testing process. Testkube has evolved, and in this blog post, we’ll look at Test Workflows and how they can transform testing in Kubernetes.
Since its inception, Testkube has evolved greatly, not only in terms of new feature additions but also improvement in the way it helps you test your applications. Executors in Testkube were the initial approach to running tests on Kubernetes. Let us look at the types of test executors in Testkube:
Both test executors and container executors allow you to run specific and custom test types in Testkube. Container executors were helpful when you wanted to run your custom tests. However, it wasn’t very user-friendly. Users had to do a lot of manual configurations that were tedious and error-prone for more advanced testing needs, so a better way was needed.
Building on the learnings from container executors, 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 the components specified in a test workflow, from executing tests to collecting logs and results in real-time and showing them on the Testkube dashboard.
Test Workflows are single yaml files that comprise everything required to define a test workflow. And just like tests and executors, Test Workflows are stored as custom resources in your cluster, making them easy to manage using existing Kubernetes tools and GitOps pipelines.
Test Workflows comes with a powerful templating engine that allows you to define common testing configurations which ensure standardization and consistency across your testing efforts. You can use any of our existing templates or create your own templates as needed.
Test Workflows unlock numerous advantages for improving the efficiency of your testing efforts. Some of these benefits include:
Read more about Test Workflows to see how they empower developers to deliver high-quality software faster by centralizing and streamlining the testing process.
Now that we’ve understood Test Workflows and their benefits, let's see them in action and understand how they work. In this short demo, we’ll walk through the process of creating a test workflow to execute a test and also examine how it streamlines the complete testing lifecycle.
We will use the default k6 test workflow template for this hands-on demo.
Once the prerequisites are in place, you should have a target Kubernetes cluster ready with a Testkube agent configured.
Navigate to the Test Workflows tab and click on “Add a new test workflow”
This will provide you with two options:
We’ll use a working example, but you can implement your own workflow as well. For more information, refer to our guide on creating test workflow templates.
Choose “Use a working example”
On the next tab, choose “k6 load test” and provide a name for your workflow. The spec section contains detailed specifications for your test workflow. Below is the default spec file for k6te
```yaml
kind: TestWorkflow
apiVersion: testworkflows.testkube.io/v1
metadata:
name: k6-workflow
namespace: testkube
spec:
content:
git:
uri: https://github.com/kubeshop/testkube
revision: main
paths:
- test/k6/executor-tests/k6-smoke-test.js
container:
workingDir: /data/repo/test/k6/executor-tests
resources:
requests:
cpu: 128m
memory: 128Mi
steps:
- name: Run test
run:
env:
- name: K6_SYSTEM_ENV
value: K6_SYSTEM_ENV_value
- name: K6_WEB_DASHBOARD
value: "true"
- name: K6_WEB_DASHBOARD_EXPORT
value: /data/artifacts/k6-test-report.html
args:
- run
- k6-smoke-test.js
- -e
- K6_ENV_FROM_PARAM=K6_ENV_FROM_PARAM_value
container:
image: grafana/k6:0.49.0
artifacts:
workingDir: /data/artifacts
paths:
- '*'
setup:
- shell: mkdir /data/artifacts
```
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.
Click on “Create” to create the test workflow.
Once the workflow is ready, you’ll see the newly created test workflow on the screen. Click on it and click “Run Now” to start the workflow.
You’ll see the workflow executing along with the real-time logs of every step.
After the execution, Testkube also collects all the artifacts, in this case, a k6-report where you can view all the results and outputs.
This was a straightforward demo of using Test workflows for Kubernetes testing. You can create custom workflows and import them to Testkube to take greater advantage of test workflows.
Apart from Workflows currently being integrated into the Testkube architecture to make it compatible with Test Triggers, Test Suites, Status Pages, etc., we are adding a number of powerful features not available for Tests and custom Executors:
Test workflows are the next evolution in testing for Kubernetes. By bringing the entire testing lifecycle into a single, declarative workflow, Test Workflows empower teams to scale, simplify, and standardize their testing workflows.
The benefits of adopting Test Workflows are clear, too - improve scalability consistency through templating and single spec files for easier management - to name a few.
We invite you to try Test Workflows. Visit 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 for free.
Related topics: