Skip to main content
New to Testkube? Unleash the power of cloud native testing in Kubernetes with Testkube. Get Started >

Container Executor

warning

Features described in this document are being deprecated as part of the transition to Test Workflows - Read More.

The Testkube Container Executor allows you to run your own container images for executing tests. Testkube orchestrates the Tests using the container image as Kubernetes Jobs.

The Test execution fails if the container exits with an error and succeeds when the container command successfully executes.

That's the new and recommended way of running custom images. Docs about the prebuilt custom executors can be found here.

Creating and Configuring the Container Executor: cURL

In the following example, the custom cURL executor will be creating using curlimages/curl:7.85.0 image. Testkube supports interacting with custom executors using any of available methods - Testkube Dashboard, CLI, and CRD.

Let's start with Dashboard first. You can view existing executors by going to the Executors tab.

Dashboard menu - executors icon

Also in the Dashboard, you can create a new custom Container Executor. To do this, click the Create a new executor button. The executor creation dialog will be displayed. That's where you can name you executor and set the image that will be used for execution. You also need to set Executor type - that's the name you will later use in your Tests as the test type. In this example we created a custom Curl executor:

Container executor creation dialog

After the executor is created, you will be redirected to the executor settings view. That's where you can set additional settings.

Additional settings

In the Command & Arguments tab you can define the Command your custom executor will run and default arguments. Let's set the Command to curl:

Container executor settings - Command and Arguments

The Container Image tab allows you to change the container image which is used, or set Secret ref name if the image is in the private registry. Additionally, the Definition tab allows you to check the Executor CRD:

Container executor settings - Definition

The container executor is created and configured and it can be used for running tests.

Creating and Configuring a Container Executor: Playwright

Despite having the dedicated Playwright executor, you may want to use a version that isn't supported. That's where you can use the Container executor. It allows you to use any Playwright image you may need.

The example Playwright project uses Playwright 1.31.1: https://github.com/kubeshop/testkube/tree/main/test/playwright/executor-tests/playwright-project That is the specific version that is needed to run the tests. So, in this example the container executor will be created with mcr.microsoft.com/playwright:v1.31.1-focal Playwright official image. If you need another image you can find specific image tags in the Playwright Docs: https://playwright.dev/docs/docker#image-tags.

Again, let's start with the Dashboard first. In order to create a new custom Container Executor you need to go to the Executors tab and then click the Create a new executor button.

Dashboard menu - executors icon

The executor creation dialog will be displayed. That's where you can name the executor and set the image that will be used for execution. That's where you also need to set Executor type, the name you will later use in your Tests as the test type. In this example we created a custom Playwright executor:

Container executor creation dialog

After the executor is created, you will be redirected to executor settings view. That's where you can set additional seetings.

In this case you will need to set the Command that will be executed.

Container executor settings - command and arguments

Command: /bin/sh -c Arguments: npm install; npx playwright test

Input Data

You can provide input data via string, files, and Git repositories via the Testkube Dashboard. The data is downloaded into /data before the test is run using the Kubernetes Init container. When using the string type, the content is put into /data/test-content file. For example:

apiVersion: tests.testkube.io/v3
kind: Test
metadata:
name: custom-container
namespace: testkube
spec:
content:
data: |-
{
"project": "testkube",
"is": "awesome"
}
type: string
type: custom-container/test

Puts data into /data/test-content file:

cat /data/test-content
Expected output:
{
"project": "testkube",
"is": "awesome"
}

When using Git or Git directory sources, the content is placed inside /data/repo directory. For example:

apiVersion: tests.testkube.io/v3
kind: Test
metadata:
name: custom-container
namespace: testkube
spec:
content:
repository:
branch: main
type: git
uri: https://github.com/kubeshop/testkube-executor-init
type: git

Downloads into the /data/repo directory.

$ ls /data/repO
CODE_OF_CONDUCT.md CONTRIBUTING.md LICENSE Makefile README.md build cmd go.mod go.sum pkg