Obtain the REST URL to execute a Job from Test Scenarios

Chris ColosimoChris Colosimo Posts: 67 admin
edited December 2016 in Continuous Testing Platform

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

  1. Take note of your Job Name. In my case it was P2 Regression
  2. Navigate to "YOUR CTP HOST:PORT"/em/apidoc
  3. 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 call
http://<CTP_HOST>:<CTP_PORT>/em/api/v2/jobs?name=P2%20Regerssion&limit=50&offset=0

  1. From this you can see that the JobId is 201
  2. 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

Sign In or Register to comment.