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

Tracetest

warning

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

Testkube supports running trace-based tests with Tracetest.

๐ŸŽ“What is Tracetest?
  • Tracetest is a OpenTelemetry based tool that helps you develop and test your distributed applications. It assists you in the development process by enabling you to trigger your code and see the trace as you add OTel instrumentation.
What can I do with Tracetest?
  • Tracetest uses your existing OpenTelemetry traces to power trace-based testing with assertions against your trace data at every point of the request transaction.

By using the Testkube Tracetest Executor you can now add Tracetest to the native CI/CD pipeline in your Kubernetes cluster. This allows you to add all the additional Testkube functionalities, like running scheduled test runs and using Test Triggers. All while following the trace-based testing principle and enabling full in-depth assertions against trace data, not just the response.

Running a Tracetest Testโ€‹

In order to run Tracetest tests using Testkube, you will need to have the following in your Kubernetes cluster:

  1. Testkube
  2. Tracetest
  3. An OpenTelemetry Instrumented Service

To install Tracetest, refer to Tracetest's documentation.

To create the test in Testkube, you'll need to export your Tracetest Test Definition. An example of an exported Tracetest definition looks like the following:

type: Test
spec:
id: RUkKQ_aVR
name: Pokeshop - List
description: Get a Pokemon
trigger:
type: http
httpRequest:
url: http://demo-pokemon-api.demo/pokemon?take=20&skip=0
method: GET
headers:
- key: Content-Type
value: application/json
specs:
- name: Database queries less than 500 ms
selector: span[tracetest.span.type="database"]
assertions:
- attr:tracetest.span.duration < 500ms

Add Test to Testkubeโ€‹

To add your Tracetest tests to Testkube, use the create test command. You'll need to reference the .yaml file for your test definitions using the --file argument and the Tracetest Server endpoint using the --variable argument with TRACETEST_ENDPOINT.

Your Tracetest Endpoint should be reachable by Testkube in your cluster. Use your Tracetest service's CLUSTER-IP:PORT, for example: 10.96.93.106:11633.

kubectl testkube create test --file ./test.yaml --type "tracetest/test" --name tracetest-test --variable TRACETEST_ENDPOINT=http://CLUSTER-IP:PORT
Expected output:
Test created testkube / tracetest-test ๐Ÿฅ‡

Running Tracetest Tests in Testkubeโ€‹

To execute the test, run the following command:

kubectl testkube run test --watch tracetest-test

Alternatively, you can also run the test from the Testkube Dashboard.

Getting Test Resultsโ€‹

If the test passes, the Testkube CLI will look like this:

Expected output:
Type:              tracetest/test
Name: tracetest-test
Execution ID: 6418873d9922b3e1003dd5b8
Execution name: tracetest-test-4
Execution number: 4
Status: running
Start time: 2023-03-20 16:18:05.60245717 +0000 UTC
End time: 0001-01-01 00:00:00 +0000 UTC
Duration:

Variables: 1
- TRACETEST_ENDPOINT = http://10.96.93.106:11633


Getting logs from test job 6418873d9922b3e1003dd5b8
Execution completed
๐Ÿ”ฌ Executing in directory :
$ tracetest test run --server-url http://10.96.93.106:11633 --definition /tmp/test-content1901459587 --wait-for-result --output pretty
โœ” Pokeshop - List (http://10.96.93.106:11633/test/RUkKQ_aVR/run/3/test)
โœ” Database queries less than 500 ms

โœ… Execution succeeded
Execution completed โœ” Pokeshop - List (http://10.96.93.106:11633/test/RUkKQ_aVR/run/3/test)
โœ” Database queries less than 500 ms

Alternatively, if it fails:

Expected output:
Type:              tracetest/test
Name: tracetest-test
Execution ID: 641885f39922b3e1003dd5b6
Execution name: tracetest-test-3
Execution number: 3
Status: running
Start time: 2023-03-20 16:12:35.268197087 +0000 UTC
End time: 0001-01-01 00:00:00 +0000 UTC
Duration:

Variables: 1
- TRACETEST_ENDPOINT = http://10.96.93.106:11633

Getting logs from test job 641885f39922b3e1003dd5b6
Execution completed
๐Ÿ”ฌ Executing in directory :
$ tracetest test run --server-url http://10.96.93.106:11633 --definition /tmp/test-content737616681 --wait-for-result --output pretty
โœ˜ Pokeshop - List (http://10.96.93.106:11633/test/RUkKQ_aVR/run/2/test)
โœ˜ Database queries less than 500 ms
โœ˜ #2b213392d0e3ff21
โœ˜ attr:tracetest.span.duration < 500ms (502ms) (http://10.96.93.106:11633/test/RUkKQ_aVR/run/2/test?selectedAssertion=0&selectedSpan=2b213392d0e3ff21)
โœ” #7e6657f6a43fceeb
โœ” attr:tracetest.span.duration < 500ms (72ms)
โœ” #6ee2fb69690eed47
โœ” attr:tracetest.span.duration < 500ms (13ms)
โœ˜ #a82c304a3558763b
โœ˜ attr:tracetest.span.duration < 500ms (679ms) (http://10.96.93.106:11633/test/RUkKQ_aVR/run/2/test?selectedAssertion=0&selectedSpan=a82c304a3558763b)
โœ” #6ae21f2251101fd6
โœ” attr:tracetest.span.duration < 500ms (393ms)
โœ” #2a9b9422af8ba1a8
โœ” attr:tracetest.span.duration < 500ms (61ms)
โœ” #010a8a0d53687276
โœ” attr:tracetest.span.duration < 500ms (36ms)
โœ˜ #895d66286b6325ae
โœ˜ attr:tracetest.span.duration < 500ms (686ms) (http://10.96.93.106:11633/test/RUkKQ_aVR/run/2/test?selectedAssertion=0&selectedSpan=895d66286b6325ae)

Referencesโ€‹