Use Tusk Drift’s API tests in your CI/CD pipeline by running your test suite against commits in your pull requests (PRs). Our Cloud offering provides storage of these tests alongside an additional layer of intelligence on deviations detected.
Key features:
- Automatic recording of traces based on live traffic in your environment of choice
- Securely store and maintain these traces as API test suites
- Analyze deviations (classification of intended vs. unintended deviations), determine root cause of deviations against your code changes, and suggest fixes
Getting Started
1
Verify Tusk Drift config
Ensure you have set up the essential Tusk Drift config and verified that recording and replaying traces work locally for your service.
2
Run `tusk init-cloud` in CLI
Run
tusk init-cloud and follow the setup wizard. It will guide you to:- Authorize the Tusk app for your code hosting service
- Register your service for Tusk Drift Cloud
- Obtain an API key to use Tusk Drift in CI/CD pipelines
3
Upgrade organization plan
To get Tusk’s AI-powered deviation analysis and suggested fixes, upgrade your account to the Business, Enterprise, or Tusk Drift plan. See plan details.
Configuration
.tusk/config.yaml:
service.id: Automatically created once you complete thetusk init-cloudsetup wizard.tusk_api.url: Required for exporting traces and test results to Tusk.recording.sampling_rate: The fraction of live requests to record (a value between 0 and 1). Higher values improve fidelity but adds more overhead on your service. We recommend setting a value between 0.01 - 0.1.recording.export_spans: Whether to export recorded traffic to Tusk. For deployed services, set this totrue. If set tofalse, it will export traces to your machine’s filesystem.recording.enable_env_var_recording: Whether to record and replay environment variables. We recommend setting this totruefor accurate replay behavior if your service’s logic depends on environment variables.
TUSK_API_KEY) in your machine. You may also wish to add this as a GitHub secret so that GitHub Actions workflows can access it securely (see below for an example).
Running Tusk Drift in Your CI/CD Pipeline
- GitHub Actions
Here’s an example of GitHub Actions workflow. Adapt accordingly for your service.
tusk run crash-course:
-c: Load tests from Tusk Drift Cloud-p: Print mode (non-interactive)--ci: Create a Tusk Drift run and upload results to Tusk Drift Cloud
tusk run --help.
Deviation Analysis
When replayed against past recordings, your code change could yield intended deviations (this is good since existing behavior is modified as expected) or unintended deviations (unexpected regressions or bugs). A Tusk Drift run in a CI/CD environment (if the--ci flag is present) exports test results and commit information to Tusk. For each test with a deviation, Tusk correlates the deviation with code changes and performs an analysis, classifying whether it is likely intended/unintended.
If it is unintended, Tusk will provide a root cause analysis and suggest fixes. A PR/MR with unintended deviations will have a “Failed” status and may be blocked from merging.



FAQs
How much of a performance impact will Tusk have on my service?
How much of a performance impact will Tusk have on my service?
Expect a 1-2% throughput overhead. Transforms result in a 1.0% increase in tail latency when a small number of transforms are registered; its impact scales linearly with the number of transforms registered. For more details, see our performance benchmarks.If
TUSK_DRIFT_MODE is set to DISABLED or left unset, there is zero performance impact.How do you handle duplicate requests or ensure a diverse test suite?
How do you handle duplicate requests or ensure a diverse test suite?
Tusk intelligently selects up to 10 unique requests for each endpoint, prioritizing the most diverse ones to ensure comprehensive test coverage. A maximum of 200 unique endpoints are stored for your test suite.
Merging a PR caused some tests to be deleted. What can I do next?
Merging a PR caused some tests to be deleted. What can I do next?
Depending on your traffic volume, you may need to wait for Tusk to replenish tests for these APIs. You also may wish to manually make requests to your service to trigger recordings.