Run Profiling and Tests¶
Trigger a profiling or test run through the API and retrieve its results from CI/CD pipelines, orchestration tools, or any system that needs to drive TestGen in response to upstream events.
The pattern is the same for every job type: submit, then poll for completion. Profiling and test runs also have a result summary to fetch. Job submissions return immediately and do not wait for the job to finish.
Job lifecycle¶
A job's status is one of the following. A successful run moves from pending to claimed, running, and completed. The other statuses apply only when a run waits its turn, fails, is canceled, or stops partway.
| Status | Meaning |
|---|---|
pending |
Submitted, waiting to be picked up |
queued |
Waiting for another run to finish (DuckDB or file data sources only) |
claimed |
Picked up by the system, about to start |
running |
Currently executing |
completed |
Finished successfully |
error |
Failed. See error_message in the job response. |
cancel_requested |
Cancellation requested but not yet processed |
canceled |
Cancellation completed |
interrupt_requested |
Stop requested by a TestGen shutdown but not yet processed |
interrupted |
Stopped partway, keeping its progress; continues on the next scheduler start (profiling runs only) |
pause_requested |
Pause requested but not yet processed (profiling runs only) |
paused |
Stopped partway; continues when resumed (profiling runs only) |
resume_requested |
Set to continue, waiting to be picked up (profiling runs only) |
completed, error, and canceled are terminal: once a job reaches one of these, its status does not change. Every other status means the job is still in progress.
A profiling run can stop partway through and keep its progress, then continue from where it stopped. TestGen shutting down mid-run leaves it interrupted, and the next start picks it up on its own; a pause leaves it paused, which continues only when a resume is requested. A test run does not pause.
A run that is in progress when TestGen stops or restarts, and that cannot continue, ends as error. Submit it again.
A job on a DuckDB connection or file data source is queued while it waits for other such jobs to finish, and queued jobs start in the order they were submitted. To change how many of these jobs run at once, see Size TestGen for DuckDB and File Data Sources.
Submit a job¶
Each job type has its own submission endpoint. Each returns 202 Accepted with the job ID.
| Job | Endpoint |
|---|---|
| Profile a table group | POST /api/v1/table-groups/{table_group_id}/profiling-runs |
| Generate tests for a test suite | POST /api/v1/test-suites/{test_suite_id}/test-generation |
| Run a test suite | POST /api/v1/test-suites/{test_suite_id}/test-runs |
To find a table_group_id, list a project's table groups with GET /api/v1/projects/{project_code}/table-groups, filtering by schema or name to pinpoint the one you want. If the dataset is not set up yet, see Onboard a Dataset.
The response contains the job ID.
Save the id. You use it for polling and for retrieving the result.
A test run also accepts optional settings in the request body. See Test run options.
Poll for completion¶
Poll until status is one of the three terminal values: completed, error, or canceled. Treat any other status, including interrupted and paused, as still in progress rather than a stopping point, and do not treat an unrecognized status as terminal. Give the poll a timeout: a paused run stays in progress until somebody resumes it from the TestGen UI, which the API does not expose, so it can remain there indefinitely. The response includes the lifecycle timestamps so you can track the job's progress.
{
"id": "8a4f1c7e-2b39-4e2e-a8c3-1d5e9f2a7b4c",
"job_key": "run-tests",
"status": "running",
"source": "api",
"created_at": "2026-05-04T14:22:18Z",
"claimed_at": "2026-05-04T14:22:25Z",
"started_at": "2026-05-04T14:22:26Z",
"completed_at": null,
"error_message": null
}
If the job ends in error, error_message describes what went wrong.
started_at is when the run began and does not move again. claimed_at is when the run was most recently picked up, so a profiling run that stopped partway and continued reports the claim that continued it. That is later than started_at, and tells you how long the current stretch has been going. Measure the whole run from started_at, not from claimed_at.
Fetch the result summary¶
Once the job status is completed, retrieve the run summary using the job ID.
| Job | Endpoint |
|---|---|
| Profile a table group | GET /api/v1/profiling-runs/{job_id} |
| Run a test suite | GET /api/v1/test-runs/{job_id} |
A test run summary includes the result counts by status and the run's Testing Score.
{
"id": "8a4f1c7e-2b39-4e2e-a8c3-1d5e9f2a7b4c",
"status": "completed",
"test_suite_id": "...",
"table_group_id": "...",
"started_at": "2026-05-04T14:22:26Z",
"completed_at": "2026-05-04T14:23:41Z",
"result": {
"score": 97.4,
"result_counts": {
"passed": 412, "failed": 8, "warning": 3,
"error": 0, "log": 0, "dismissed": 1
}
}
}
A run of a contract also carries a version block that names the version the run checked. Its counts_as_status is true only for a run of the version that was active when the run started.
A profiling run summary includes the asset counts, the breakdown of hygiene issues and potential PII findings, and the run's Profiling Score. The hygiene_issues and potential_pii counts cover active findings only; dismissed and muted findings are totaled separately under dismissed.
{
"id": "...",
"status": "completed",
"table_group_id": "...",
"started_at": "...",
"completed_at": "...",
"result": {
"score": 96.2,
"table_ct": 24,
"column_ct": 318,
"record_ct": 1842091,
"issue_counts": {
"hygiene_issues": { "definite": 4, "likely": 11, "possible": 27 },
"potential_pii": { "high": 2, "moderate": 5 },
"dismissed": 0
}
}
}
A completed profiling run means profiling itself finished. When the table group is configured to auto-generate tests or monitors, that generation runs as its own follow-up job after profiling, so a completed profiling run does not mean the generated tests are ready yet.
Cancel a job¶
Cancellation is asynchronous. The job status moves to cancel_requested first, then to canceled once the system processes the request.
Test run options¶
A test run submission takes an optional JSON body. Omit it to run the suite as configured.
| Field | Purpose |
|---|---|
schema_name |
Schema to read the tests' tables from |
table_names |
Tables to read in place of the tests' tables |
match_schema_name |
Schema to read the referential tests' second tables from |
match_table_names |
Tables to read in place of the referential tests' second tables |
variables |
Values for the variables that custom queries declare |
external_url |
Link back to the system that started the run |
metadata |
JSON object with any other details about the run |
version |
Contract version number to run. Omitted: the active version, else the draft. |
For example, the following request runs the tests against the build_ tables in a staging schema before you promote them.
{
"schema_name": "staging",
"table_names": {"*": "build_*"},
"variables": {"END_DATE": "2026-10-17"},
"external_url": "https://automation.example.com/runs/8891",
"metadata": {
"system": "DataOps Automation",
"run_id": "8891"
}
}
The schema, table, and variable fields apply to this run only. The test definitions keep their own schema and tables. A test whose table the run cannot read reports an error and stays active. To read a different schema on every run, change the table group's schema instead.
- Schemas:
schema_nameandmatch_schema_nameapply to database connections other than Salesforce Data 360. In a custom SQL test,{DATA_SCHEMA}is replaced with the schema inschema_name. - Tables:
table_namesandmatch_table_namesmap a table name to the table to read. A key is an exact name or a pattern with one*, and a*in the value is replaced by what the key's*matched, so{"*": "build_*"}readsbuild_ordersfor the tests onorders. An exact name takes precedence over a pattern, and when two patterns match, the one that matches more of the name outside its*applies. A table that no key matches keeps its name. Names match exactly, including case. A custom query reads the tables it names, andtable_namesdoes not change them. - Variables: A custom query declares a variable as
{NAME:default}. The run uses the value invariables, or the default whenvariablesdoes not name it. A name that no custom query in the run declares is ignored. The value is inserted into the query as SQL text, so a string value needs its quotes in the query, as in'{END_DATE:2026-10-10}'.
The Test Results page shows external_url under Link, and the schema, table, and variable values sent with the run, along with metadata, under Run details. GET /api/v1/test-runs/{job_id} returns them as well.
Next steps¶
- Investigate Profiling Results to review column statistics and hygiene issues
- Investigate Test Results to review failures and take action on findings