Continuous Testing With CircleCI and Testkube

Continuous Testing With CircleCI and Testkube

Last updated
June 1, 2024
Bruno Lopes
Product Leader
Share on X
Share on LinkedIn
Share on Reddit
Share on HackerNews
Copy URL

Table of Contents

Start Using Testkube for Free Today

The software development process today is more than just writing the logic for your application. It involves critical tasks like testing, integration,  deployment, and monitoring, to name a few. And with everyone wanting to ship features faster, the balance between speed and quality is critical. 

Continuous testing comes in to maintain that balance - ensuring that every line of code is checked, always. TestOps as we refer to it, is the practice of integrating continuous testing into your DevOps process.

In this blog post, we’re going to look at one of the popular CI tools, Circle CI and how Testkube integrates with it. 

CircleCI and Testkube - Unleashing Efficiency

CircleCI is one of the popular CI/CD tools that efficiently manages the processes of building, testing, and deploying code changes. It allows you to connect with any of your existing projects in GitHub, GitLab, etc. At the heart of this is a config.yml file where a set of instructions specifying the workflow is configured. Based on that, it triggers the pipelines, removing manual intervention. This allows for reliable and rapid delivery of features.

Testkube is a framework designed for versatility. It allows you to bring any testing tool that you use and enable them to work with Kubernetes seamlessly. With the help of CRDs, Testkube allows you to manage your tests as code. It is designed to integrate with CI/CD tools like GitHub Actions, GitLab CI and Jenkins to name a few, enabling TestOps.

Integrating Testkube with CircleCI brings in multiple benefits, including the following:

  • TestOps Implementation: Testkube’s integration with CircleCI helps implement TestOps, removing the barrier between development and testing workflows. Doing so enables continuous testing that leads to rapid and reliable deployments. 
  • Continuous Testing: With integration with CircleCI, you can enable continuous testing throughout your development lifecycle. Tests are executed on every code change which ensures that every change is validated earlier in the development cycle. 
  • Accelerated Development: CircleCI triggers workflows on every code change automatically and feedback is received earlier in the cycle. This leads to faster development and deployment of features.

Integrating CircleCI with Testkube

To understand how Testkube integrates with CircleCI workflows, we’ll use the existing GitLab repo from our previous blog post. Below is what we are going to do:

  • Create a new project in CircleCI by adding an existing repo from GitLab.
  • Modify the GitLab repo and configure it to work with CircleCI - create a .circleci folder with a config.yml file.
  • Add Testkube configuration to the confi.yml file and let the workflow run on every commit to the repo.
  • The workflow will create a k6 test on Testkube that is configured on a cluster. 
  • Lastly, we’ll configure a branch protection rule that will not allow a change to be merged if the test fails.

This was the high-level overview of what we are going to do.

The code for this integration is available in this repo. The repo contains a directory named k6,  which contains the test. A .circleci folder with `config.yml` file that contains the code for the automated workflow.


Once the prerequisites are in place, you should have a target Kubernetes cluster ready with a Testkube agent configured. You should also have a GitLab repository configured with CircleCI that is integrated with Testkube.

Note: Refer to our API Token document to create the API token. To find the Org ID and environment IDs, log in to your Teskube Cloud dashboard, head to any existing tests page, navigate to CI/CD integration, and choose GitLab. Copy the environment and organization IDs from here.  

You’ll also need to create variables in CircleCI to store these IDs and the token. 

K6 Test

We will create a k6 test that performs a load test on the website and checks if the response time is less than 1000 milliseconds. If the response is more than that, the test will fail.


import http from 'k6/http';
import { check, sleep } from 'k6';

export let options = {
  vus: 1, // Virtual Users
  duration: '10s', // Duration of the test

export default function () {
  // Send an HTTP GET request to the website
  let response = http.get(''); // Replace with your URL

  // Check if the response time is less than 1000 milliseconds
 check(response, {
    'Response time is less than 1000 milliseconds': (r) => r.timings.duration < 1000, // Check if response time is less than 1000 milliseconds

  // Add a sleep period (in this case, 1 second) between requests


Configuring CircleCI Pipeline

We configure the CI pipeline job to execute whenever a new merge request is made. The job uses the Testkube API key, ORG_ID, and ENV_ID which are saved as CircleCI variables.


version: 2.1
      - image: kubeshop/testkube-cli
    working_directory: /.testkube
      - run:
          name: "Set Testkube Context"
          command: "testkube set context --api-key $TESTKUBE_API_KEY --org $TESTKUBE_ORG_ID --env $TESTKUBE_ENV_ID"
      - run:
          name: "Trigger Testkube tests"
          command: "testkube run test k6-kubeshop-test -f"
      - run-tests


Pro Tip: You can also use this sample workflow generated by Testkube to create and configure your CircleCI pipeline.

The above workflow does the following things:

  • Configures the CI job to connect with Testkube cloud using the Testkube token, organization, and environment ID.
  • Creates and executes the k6 test using `kubeshop/testkube-cli` on the EKS cluster.
  • Based on the result, the status will be updated in the MR. If the test passes, the merge option will be enabled, and anyone can merge it. However, if the test fails, the merge will not be available - we’ll configure an auto-merge protection rule to prevent the PR from being merged if the run fails.

Configure GitLab Project in CircleCI

When you log in to CircleCI, it prompts you to create a new project. You can easily import an existing project that has the CircleCI configuration already created. That’s the fastest way to configure CircleCI with GitLab.

Once the project is created, it will take you to the pipelines page. It won’t have any details as we’ve not executed a pipeline yet. This will auto-populate when new pipeline is triggered.

You can find more details on how to configure here.

Trigger Testkube Test

To check if everything works correctly, raise a new MR in the repository with some changes. You’ll see that your action is triggered almost immediately.

You can see that there are two jobs running, that’s because we’ve also configured the Gitlab workflow to run alongside it to show how we can have multiple jobs in the same pipeline. The CircleCI job is marked as external. You can click on it to view the details on the CircleCI dashboard.

In the background, our test will run on the target Kubernetes cluster specified. If the test passes, our CI job will update the status in the PR, and a user can merge the PR. 

However, if the workflow fails, the CI job will update the workflow status as failed in the PR. Merging will be blocked because of the branch protection rule that we have created, which prevents merging if the test fails.

With this example, we have seen how easy it is to configure Testkube with CircleCI and GitLab. One can perform advanced scenarios by tweaking the workflow and configuring your repositories based on your requirements.


We looked at the critical importance of continuous testing in making your testing practices more effective and efficient. To illustrate this, we saw how Testkube seamlessly integrates with CircleCI to add continuous testing capabilities to your DevOps processes.

For a more in-depth understanding of Testkube and how it integrates with your CI/CD platforms along with using any testing tool, refer to our documentation. We also suggest you try Testkube first-hand to understand the benefits of Testkube.

Try it out today by signing into Testkube. And join our Slack community for guidance and support.

About Testkube

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.