Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

Obtain the REST URL to execute a Job from Test Scenarios

[Deleted User]
[Deleted User] Posts: 0 admin
edited December 2016 in CTP

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

Comments

  • Nihar1991
    Nihar1991 Posts: 52

    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
    Nihar

  • Matt Love
    Matt Love Posts: 100 admin
    edited September 2020

    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