Synthetic test APIs
Use these APIs to configure Synthetic tests.
- Creating a synthetic test
- Updating/Starting/Stoping a synthetic test
- Getting a synthetic test
- Listing the synthetic tests
- Deleting a synthetic test
Creating a synthetic test
API version 1.0.0
-
API URI components
-
Scheme HTTPS
-
Host IP Synthetic Route Host
-
Port number Synthetic Route Port
-
Path /synthetic/1.0/synthetic_tests
-
Command POST
Command output format application/json
Synthetic APIs support the following test types:
- HTTPAction: Test a Rest API by pinging a URL.
- WebpageAction: Load a web page URL with a real browser.
- WebpageScript: Test a website with a recorded selenium script.
- HTTPScript: Test one or multiple Rest APIs with Node.js based script.
- SOAP: Test Webservice/SOAP with Node.js based script.
To test an HTTP URL, the sample curl command resembles the following code:
curl -X POST -H 'Content-Type: application/json' -H 'Authorization: Bearer $ACCESS_TOKEN' -i 'http://<synthetic_route_address>/synthetic/1.0/synthetic_tests' --data ' {
"label": "TestHTTPRest",
"syntheticType": "HTTPAction",
"active": true,
"description": "this is to a URL with ping",
"configuration": {
"url": "http://www.google.com",
"operation": "GET"
},
"schedInterval": 5,
"playbackMode": "Simultaneous",
"locations": [
{
"_id": "KSN_Location_uipop_three_2ac0-1013"
}
],
"threshold": {
"criticalThreshold": 2,
"warningThreshold": 1
}
]
}
'
The configuration section varies based on the syntheticType
.
-
If the
syntheticType
isWebpageAction
, the configuration section resembles the following code:"configuration" : { "url": "http://www.ibm.com/" }
-
If the
syntheticType
isWebpageScript
, you need to record a selenium script with SeleniumIDE, save it to.side
file, and then encode the content with base64. The configuration section resembles the following code:"configuration" : { "fileName": "seleniumscript.side", "scriptContents": "<input the selenium scrip content (BASE64 encoded) here>" }
-
If the
syntheticType
isHTTPScript
orSOAP
, input thenode.js
script in plain text format in thescript
field."configuration": { "script": "<input Node.js content (PLAIN TEXT) here>" }
-
If multiple variables are defined in WebpageScript, HTTPScript, or SOAP tests, you can specify the variable values per location in the
variables
field of the configuration section. See the following example:"configuration": { "script": "\ndescribe(\"CalculatorSoap - Add\", function () {\n var endpoint = \"http:\/\/www.dneonline.com\/calculator.asmx\";\n var namespace = \"http:\/\/tempuri.org\/\";\n var add1 = $globalContext[\"add1\"];\n var add2 = $globalContext[\"add2\"];\n\n var requestXML = '<soap:Envelope xmlns:soap=\"http:\/\/www.w3.org\/2003\/05\/soap-envelope\" xmlns:tem=\"' + namespace + '\">' +\n '<soap:Header\/>' +\n '<soap:Body>' +\n \/\/Customized soap request start\n '<tem:Add>' +\n \/**\n * Add your inputs\n * Example:\n * '<tem:intA>6<\/tem:intA>' +\n * '<tem:intB>3<\/tem:intB>' +\n *\/\n '<tem:intA>' + add1 + '<\/tem:intA>' +\n '<tem:intB>' + add2 + '<\/tem:intB>' +\n '<\/tem:Add>' +\n \/\/Customized soap request end\n '<\/soap:Body>' +\n '<\/soap:Envelope>';\n\n var options = {\n url: endpoint,\n body: requestXML,\n \/\/Add headers options as you need\n headers: {\n 'Content-Type': 'text\/xml',\n 'SOAPAction': \"http:\/\/tempuri.org\/Add\"\n }\n }\n\n request.post(options, function (error, response, body) {\n var parseString = require('xml2js').parseString;\n var XMLResult = body;\n \/\/Validate response when filled soap request body\n assert.ok(response.statusCode == 200, 'Expected 200 OK response');\n parseString(XMLResult, function (error, result) {\n var soapBody = result['soap:Envelope']['soap:Body'][0];\n \/** \n * Add your assertion(s)\n * Example:\n * assert.equal(soapBody.DivideResponse[0].DivideResult[0], \"2\");\n *\/\n assert.equal(soapBody.AddResponse[0].AddResult[0], (add1*1 + add2*1));\n });\n });\n});\n\n\ndescribe(\"CalculatorSoap - Subtract\", function () {\n var endpoint = \"http:\/\/www.dneonline.com\/calculator.asmx\";\n var namespace = \"http:\/\/tempuri.org\/\";\n var sub1 = $globalContext[\"sub1\"];\n var sub2 = $globalContext[\"sub2\"];\n \n var requestXML = '<soap:Envelope xmlns:soap=\"http:\/\/www.w3.org\/2003\/05\/soap-envelope\" xmlns:tem=\"' + namespace + '\">' +\n '<soap:Header\/>' +\n '<soap:Body>' +\n \/\/Customized soap request start\n '<tem:Subtract>' +\n \/**\n * Add your inputs\n * Example:\n * '<tem:intA>6<\/tem:intA>' +\n * '<tem:intB>3<\/tem:intB>' +\n *\/\n '<tem:intA>' + sub1 + '<\/tem:intA>' +\n '<tem:intB>' + sub2 + '<\/tem:intB>' +\n '<\/tem:Subtract>' +\n \/\/Customized soap request end\n '<\/soap:Body>' +\n '<\/soap:Envelope>';\n\n var options = {\n url: endpoint,\n body: requestXML,\n \/\/Add headers options as you need\n headers: {\n 'Content-Type': 'text\/xml',\n 'SOAPAction': \"http:\/\/tempuri.org\/Subtract\"\n }\n }\n\n request.post(options, function (error, response, body) {\n var parseString = require('xml2js').parseString;\n var XMLResult = body;\n \/\/Validate response when filled soap request body\n assert.ok(response.statusCode == 200, 'Expected 200 OK response');\n parseString(XMLResult, function (error, result) {\n var soapBody = result['soap:Envelope']['soap:Body'][0];\n \/** \n * Add your assertion(s)\n * Example:\n * assert.equal(soapBody.DivideResponse[0].DivideResult[0], \"2\");\n *\/\n assert.equal(soapBody.SubtractResponse[0].SubtractResult[0], (sub1*1 - sub2*1));\n });\n });\n});\n\n\n", "variables": [{ "variableList": [{ "name": "add1", "value": "5" }, { "name": "add2", "value": "4" }, { "name": "sub1", "value": "100" }, { "name": "sub2", "value": "99" }], "location": { "_id": "KSN_Location_uipop_three_2ac0-1013" } }]
The response resembles the following code:
HTTP/1.1 201 Created
location: https://<synthetic_route_address>/synthetic/1.0/synthetic_tests/A_vossE9T9q_uMP3NDeuBQ
Updating/Starting/Stoping a synthetic test
API version 1.0.0
API URI components
-
Scheme HTTPS
-
Host IP Synthetic Route Host
-
Port number Synthetic Route Port
-
Path /synthetic/1.0/locations/{testId}
-
Command PUT
Command output format application/json
The sample curl command resembles the following code:
curl -X PUT -H 'Content-Type: application/json' -H 'Authorization: Bearer $ACCESS_TOKEN' -H 'X-TransactionID: test-txid' -i 'https://<synthetic_route_address>/synthetic/1.0/synthetic_tests/A_vossE9T9q_uMP3NDeuBQ' --data ' {
"syntheticType": "WebpageScript",
"active": false,
"description": "Stop this test by setting active: false"
}'
Note: To start a test, pdate the active
property to true
. To stop a test, pdate the active
property to false
.
The response resembles the following code:
HTTP/1.1 204 No Content
Getting a synthetic test
API version 1.0.0
API URI components
-
Scheme HTTPS
-
Host IP Synthetic Route Host
-
Port number Synthetic Route Port
-
Path /synthetic/1.0/synthetic_tests/{testId}
-
Command GET
Command output format application/json
The sample curl command resembles the following code:
curl -X GET -H 'Content-Type: application/json' -H 'Authorization: Bearer $ACCESS_TOKEN' -i 'https://<synthetic_route_address>/synthetic/1.0/synthetic_tests/Te-mVC29TdK1guASXotQGw'
The response resembles the following code:
HTTP/1.1 200 OK
{
"_id": "Te-mVC29TdK1guASXotQGw",
"label": "DBlue_Side_V1",
"description": "this is to test selenium script by Selenium server",
"syntheticType": "WebpageScript",
"active": true,
"schedInterval": 5,
"playbackMode": "Simultaneous",
"locations": [{
"_id": "KSN_Location_uipop_three_2ac0-1013"
}],
"configuration": {
"fileName": "DBlue.side",
"scriptContents": "ewogICJpZCI6ICJhMDllZDM5Mi1lZjQ2LTRjYmUtYmRiYS1kYTQ4ZDg5OTAyMTEiLAogICJuYW1lIjogIkltcG9ydGVkIHByb2plY3QiLAogICJ1cmwiOiAiIiwKICAidGVzdHMiOiBbewogICAgImlkIjogIlN1cHBvcnQudGVzdGNhc2UuaHRtbCIsCiAgICAibmFtZSI6ICJTdXBwb3J0IiwKICAgICJjb21tYW5kcyI6IFt7CiAgICAgICJpZCI6ICIyNDE3OGUyOS1iNGRmLTQwMjgtOTcyNC1kYjIyMTU1YjI3ZWYiLAogICAgICAiY29tbWVudCI6ICIiLAogICAgICAiY29tbWFuZCI6ICJvcGVuIiwKICAgICAgInRhcmdldCI6ICIvc3VwcG9ydC91cy9zZWFyY2gvaW5kZXguaHRtbCIsCiAgICAgICJ0YXJnZXRzIjogW10sCiAgICAgICJ2YWx1ZSI6ICIiCiAgICB9XQogIH0sIHsKICAgICJpZCI6ICJTZWFyY2gudGVzdGNhc2UuaHRtbCIsCiAgICAibmFtZSI6ICJTZWFyY2giLAogICAgImNvbW1hbmRzIjogWwoJewogICAgICAiaWQiOiAiYjQ2ZTZiODUtZTUzYy00NGRmLTljY2MtN2NiNTJiMDQzNjlkIiwKICAgICAgImNvbW1lbnQiOiAiIiwKICAgICAgImNvbW1hbmQiOiAic3RvcmUiLAogICAgICAidGFyZ2V0IjogInRlc3RlckBjbi5pYm0uY29tIiwKICAgICAgInZhbHVlIjogInVzZXJuYW1lIgogICAgfSwKCXsKICAgICAgImlkIjogIjcxNjY0NGI4LWFmZDgtNDk0NS1hMGU0LTU3M2VkZGFjZjAwMiIsCiAgICAgICJjb21tZW50IjogIiIsCiAgICAgICJjb21tYW5kIjogImNsaWNrIiwKICAgICAgInRhcmdldCI6ICIvLypbQGlkPVwic2VhcmNoa2V5d29yZFwiXSIsCiAgICAgICJ0YXJnZXRzIjogW10sCiAgICAgICJ2YWx1ZSI6ICIiCiAgICB9LCB7CiAgICAgICJpZCI6ICI4ZjI0YTEwZS01NGE5LTRhOTUtYTFiMy1hMmM5MjUzMTFjMTUiLAogICAgICAiY29tbWVudCI6ICIiLAogICAgICAiY29tbWFuZCI6ICJ0eXBlIiwKICAgICAgInRhcmdldCI6ICIvLypbQGlkPVwic2VhcmNoa2V5d29yZFwiXSIsCiAgICAgICJ0YXJnZXRzIjogW10sCiAgICAgICJ2YWx1ZSI6ICIxMDI1MjY3IgogICAgfSwgewogICAgICAiaWQiOiAiMjkwNTI5ODAtN2JjMy00MTE0LWJlMmYtMDgxMjE3NGI3YWE4IiwKICAgICAgImNvbW1lbnQiOiAiIiwKICAgICAgImNvbW1hbmQiOiAiY2xpY2siLAogICAgICAidGFyZ2V0IjogIi8vKltAaWQ9XCJpYm0tY29udGVudC1tYWluXCJdL2RpdlsxXS9kaXYvZm9ybS9maWVsZHNldC9wWzFdL2lucHV0WzJdIiwKICAgICAgInRhcmdldHMiOiBbXSwKICAgICAgInZhbHVlIjogIiIKICAgIH1dCiAgfSwgewogICAgImlkIjogIkl0ZW0udGVzdGNhc2UuaHRtbCIsCiAgICAibmFtZSI6ICJJdGVtIiwKICAgICJjb21tYW5kcyI6IFt7CiAgICAgICJpZCI6ICIxMzhkMDc5Ni1iMDQ4LTQ3YTQtOThhYS1iZmZjYmIxNGVlYTYiLAogICAgICAiY29tbWVudCI6ICIiLAogICAgICAiY29tbWFuZCI6ICJjbGljayIsCiAgICAgICJ0YXJnZXQiOiAiLy8qW0BpZD1cImlibS1lc2EtcmVzdWx0LWxpbmstbWFpbi0xXCJdIiwKICAgICAgInRhcmdldHMiOiBbXSwKICAgICAgInZhbHVlIjogIiIKICAgIH1dCiAgfV0sCiAgInN1aXRlcyI6IFt7CiAgICAiaWQiOiAiNmI5YjQyN2EtYTY3YS00MWRhLWE3NTItZDg0OTdmMjg1NjVjIiwKICAgICJuYW1lIjogIkltcG9ydGVkIHN1aXRlIiwKICAgICJwZXJzaXN0U2Vzc2lvbiI6IHRydWUsCiAgICAicGFyYWxsZWwiOiBmYWxzZSwKICAgICJ0aW1lb3V0IjogMzAwLAogICAgInRlc3RzIjogWyJTdXBwb3J0LnRlc3RjYXNlLmh0bWwiLCAiU2VhcmNoLnRlc3RjYXNlLmh0bWwiLCAiSXRlbS50ZXN0Y2FzZS5odG1sIl0KICB9XSwKICAidXJscyI6IFsiaHR0cDovL3d3dy0wMS5pYm0uY29tLyIsICJodHRwOi8vd3d3LmlibS5jb20vIl0sCiAgInBsdWdpbnMiOiBbXQp9",
"blacklist": ["datacloud.tealiumiq.com", ".cloudfront.net", "tags.tiqcdn.com\/utag\/ibm\/main\/prod\/utag", ".profile..cloudfront.net\/.png"],
"whitelist": ["ibm.com", ".s81c.com\/*"]
},
"_modifiedAt": "2020-09-22T01:58:43.011Z",
"_createdBy": "icpuser1-1",
"status": "normal"
}
Listing the synthetic tests
API version 1.0.0
API URI components
-
Scheme HTTPS
-
Host IP Synthetic Route Host
-
Port number Synthetic Route Port
-
Path /synthetic/1.0/synthetic_tests/
-
Command GET
Command output format application/json
The sample curl command resembles the following code:
curl -X GET -H 'Content-Type: application/json' -H 'X-TransactionID: test-txid' -H 'Authorization: Bearer $ACCESS_TOKEN' -i 'https://<synthetic_route_address>/synthetic/1.0/synthetic_tests'
This API also supports query parameters by using sorting (_sort), filtering (_filter), and pagination (_offset and _limit). See the following examples:
_filter=_createdAt>2020-09-17T07:21:11.074Z
_filter=_modifiedAt>2020-09-17T07:21:11.074Z
_offset=0&_limit=200
_sort=+_modifiedAt
The response resembles the following code:
HTTP/1.1 200 OK
{
"_href": "\/synthetic\/1.0\/synthetic_tests?_offset=0&_limit=100",
"_offset": "0",
"_limit": "100",
"_prev": {
"_href": "\/synthetic\/1.0\/synthetic_tests?_offset=0&_limit=100"
},
"_next": {
"_href": "\/synthetic\/1.0\/synthetic_tests?_offset=100&_limit=100"
},
"items": [
{
"_id": "Te-mVC29TdK1guASXotQGw",
"label": "DBlue_Side_V1",
"description": "this is to test selenium script by Selenium server",
"syntheticType": "WebpageScript",
"active": true,
"schedInterval": 5,
"playbackMode": "Simultaneous",
"locations": [
{
"_id": "KSN_Location_uipop_three_2ac0-1013"
}
],
"configuration": {
"fileName": "DBlue.side",
"scriptContents": *********
},
"_modifiedAt": "2020-09-17T07:21:11.074Z",
"_createdBy": "mcmdemo",
"status": "normal"
},
{
"_id": "axNrd6UKSh-OYq9WTomo3g",
"label": "TestHTTPR",
"description": "this is to rest URL",
"syntheticType": "HTTPAction",
"active": true,
"schedInterval": 1,
"playbackMode": "Simultaneous",
"locations": [
{
"_id": "KSN_Location_uipop_three_2ac0-1013"
}
],
"configuration": {
"url": "http:\/\/www.google.com"
}
"_modifiedAt": "2020-09-17T06:57:10.300Z",
"_createdBy": "mcmdemo",
"status": "normal"
}
]
}
Deleting a synthetic test
API version 1.0.0
API URI components
-
Scheme HTTPS
-
Host IP Synthetic Route Host
-
Port number Synthetic Route Port
-
Path /synthetic/1.0/synthetic_tests/{testId}
-
Command DELETE
Command output format application/json
The sample curl command resembles the following code:
curl -X DELETE -H 'Content-Type: application/json' -H 'Authorization: Bearer $ACCESS_TOKEN' -i 'https://<synthetic_route_address>/synthetic/1.0/synthetic_tests/XFqopWQVTCSbVln09CpEnQ'
The response resembles the following code:
HTTP/1.1 204 No Content