TestKube Tracetest Executor is a test executor to run Tracetest tests with TestKube.
Tracetest is a testing tool based on OpenTelemetry that allows you to test your distributed application. It allows you to use your telemetry data generated by the OpenTelemetry tools to check and assert if your application has the desired behavior defined by your test definitions.
-
Trecetest Server: You'll need a running instance of Tracetest which is going to be executing your tests and assertions. To do so you can follow the instructions defined in the Tracetest documentation.
-
OpenTelemetry Instrumented Service: In order to generate traces and spans, the service under test must support the basics for propagation through HTTP requests, and also store traces and spans into a Data Store Backend (Jaeger, Grafana Tempo, OpenSearch, etc) or use the OpenTelemetry Collector.
First you need to register and deploy the Tracetest executor in your cluster using the Testkube CLI:
kubectl testkube create executor --image kubeshop/testkube-executor-tracetest:latest --types "tracetest/test" --name tracetest-executor
Now you need a Tracetest test. Have a look at the Tracetest documentation for details on writing tests. Here is a simple test definition example:
type: Test
spec:
id: R5NITR14g
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:
- selector: span[tracetest.span.type="http"]
assertions:
- attr:http.method = "GET"
- selector: span[tracetest.span.type="database"]
assertions:
- attr:db.name = "pokeshop"
Execute the following command to create the test executor object in Testkube. Do not forget to provide the path to your Tracetest definition file using the --file
argument, and also the Tracetest Server endpoint using the TRACETEST_ENDPOINT
--variable
:
kubectl testkube create test --file my/file/location.yaml --type "tracetest/test" --name pokeshop-tracetest-test --variable TRACETEST_ENDPOINT=http://tracetest
Finally you can run the test:
kubectl testkube run test --watch pokeshop-tracetest-test
sequenceDiagram
testkube client->>+testkube: Trigger Testkube test run
testkube->>+executor CRDs: Get executor details
executor CRDs-->>-testkube: Send details
testkube->>+tracetest executor job: Schedules execution
tracetest executor job->>+tracetest executor job: Configure Tracetest CLI
tracetest executor job->>+tracetest server: Executes the Tracetest test run
tracetest server->>+instrumented service: Trigger request
instrumented service-->>-tracetest server: Get response
instrumented service->>+data store: Send telemetry data
tracetest server->>+data store: Fetch trace
data store-->>-tracetest server: Get trace
tracetest server->>+tracetest server: Run assertions
tracetest server-->>-tracetest executor job: Return test run results
tracetest executor job-->>-testkube: Return test run results
testkube-->>-testkube client: Send details
Please follow the main TestKube repository for reporting any issues or discussions
For more info go to main testkube repo
For more info go to main tracetest repo