Route | Description |
---|---|
GET /test-cases/:testCaseId/scripts | Get list of scripts |
GET /scripts/:id | Get script details |
POST /scripts/:id/run | Run script to validate |
POST /test-cases/:testCaseId/scripts | Create script |
HEAD /script/:id | Check if script exists |
PUT /scripts/:id | Update script |
DELETE /scripts/:id | Delete script |
POST /scripts/:id/copy | Copy script |
GET /scripts/:id/data-stores | Get list of data stores |
GET /data-stores/:id | Get data store details |
GET /data-stores/:id/download | Download data store |
GET /data-stores/:id/thumbnail | Get thumbnail image for data store |
GET /data-stores/:id/rows/:index | Get row at a given index within a CSV |
GET /data-stores/:id/rows/iterators/:iterator | Get next N rows for the iterator of a CSV |
POST /scripts/:script/data-stores/contents | Upload data store contents |
POST /scripts/:script/data-stores | Upload data store via multi-part form upload |
HEAD /data-stores/:id | Check if data store exists |
PUT /data-stores/:id/contents | Update data store contents |
PUT /data-stores/:id | Update data store name |
DELETE /data-stores/:id | Delete data store |
Overview
A scenario is the set of steps that define a use case we want to execute at scale. We provide various ways of definings a scenario. In the end no matter what method you use, a script is generated behind the scenes. Testable’s infrastructure knows how to execute scripts at scale under a configuration you define.
In order to create a configuration you need the script ID.
This page contains all routes related to scripts. Remember that you can also create a script with a recording.
Get list of scripts
Retrieve a list of all scripts within a given test case.
GET /test-cases/:testCaseId/scripts
Request Parameters
down
: Whether to include the script contents and data stores. Defaults to false.up
: Whether or not to include the parent, the test case details. Defaults to false.
Sample Response
[
{
"id":308,
"createdAt":"2016-03-13T20:56:46.614Z",
"updatedAt":"2016-03-13T21:20:03.651Z",
"name":"Script",
"length":140,
"hasInit":false,
"hasTeardown":false,
"scriptType":"Code"
}
]
Get script details
Retrieve details about a specific script.
GET /scripts/:id
Request Parameters
down
: Whether to include the script contents and data stores. Defaults to true.up
: Whether or not to include the parent, the test case or execution details. Defaults to true.
Sample Response
{
"id":308,
"createdAt":"2016-03-13T20:56:46.614Z",
"updatedAt":"2016-03-13T21:20:03.651Z",
"name":"Script",
"length":140,
"hasInit":false,
"main":"\nvar dt = dataTable.open('symbols.csv');\ndt.next(function(row) {\n http.get('http://sample.testable.io/stocks/' + row.data['Symbols']);\n});\n",
"hasTeardown":false,
"scriptType":"Code",
"dataStores":[
{
"id":3,
"createdAt":"2016-03-13T21:00:37.712Z",
"updatedAt":"2016-03-13T21:00:37.712Z",
"name":"symbols.csv",
"type":"text/csv",
"charset":"UTF-8",
"size":2020,
"numRows":500,
"url":"https://dev.testable.io:8000/api/data-stores/3/download",
"thumbnailUrl":"https://dev.testable.io:8000/api/data-stores/3/thumbnail",
"deleteUrl":"https://dev.testable.io:8000/api/data-stores/3",
"deleteType":"DELETE",
"headers":"Symbols"
}
]
}
Run script to validate
Run the script for 1 iteration on 1 concurrent client on a Testable agent and return all results and logging.
POST /scripts/:id/run
Request Parameters
region
: The region id where run the script. UseGET /regions
to find the list of regions and their respective ids. Defaults to the ID of the AWS N. Virginia region. Both public and private regions are eligible for selection here.
Request Body
Optional set of script parameters. Only necessary if the script requires parameters.
{
"Threads": "100"
}
Sample Response
{
"success":true,
"startedAt":"2016-03-13T22:19:20.180Z",
"finishedAt":"2016-03-13T22:19:21.079Z",
"results":[
{
"connectionId":"7460b831-199b-4bc4-af67-68df34c66f2d",
"threadId":"35294392-2ac7-4cb6-a275-a08587df464c",
"resource":"GET http://sample.testable.io/stocks/MMM",
"timestamp":1457907561027,
"firstReport":true,
"metrics":[
{
"name":"httpMethod",
"metricType":"Histogram",
"metricKey":"GET",
"metricValue":1
},
{
"name":"dnsLookupMs",
"metricType":"Timing",
"metricValue":6,
"metricUnits":"ms"
},
{
"name":"dataPacketsSent",
"metricType":"Counter",
"metricValue":1,
"metricUnits":"packets"
},
{
"name":"connectionOpenMs",
"metricType":"Timing",
"metricValue":8,
"metricUnits":"ms"
},
{
"name":"dataPacketsReceived",
"metricType":"Counter",
"metricValue":2,
"metricUnits":"packets"
},
{
"name":"firstReceivedMs",
"metricType":"Timing",
"metricValue":10,
"metricUnits":"ms"
},
{
"name":"httpResponseCode",
"metricType":"Histogram",
"metricKey":"200",
"metricValue":1
},
{
"name":"success",
"metricType":"Counter",
"metricValue":1,
"metricUnits":"requests"
},
{
"name":"connectionCloseMs",
"metricType":"Timing",
"metricValue":16,
"metricUnits":"ms"
},
{
"name":"bytesSent",
"metricType":"Counter",
"metricValue":73,
"metricUnits":"bytes"
},
{
"name":"bytesReceived",
"metricType":"Counter",
"metricValue":99,
"metricUnits":"bytes"
},
{
"name":"bandwidth",
"metricType":"Counter",
"metricValue":172,
"metricUnits":"bytes"
}
]
}
],
"logs":[
{
"level":"Info",
"message":"[aws-us-east-1] Symbol: MMM",
"timestamp":1457907561026
}
]
}
Create script
Creates a new script.
POST /test-cases/:testCaseId/scripts
To create a scenario we recommend using the [Simple API][(/api/simple.html)].
Check if script exists
HEAD /scripts/:id
Response
HTTP Status: 200 OK or 404 NOT FOUND
Update script
To update a scenario we recommend using the Simple API.
Delete script
DELETE /scripts/:id
Response
The deleted script
{
"id":309,
"createdAt":"2016-03-13T23:32:23.235Z",
"updatedAt":"2016-03-13T23:34:31.912Z",
"name":"New Name",
"length":0,
"hasInit":false,
"main":"",
"hasTeardown":false,
"scriptType":"Code",
"testCase":{
"id":208,
"createdAt":"2016-03-13T08:59:37.248Z",
"updatedAt":"2016-03-13T08:59:37.248Z",
"name":"JMeter",
"active":true
}
}
Copy script
Creates a copy of the scenario.
POST /scripts/:id/copy
Parameters
name
: Required. The name of the new scenariotargetTestCase
: The ID of the test case to copy the scenario to. Defaults to the test case of the source scenario.copyConfs
: Whether or not to copy all test configurations that run this scenario. Defaults to false.
Get list of data stores
Retrieve a list of all data stores within a given script.
GET /scripts/:id/data-stores
Request Parameters
down
: Whether to include the CSV headers in the response. Defaults to true.up
: Whether or not to include the script parent. Defaults to false.includeRows
: Whether or not to include all rows of the CSV in the response (structured as JSON). Defaults to false.
Sample Response
{
"files":[
{
"id":3,
"createdAt":"2016-03-13T21:00:37.712Z",
"updatedAt":"2016-03-13T21:00:37.712Z",
"name":"symbols.csv",
"type":"text/csv",
"charset":"UTF-8",
"size":2020,
"numRows":500,
"url":"https://dev.testable.io:8000/api/data-stores/3/download?sid=4dfe7d695804158f84df5ce1f40cc1c43e3608ff3275bdb3b6a6e40ac089ceee",
"thumbnailUrl":"https://dev.testable.io:8000/api/data-stores/3/thumbnail?sid=4dfe7d695804158f84df5ce1f40cc1c43e3608ff3275bdb3b6a6e40ac089ceee",
"deleteUrl":"https://dev.testable.io:8000/api/data-stores/3?sid=4dfe7d695804158f84df5ce1f40cc1c43e3608ff3275bdb3b6a6e40ac089ceee",
"deleteType":"DELETE",
"headers":"Symbols"
}
]
}
Get data store details
Retrieve details about a specific data store.
GET /data-stores/:id
Request Parameters
down
: Whether to include the CSV headers in the response. Defaults to true.up
: Whether or not to include the script parent. Defaults to true.includeRows
: Whether or not to include all rows of the CSV in the response (structured as JSON). Defaults to false.
Sample Response
{
"id":3,
"createdAt":"2016-03-13T21:00:37.712Z",
"updatedAt":"2016-03-13T21:00:37.712Z",
"name":"symbols.csv",
"type":"text/csv",
"charset":"UTF-8",
"size":2020,
"numRows":500,
"url":"https://dev.testable.io:8000/api/data-stores/3/download",
"thumbnailUrl":"https://dev.testable.io:8000/api/data-stores/3/thumbnail",
"deleteUrl":"https://dev.testable.io:8000/api/data-stores/3",
"deleteType":"DELETE",
"headers":"Symbols"
}
Download data store
Download the contents of the data store as a file.
GET /data-stores/:id/download
Request Parameters
None
Get thumbnail image for data store
Get the thumbnail image for this data store as an image file.
GET /data-stores/:id/thumbnail
Request Parameters
None
Get row at a given index within a CSV
Retrieves the row at a particular index within a CSV. Indices start at 1.
GET /data-stores/:id/rows/:index
Request Parameters
up
: Whether or not to include the data store parent. Defaults to true.
Response
{
"id":1,
"createdAt":"2016-03-13T21:00:37.713Z",
"updatedAt":"2016-03-13T21:00:37.713Z",
"rowIndex":1,
"rowData":"MMM,Some symbol"
}
Get next N rows for the iterator of a CSV
Useful if you want to iterate the CSV across a distributed set of processes like during a load test execution. Choose a unique name for your iterator and each call is guaranteed to return the next N (where N defaults to 1) rows. Iterators are removed after an hour without usage.
GET /data-stores/:id/rows/iterators/:iterator
Request Parameters
up
: Whether or not to include the data store parent. Defaults to true.wrap
: Whether or not to wrap around to the start of the CSV when the end is reached. Defaults to true. If set to false and the end is reached, an error will be returned on all future calls using this iterator.rows
: Number of rows to return. Defaults to 1.
Response
[
{
"id":4,
"createdAt":"2016-03-13T21:00:37.716Z",
"updatedAt":"2016-03-13T21:00:37.716Z",
"rowIndex":4,
"rowData":"ANF,Company name 1"
},
{
"id":5,
"createdAt":"2016-03-13T21:00:37.716Z",
"updatedAt":"2016-03-13T21:00:37.716Z",
"rowIndex":5,
"rowData":"ADBE,Company name 2"
},
{
"id":6,
"createdAt":"2016-03-13T21:00:37.717Z",
"updatedAt":"2016-03-13T21:00:37.717Z",
"rowIndex":6,
"rowData":"AMD,Company name 3"
}
]
Upload data store contents
Upload a data store file by providing a JSON that includes the file name and the base64 encoded contents. The file type will be inferred based on the extension of the file name following standard mime type mappings.
POST /scripts/:id/data-stores/contents
Request Body
{
"name": "symbols.csv",
"contents": "[base64_encoded_contents]"
}
Response
{
"id":64,
"createdAt":"2016-09-26T14:16:32.178Z",
"updatedAt":"2016-09-26T14:16:32.178Z",
"name":"symbols.csv",
"type":"text/csv",
"charset":"UTF-8",
"size":2007,
"numRows":497,
"url":"/api/data-stores/64/download?sid=abc",
"thumbnailUrl":"/api/data-stores/64/thumbnail?sid=abc",
"deleteUrl":"/api/data-stores/64?sid=abc",
"deleteType":"DELETE",
"headers":"Symbols",
"script":{
"id":240,
"createdAt":"2016-06-27T20:32:31.538Z",
"updatedAt":"2016-06-27T20:34:00.836Z",
"name":"Default Scenario",
"length":389,
"hasInit":false,
"hasTeardown":false,
"scriptType":"Code"
}
}
Upload data store via multi-part form upload
Upload a data store file following a standard HTTP multi part upload format. If a data store already exists for this scenario with the same name it will update it otherwise a new data store will be created.
POST /scripts/:id/data-stores
Response
{
"files":[
{
"id":64,
"createdAt":"2016-09-26T14:16:32.178Z",
"updatedAt":"2016-09-26T14:16:32.178Z",
"name":"symbols.csv",
"type":"text/csv",
"charset":"UTF-8",
"size":2007,
"numRows":497,
"url":"/api/data-stores/64/download?sid=abc",
"thumbnailUrl":"/api/data-stores/64/thumbnail?sid=abc",
"deleteUrl":"/api/data-stores/64?sid=abc",
"deleteType":"DELETE",
"headers":"Symbols",
"script":{
"id":240,
"createdAt":"2016-06-27T20:32:31.538Z",
"updatedAt":"2016-06-27T20:34:00.836Z",
"name":"Default Scenario",
"length":389,
"hasInit":false,
"hasTeardown":false,
"scriptType":"Code"
}
}
]
}
Check if data store exists
HEAD /data-stores/:id
Response
HTTP Status: 200 OK or 404 NOT FOUND
Update data store contents
Update the data store name and contents by providing a JSON that includes the file name and the base64 encoded contents. If either the name or contents are not included, the current value for that field will be maitained. The file type will be inferred based on the extension of the file name following standard mime type mappings.
PUT /data-stores/:id/contents
Request Body
{
"name": "symbols.csv",
"contents": "[base64_encoded_contents]"
}
Response
{
"id":64,
"createdAt":"2016-09-26T14:16:32.178Z",
"updatedAt":"2016-09-26T14:16:32.178Z",
"name":"symbols.csv",
"type":"text/csv",
"charset":"UTF-8",
"size":2007,
"numRows":497,
"url":"/api/data-stores/64/download?sid=abc",
"thumbnailUrl":"/api/data-stores/64/thumbnail?sid=abc",
"deleteUrl":"/api/data-stores/64?sid=abc",
"deleteType":"DELETE",
"headers":"Symbols",
"script":{
"id":240,
"createdAt":"2016-06-27T20:32:31.538Z",
"updatedAt":"2016-06-27T20:34:00.836Z",
"name":"Default Scenario",
"length":389,
"hasInit":false,
"hasTeardown":false,
"scriptType":"Code"
}
}
Update data store name
Update the data store name. To overwrite the data store with a new one, use the upload data stores endpoint.
PUT /data-stores/:id
Request Body
{
"name": "new.csv"
}
Response
{
"id":3,
"createdAt":"2016-03-13T21:00:37.712Z",
"updatedAt":"2016-03-13T21:00:37.712Z",
"name":"new.csv",
"type":"text/csv",
"charset":"UTF-8",
"size":2020,
"numRows":500,
"url":"https://dev.testable.io:8000/api/data-stores/3/download",
"thumbnailUrl":"https://dev.testable.io:8000/api/data-stores/3/thumbnail",
"deleteUrl":"https://dev.testable.io:8000/api/data-stores/3",
"deleteType":"DELETE",
"headers":"Symbols"
}
Delete data store
DELETE /data-stores/:id
Response
The deleted data store
{
"id":3,
"createdAt":"2016-03-13T21:00:37.712Z",
"updatedAt":"2016-03-13T21:00:37.712Z",
"name":"new.csv",
"type":"text/csv",
"charset":"UTF-8",
"size":2020,
"numRows":500,
"url":"https://dev.testable.io:8000/api/data-stores/3/download",
"thumbnailUrl":"https://dev.testable.io:8000/api/data-stores/3/thumbnail",
"deleteUrl":"https://dev.testable.io:8000/api/data-stores/3",
"deleteType":"DELETE",
"headers":"Symbols"
}