Test Sessions API (a.k.a TIA API)
You can integrate any Testing framework with Sealights to capture Tests Events like Start and End of Test Stage, Tests results, etc using the API described on this page.
This API includes getting the list of tests recommended to be skipped by Sealights for Test Optimization (TIA) and forcing a Full-Run on the next execution of a Test Stage.
For your reference, you’ll find a few sample integrations with various Testing frameworks listed on our dedicated documentation page.
This API requires an Agent Token.
Creating Test Session
Create a test session with a specific Labid and test stage, if there is no labId - use BSId instead
Calling this request to create a new test session for the current run
POST /sl-api/v1/test-sessionsRequest details
Request body
Parameter | Description | Default value | Is mandatory? |
|---|---|---|---|
| Lab Id |
|
|
| Test Stage |
|
|
| Build Session Id |
|
|
| Session Timeout (seconds), max timeout 86400 (24 hours) | 14,400 (4 hours) |
|
| Test group id |
|
|
Request Samples
POST /sl-api/v1/test-sessions HTTP/1.1
Authorization: Bearer {sealights-agent-token}
Content-Type: application/json
{
"labId": "LabId",
"testStage": "Unit Tests",
"bsid": "bsId",
"sessionTimeout": 10000,
"testGroupId": "job name"
}
HTTP/1.1 200 OK
HTTP/1.1 404 NOT_FOUND
HTTP/1.1 500 BAD_REQUESTResponse Sample
{
"data": {
"testSessionId": "341dc795-71a8-4253-b686-27ff09f04468"
}
}Sample Shell command and response:
Linux | curl -X POST "https://$DOMAIN/sl-api/v1/test-sessions"
-H "Authorization: Bearer $SEALIGHTS_AGENT_TOKEN" \
-H "Content-Type: application/json" \
-d "{\"labId\":\"LabId\",\"testStage\":\"UnitTests\",\"bsid\":\"bsId\",\"sessionTimeout\":10000}"
200 OK
404 NOT_FOUND
500 BAD_REQUEST |
|---|---|
Powershell | Invoke-RestMethod -Uri "https://$SL_DOMAIN/sl-api/v1/test-sessions" -Method 'Post' \
-Headers @{'Authorization'="Bearer $SEALIGHTS_AGENT_TOKEN";'Content-Type'='application/json'}
-Body @{'testStage'='Automation Tests';'bsid'='123'} |
Get Exclude Tests v1 (deprecated)
Getting a list of tests that should be excluded
Test Optimization must be turned on for the Test Stage in order to receive a non-empty response.
Calling this request to get a list of test names that should be excluded in the current run (by default with test names)
GET /sl-api/v1/test-sessions/{testSessionId}/exclude-testsYou can specify to get only the External Tests IDs (instead of Test Names) to be returned in the response
GET /sl-api/v1/test-sessions/{testSessionId}/exclude-tests?type=externalIdRequest details
Request parameters
Parameter | Description | Is mandatory? |
|---|---|---|
| Test Session ID |
|
| enum:
|
|
Request/Response Samples
Sample | Request | Response |
|---|---|---|
Default (using test names) | GET /sl-api/v1/test-sessions/{testSessionId}/exclude-tests
Authorization: Bearer {sealights-agent-token}
Content-Type: application/json
HTTP/1.1 200 OK
HTTP/1.1 404 NOT_FOUND
HTTP/1.1 500 BAD_REQUEST | {
"data":[
"Test1",
"Test2"
]
} |
| GET /sl-api/v1/test-sessions/{testSessionId}/exclude-tests?type=externalId
Authorization: Bearer {sealights-agent-token}
Content-Type: application/json
HTTP/1.1 200 OK
HTTP/1.1 404 NOT_FOUND
HTTP/1.1 500 BAD_REQUEST | {
"data":[
"123-456",
"adg-457"
]
}
|
Sample Shell command and response:
curl -X GET "https://$DOMAIN/sl-api/v1/test-sessions/$TESTSESSIONID/exclude-tests" \
-H "Authorization: Bearer $SEALIGHTS_AGENT_TOKEN" \
-H "Content-Type: application/json"
200 OK
404 NOT_FOUND
500 BAD_REQUESTGet Exclude Tests v2
Getting a list of tests that should be excluded
Test Optimization must be turned on for the Test Stage in order to receive a non-empty response.
Calling this request to get a list of test names that should be excluded in the current run (by default with test names)
GET /sl-api/v2/test-sessions/{testSessionId}/exclude-testsRequest details
Request parameters
Parameter | Description | Is mandatory? |
|---|---|---|
| Test Session ID |
|
Request/Response Samples
Sample | Request | Response |
|---|---|---|
Default (using test names) | GET /sl-api/v2/test-sessions/{testSessionId}/exclude-tests
Authorization: Bearer {sealights-agent-token}
Content-Type: application/json
HTTP/1.1 200 OK
HTTP/1.1 404 NOT_FOUND
HTTP/1.1 500 BAD_REQUEST | {
"metadata": { // metadata to help DevOps debug their integration
"appName": "string", // app name requested.
"branchName": "string", // branch name requested.
"buildName": "string", // build name requested.
"testStage": "string", // test stage requested.
"testGroupId": "string", // test group id requested.
"testSelectionEnabled": true, // when true TIA is on the given app/branch/test-stage
"isFullRun": true, // when true it means that on the given app/branch/test-stage for the build
"status": "notReady", // represent recommendations status [notReady, noHistory, ready, error, wontBeReady]
"fullRunReason": "No statistical model available for build" // describe the reason why full run is recommended (Optional, only if isFullRun=true)
},
"excludedTests": [ // an array of objects representing the execluded tests.
{
"testName": "string"
}
]
} |
Sample Shell command and response:
curl -X GET "https://$DOMAIN/sl-api/v2/test-sessions/$TESTSESSIONID/exclude-tests" \
-H "Authorization: Bearer $SEALIGHTS_AGENT_TOKEN" \
-H "Content-Type: application/json"
200 OK
404 NOT_FOUND
500 BAD_REQUESTSending Test Events
Sending test events with status
Calling this request for reporting SeaLights test event result.
POST /sl-api/v2/test-sessions/{testSessionId}This API must be called before closing/deleting the session.
Please notice this specific endpoint uses a
v2URL
This API can be called several times during a session to report tests in bulk.
Request details
Request parameters
Parameter | Description | Is mandatory? |
|---|---|---|
| Test Session ID |
|
Request Body
The tests skipped per the recommendation (GetExcluded Tests API above) must be explicitly included in the results of the test sent to Sealights (with the status
skipped)Skipped tests must be provided with start and end parameters, as well. We recommend providing them with
start = end = now()value.
Parameter | Description | Is mandatory? |
|---|---|---|
| Array of Test run events (even for a single test) |
|
Test run event |
|
|
| Test Name |
|
| (Optional) Test ID from the Test Management platform/framework . |
|
| Starting time of the test (milliseconds since epoch) |
|
| Ending time of the test (milliseconds since epoch) |
|
| Test status: |
|
In case of Invalid parameters, API will return an Error code 400 INVALID. For example, if the timestamps are not sent in milliseconds format, API will return with code 400 and a message Invalid timestamp
Request Samples
POST /sl-api/v2/test-sessions/{testSessionId}
Authorization: Bearer {sealights-agent-token}
Content-Type: application/json
[
{
"name": "TestToRun1",
"start": 1619341754996,
"end": 1619341754998,
"status": "passed"
}
]
HTTP/1.1 200 OK
HTTP/1.1 400 INVALID
HTTP/1.1 404 NOT_FOUND
HTTP/1.1 500 BAD_REQUESTSample Shell command and response:
curl -X POST "https://$DOMAIN/sl-api/v2/test-sessions/$TESTSESSIONID" \
-H "Authorization: Bearer $SEALIGHTS_AGENT_TOKEN" \
-H "Content-Type: application/json" \
-d "[{\"name\":\"TestToRun1\",\"start\":1619341754996,\"end\":1619341754998,\"status\":\"passed\"}]"
200 OK
400 INVALID
404 NOT_FOUND
500 BAD_REQUEST
Delete Test Session
Delete test session when sending of test events has been done.
Calling this request will close the test session and update the coverage.
DELETE /sl-api/v1/test-sessions/{testSessionId}Request details
Request parameters
Parameter | Description | Is mandatory? |
|---|---|---|
| Test Session ID |
|
Request Samples
DELETE /sl-api/v1/test-sessions/{testSessionId}
Authorization: Bearer {sealights-agent-token}
Content-Type: application/json
HTTP/1.1 200 OK
HTTP/1.1 404 NOT_FOUND
HTTP/1.1 500 BAD_REQUESTSample Shell command and response:
curl -X DELETE "https://$DOMAIN/sl-api/v1/test-sessions/$TESTSESSIONID" \
-H "Authorization: Bearer $SEALIGHTS_AGENT_TOKEN" \
-H "Content-Type: application/json"
200 OK
404 NOT_FOUND
500 BAD_REQUESTForce “Full-Run” on a Test Stage
This request will schedule a “full run” for the subsequent execution of a specified Test Stage.
PUT /sl-api/v1/tia/apps/{appName}/branches/{branchName}/testStages/{testStage}/full-runThis API call should be executed BEFORE creating the test session.
Request details
Request parameters
Parameter | Description | Is mandatory? |
|---|---|---|
| App to schedule full run for |
|
| Branch to schedule full run for |
|
| Test Stage to schedule full run for |
|
Request Body
Parameter | Description | Is mandatory? |
|---|---|---|
| Boolean indicator, indicates if next run will be full run or not |
|
Request Samples
PUT /sl-api/v1/tia/apps/{appName}/branches/{branchName}/testStages/{testStage}/full-run
Authorization: Bearer {sealights-agent-token}
Content-Type: application/json
{
"enable": true
}
HTTP/1.1 200 OK
HTTP/1.1 400 NOT_FOUND
HTTP/1.1 500 BAD_REQUESTSample Shell command and response:
curl -X PUT "https://$DOMAIN/sl-api/v1/tia/apps/$APPNAME/branches/$BRANCHNAME/testStages/$TESTSTAGE/full-run" \
-H "Authorization: Bearer $SEALIGHTS_AGENT_TOKEN" \
-H "Content-Type: application/json" \
-d "{\"enable\":true}"
200 OK
404 NOT_FOUND
500 BAD_REQUEST
Get Recommended Tests (White List)
This API call does not require a test session.
Get Recommended Tests for the latest build from a specific app/branch
Get recommendations for the latest build for a specific app/branch: it returns a list of test names recommended to be run.
/sl-api/v1/tia/apps/{appName}/branches/{branchName}/test-stages/{testStage}/recommendationsRequest details
Request parameters
Parameter | Description | Is mandatory? |
|---|---|---|
appName | App name | |
branchName | Branch name | |
testStage | Test Stage name |
Request/Response Samples
Sample | Request | Response |
|---|---|---|
Default | /sl-api/v1/tia/apps/{appName}/branches/{branchName}/test-stages/{testStage}/recommendations
Authorization: Bearer {sealights-agent-token}
Content-Type: application/json
HTTP/1.1 200 OK
HTTP/1.1 404 NOT_FOUND
HTTP/1.1 500 BAD_REQUEST
| {
"data": {
"total": 500,
"next": 50,
"previous": 0,
"list": [
{
"testName": "it should return ok",
"testType": "parameterized",
"numberOfpermutations": 3,
"reasons": [
"impacted"
],
"relativeBuild": {
"bsId": "some-bsid",
"buildName": "build1",
"timestamp": 1651545121
},
"pinnedBy": "user",
"pinnedDate": "12/12/2022",
"pinnedReason": "important test"
}
],
"metadata": {
"appName": "app1",
"branchName": "master",
"buildName": "build1",
"buildSessionId": "bsid1",
"testStage": "Unit Tests"
}
}
}
|
Sample Shell command and response:
curl -X GET "https://$DOMAIN/sl-api/v1/tia/apps/$APP_NAME/branches/$BRANCH_NAME/test-stages/$TEST_STAGE/recommendations" \
-H "Authorization: Bearer $SEALIGHTS_AGENT_TOKEN" \
-H "Content-Type: application/json" \
200 OK
400 Missing parameters
401 Recommendations not found due to errorGet Recommended Tests by BSID and Test-Stage
Get recommendations for a specific build according to buildSessionId: it will return a list of test names that are recommended to be run for the given build.
/sl-api/v1/tia/builds/{bsId}/test-stages/{testStage}/recommendationsRequest details
Request parameters
Parameter | Description | Is mandatory? |
|---|---|---|
bsId | Build session Id | |
testStage | Test Stage name | |
offset | Result offset - used for pagination |
|
limit | Result limit - used for pagination (max limit 100,000 records) |
|
search | Free text to filter the recommednations by |
|
sortBy | Sort recommnedations bym options are:
|
|
sortDirection | Sort recommendations direction, options are:
|
|
facet | Saved filters according to recommendations` types, options are:
|
|
Request Samples
/sl-api/v1/tia/builds/{bsId}/test-stages/{testStage}/recommendations
Authorization: Bearer {sealights-agent-token}
Content-Type: application/json
HTTP/1.1 200 OK
HTTP/1.1 404 NOT_FOUND
HTTP/1.1 500 BAD_REQUESTResponse Sample
{
"data": {
"total": 500,
"next": 50,
"previous": 0,
"list": [
{
"testName": "it should return ok",
"testType": "parameterized",
"numberOfpermutations": 3,
"reasons": [
"impacted"
],
"relativeBuild": {
"bsId": "some-bsid",
"buildName": "build1",
"timestamp": 1651545121
},
"pinnedBy": "user",
"pinnedDate": "12/12/2022",
"pinnedReason": "important test"
}
],
"metadata": {
"appName": "app1",
"branchName": "master",
"buildName": "build1",
"buildSessionId": "bsid1",
"testStage": "Unit Tests"
}
}
}Sample Shell command and response:
curl -X GET "https://$DOMAIN/sl-api/v1/tia/builds/$BSID/test-stages/$TEST_STAGE/recommendations" \
-H "Authorization: Bearer $SEALIGHTS_AGENT_TOKEN" \
-H "Content-Type: application/json" \
200 OK
400 Missing parameters
401 Recommendations not found due to errorGet Recommended Tests by app name, branch name, build name and Test Stage
Get recommendations for a specific build according to app/branch/build-name.
Calling this request for getting a list of test names that are recommended to be run for the given build.
/sl-api/v1/tia/apps/{appName}/branches/{branchName}/builds/{buildName}/test-stages/{testStage}/recommendationsRequest details
Request parameters
Parameter | Description | Is mandatory? |
|---|---|---|
appName | App name | |
branchName | Branch name | |
buildName | Build name | |
testStage | Test Stage name |