Obtain the REST URL to execute a Job from Test Scenarios
The API Testing Module in CTP allows users to execute automated tests as a Job. From the Docs:
Automated provisioning during testing: You can configure a test job that you want to execute one or more times, then associate an environment context with that test scenario so that the appropriate environment is always provisioned before that test job is run. For example, a test scenario can use one set of test data and endpoint variables for execution in a development testing environment and another in a system integration testing environment. The job execution history stores the associated test environment settings and variables along with results, enabling complete traceability.
You can get to the Test Scenarios UI by going to API Testing
CTP > API Testing > Jobs
From here you can create a Job to execute tests after provisioning a specific environment
When you execute this Job it will provision the environment first and then run the tests.
The question is, how do I run this in automation?
Each of these jobs has a unique REST URL to run it. Follow these steps to obtain the URL
- Take note of your Job Name. In my case it was P2 Regression
- Navigate to "YOUR CTP HOST:PORT"/em/apidoc
- from here find Jobs: /v2/jobs. Use this API here or as a part of your automation script to find the Jobs ID
You can also run this API callhttp://<CTP_HOST>:<CTP_PORT>/em/api/v2/jobs?name=P2%20Regerssion&limit=50&offset=0
- From this you can see that the JobId is 201
- You can now execute the POST /v2/jobs/{jobid}/histories call
You wll see that the final call is
POST http://drdoom.parasoft.com:8080/em/api/v2/jobs/201/histories with the optional body { "systemId": 0, "environmentId": 0, "environmentInstanceId": 0 }
This will automatically provision the environment and execute tests against it
Comments
-
Hi Chris,
Is there any way to run this generated Rest API from the outside like selenium or Jenkins or any way to run it from the scheduler.
Actually I have a situation to execute a test job continuously for a long time to check the performance of the service.
is there any way to do this.Appreciate your help here
Thanks
Nihar0 -
Hi Nihar,
Yes, the purpose of the REST APIT is to be able to call it from outside. Here is an example using the Linux curl command.
curl --user admin:admin --header "Content-Type: application/json" --request POST --data '{}' http://10.12.73.31:8080/em/api/v2/jobs/1/histories?async=false
0