Tracetest
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.
- 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.
- 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:
- Testkube
- Tracetest
- 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
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:
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:
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)