Automating load testing and integrating it with other processes is becoming more and more common. WebLOAD lets you automate load tests and build continuous integration processes with tools like Jenkins and Bamboo, but in some cases, you may need additional flexibility to accommodate other environments or needs.
WebLOAD resolves this with an open API, which lets you execute sessions, prepare reports, access data, etc.
The WebLOAD Open API
The API provides a dynamic explanation and is accessible via the WebLOAD Dashboard, using the link:
http://{server_address}:8080/api-docs/docs.html
Of course, replace ‘{server_address}’ with your server name.
Click any of the links to view the relevant API for running sessions, preparing reports, getting results, etc.
Each API can be created easily using the UI, as seen below:
Use Case Example
Assume you run a Load Testing session, access to data and create a report using automation only. The session runs in a context of a UNIX script, but it can be converted to other programming languages based on your needs.
Start a new session from a template ‘my.tpl’ and store the results in ‘out.ls’
curl -X POST --header 'Content-Type: application/x-www-form-urlencoded' --header 'Accept: application/json' -d 'template=my.tpl&lsName=out.ls&responseTimeout=60' 'http://localhost:8080/api/session'
Sample response:
{ "code": "STARTED", "response": "New Session started.session/23", "sessionid": "23" }
Check the status of the session by extracting the session-id from the above, for example using:
sid = `sed -n 's/.*"sessionid": "\([0-9]*\).*/\1/p'`
Get the session details:
curl 'http://localhost:8080/api/session/${sid}'
Which will become in your script:
curl 'http://localhost:8080/api/session/23'
Sample response:
{ "sessionId": 23, "reportResolution": 20, "startTime": 1494856676000, "endTime": 1494856776000, "path": "c:\\temp\\out.ls.ls", "returnCode": "Test passed", "failedReason": "Test passed", "text": "out.ls" }
Get data for the session — for example, get the load-size.
The ‘target’ will be ‘Total.Performance Measurements.Load Size’:
curl -X POST --header 'Content-Type: application/x-www-form-urlencoded' --header 'Accept: application/json' -d 'target=Total.Performance%20Measurements.Load%20Size&sessionid=23' 'http://localhost:8080/api/render'
Sample response:
[ { "target": "Load Size", "datapoints": [ [ 5, //load size 1494856696000 //timestamp ], [ 10, 1494856716000 ], ….
Generate an Analytics report using the Summary Portfolio for the session:
Curl 'http://localhost:8080/api/analytics?sessionid=23&portfolio=Summary%20Portfolio&format=PDF&name=Report'