CI Lifecycle Using Our API

In this example we start a test execution, wait for it to finish, and then save all results in CSV format.

Trigger an existing test configuration

It assumes you have already created a test configuration and scenario via the API or website first and have the trigger URL for the configuration available.

See the concepts, new configuration guide, new scenario guide, configuration API, and scenario API for more details.


curl -X POST --silent$TESTABLE_TRIGGER | jq -r ".id"

Use Simple API to define all test parameters

Use the simple API to start a test passing all parameters. For example to run a Node.js script, test.js, in AWS N. Virginia on our shared grid use the following:

curl \
  -F "code=@/local/path/to/my/test.js" \
  -F "concurrent_users_per_region=5" \
  -F "duration_mins=2" \
  -F "rampup_mins=1" \
  -F "conf_testrunners[0].regions=aws-us-east-1" \$TESTABLE_KEY

Monitor a running test and save results to CSV

The following script takes a test execution ID, waits for it to complete, prints out the success/failure status, and saves all results to a local CSV file.


echo "[$(date)] Waiting for execution to complete (view online at$execution_id)"
while [ $(curl -H "X-Testable-Key:$TESTABLE_KEY" --silent$execution_id | jq -r ".completed") = "false" ]; do
  echo -n "."
  sleep 5

if [ $(curl -H "X-Testable-Key:$TESTABLE_KEY" --silent$execution_id | jq -r ".success") = "false" ]; then
  echo -e "\n[$(date)] Test FAILED"
  echo -e "\n[$(date)] Test SUCCESS"

epoch=$(date +"%s")
echo "[$(date)] Storing CSV results at results-$epoch.csv"
curl -H "X-Testable-Key:$TESTABLE_KEY" --silent$execution_id/results.csv > results-$epoch.csv

Example usage with a trigger:

export TESTABLE_KEY=xxx
./ $(curl -X POST --silent$TESTABLE_TRIGGER | jq -r ".id")

Example usage with the Simple API:

export TESTABLE_KEY=xxx
./ $(curl \
  -F "code=@/local/path/to/my/test.js" \
  -F "concurrent_users_per_region=5" \
  -F "duration_mins=2" \
  -F "rampup_mins=1" \
  -F "conf_testrunners[0].regions=aws-us-east-1" \$TESTABLE_KEY)