Skip to main content

Custom Test

Overview

This guide explains how to run custom tests against Signadot sandboxes. You can run these tests either:

  • Directly in your CI pipeline
  • Using Signadot Jobs for sandbox-aware test execution

Set Up Routing Context

To run tests against sandboxes, you'll need to configure your test client to include the appropriate routing headers. This is required regardless of whether you're running tests in CI or using Signadot Jobs.

For example, if using a custom HTTP client:

def configure_client(routing_key):
headers = {
'baggage': f'sd-routing-key={routing_key}'
}
return headers

def make_request(url, routing_key):
headers = configure_client(routing_key)
response = requests.get(url, headers=headers)
return response
note

The exact header to use depends on your service's instrumentation library. See our header propagation guide for details on supported headers and configuration.

Running Tests in CI

To run tests directly in your CI pipeline:

  1. Create a sandbox for testing
  2. Get the sandbox's routing key
  3. Set up environment and run tests:
    export SIGNADOT_ROUTING_KEY=<your-sandbox-routing-key>
    ./run-tests.sh

Running Tests as Signadot Jobs

For sandbox-aware test execution, you can run tests as Signadot Jobs. This provides additional benefits:

  • Automatic test failure if the sandbox is terminated or fails
  • Built-in artifact collection
  • Integrated test reporting
info

Using custom images can be useful for installing in-house tooling and will run faster than installing these tools at runtime. However, it also has the operational overhead of maintaining the custom image.

Create base image

your_project/.signadot/testing/Dockerfile
# You can even use a lighter image, but make sure you have all deps you need
FROM ubuntu:latest

ENV HOME /root
WORKDIR $HOME

# Install basic tools
RUN apt-get update && \
apt-get install -y git wget && \
apt-get clean autoclean && \
rm -rf /var/lib/{apt,dpkg,cache,log}/

# Do more stuff ....

Create Job Runner Group

To start with Signadot CT, we need to create a Job Runner Group.

your_project/.signadot/testing/my-custom-runner.yaml
name: my-custom-runner
spec:
cluster: "@{cluster}"
labels:
env: "@{env}"
# Depending on your need, it can be a standard image, or a
# custom one you have built to suit your testing needs.
image: <image_registry>/<image_name>:tag
jobTimeout: 30m
scaling:
manual:
desiredPods: 1
podTemplate:
spec:
imagePullSecrets:
- name: your_registry
info

It's expected you to have already set up the registry where you are trying to push/pull the image from. For further reference you can check how to k8s pull image private

Create Job Specification

your_project/.signadot/testing/my-custom-job.yaml
spec:
namePrefix: my-custom-job
runnerGroup: my-custom-runner
script: |
#!/bin/bash
set -e

# Clone the git repo
echo "Cloning repo"
git clone --single-branch -b "@{branch}" \
https://github.com/<org>/<repo>.git

# Run the tests with routing key
cd <repo>
export SIGNADOT_ROUTING_KEY=$SIGNADOT_ROUTING_KEY
./run-tests.sh

routingContext:
sandbox: "@{sandbox}"
uploadArtifact:
- path: your_project/test-results
- path: your_project/test-logs