Hidden gems of Testkube: k6 and Kubernetes
Introduction Testkube
Many times we may need to orchestrate our API, UI and performance tests in different places. This can often be a somewhat challenging process in terms of test management. Especially when we want to manage and monitor different test suites in one place, we have to make complex configurations.
Testkube actually gives us the answer to all these questions. By its own definition, Testkube is a Kubernetes-native testing framework. Testkube allows us to execute and monitor all our functional, performance, and security tests from one place within the Kubernetes cluster. Testkube also allows us to run different test files by fetches from repos. It allows us to manage all testing activities through Testkube, eliminating the complexity in CI/CD processes.
In this article, I will show you how you can make a difference in the world of load testing with TestKube. We will do this using k6 and as you know k6 is one of the most used and most popular load test tools of the last period.
Hidden gems of Testkube: k6 and Kubernetes
When we want to run our tests with k6 in the Kubernetes environment, we come up with a few options, one of them being the k6-operator developed by k6. If you want, you can perform these operations using the k6-operator, but the process here may lead us to different configurations and complexity. Testkube comes into play here and integrates with k6 in Kubernetes in a very short time and solves all the problems I mentioned above.
Installation Testkube
You can proceed through the documentation for Testkube installation ( https://kubeshop.github.io/testkube/installing ).
I’m going to do a quick install for Homebrew for macOS.
brew install testkube
After installing testkube, we also need to install testkube components on our Kubernetes clusters.
kubectl testkube install
That’s all, we are now ready to run our test on the cluster.
Create a Test
Let’s quickly write a k6 test and witness how easy and developer-friendly k6 is again.
After creating our test, let’s save it as k6-example.js.
Define and Run Tests into Testkube
After that, it is very easy to leave yourself in the hands of testkube and run your test with two commands.
First of all, you need to define it with “k6/script” type.
kubectl testkube create test --file path/to/your/k6-example.js --type "k6/script" --name k6-test
After we see that our definition is done as a success, we can now run.
kubectl testkube run test k6-test -f
Our test started to run successfully and we can check the logs automatically from where we run it. Apart from this, it also provides us with the commands that we can pull logs in detail after the execution is completed.
Apart from all these details, we can also see the extra logs and results on the dashboard provided by Testkube.
Now you have run your k6 load test with cloud-native way over Kubernetes cluster. Now it’s time to integrate API and UI tests and run them all together. Stay tuned.