Skip to content
Itai Agmon edited this page Sep 14, 2022 · 11 revisions

Difido Server API Documentation

Root URL: http://{server}:{port}/api/

Execution Resource

Add execution

Adding new execution in the server or joining to an existing shared execution

Request

URI: executions/

Method: POST

Content Type: application/json

Body:

{
   "description":"<Execution description>",
   "executionProperties":{
      "key0":"val0",
      "key1":"val2"
   },
   "shared":false,
   "forceNew":false
}

Response

The call will return the execution id Body:

5

Example

> curl -X POST --data "{\"description\":\"example\", \"executionProperties\":{\"key0\":\"val0\"},\"shared\":false,\"forceNew\":false}" -H "Content-Type:application/json" http://localhost:8080/api/executions/

End Execution

Setting execution to not active. This will not allow any reports to be added to the executions. This is an irreversible process that

Request

URI: executions/{execution}?active=false

Method: PUT

Content Type: text/plain

Example

> curl -X PUT -H "Content-Type:text/plain" http://localhost:8080/api/executions/49?active=false

Delete Execution

Deleting execution completely from the server. This will not delete executions that are still active. By default this will also delete the execution from the Elastic

Request

URI: executions/{execution}?fromElastic=false

Method: DELETE

Content Type: text/plain

Example

> curl -X DELETE -H "Content-Type:text/plain" http://localhost:8080/api/executions/49?fromElastic=false

Machine Resource

Get Machines

To get all the machines in execution

Request

URI: executions/{execution}/machines

Method: GET

Response Json with all the machines in the execution

Example

> curl http://localhost:8080/api/executions/49/machines

Get Machine

Get a single machine from the execution

Request

URI: executions/{execution}/machines/{machine}

Method: GET

Response Json that represents the machine in the execution

Example

> curl http://localhost:8080/api/executions/49/machines/0

Add Machine

To add machine to the execution

Request

URI: executions/{execution}/machines

Method: POST

Content Type: application/json

Body:

{
   "type":"machine",
   "name":"<Machine name>",
   "status":"success",
   "children":null
}

Response

The call will return index of the added machine in the execution Body:

5

Update Machine

The update machine is actually used to update all the scenarios and tests that were executed until this point. The json can be pretty complex since it holds all the scenario tree.

Request

URI: executions/{execution}/machines/{machine}

Method: PUT

Content Type: application/json

Body:

{
   "type":"machine",
   "name":"agmon-PC",
   "status":"error",
   "children":[
      {
         "type":"scenario",
         "name":"regression",
         "status":"error",
         "children":[
            {
               "type":"scenario",
               "name":"sub02",
               "status":"error",
               "children":[
                  {
                     "type":"test",
                     "name":"reporterWithCustomHtml",
                     "status":"success",
                     "index":0,
                     "uid":"431438075599-1",
                     "duration":5207,
                     "timestamp":"12:27:03:"
                  },
                  {
                     "type":"test",
                     "name":"reporterWithLinkToTest",
                     "status":"error",
                     "index":1,
                     "uid":"431438075599-2",
                     "duration":1137108,
                     "timestamp":"12:27:08:"
                  },
                  {
                     "type":"test",
                     "name":"reporterWithLeveling",
                     "status":"success",
                     "index":2,
                     "uid":"431438075599-3",
                     "duration":0,
                     "timestamp":"12:47:09:"
                  }
               ],
               "scenarioProperties":null
            }
         ],
         "scenarioProperties":{
            "station":"10.100.102.7",
            "sutFile":"mystation.xml",
            "version":"unknown",
            "user":"agmon",
            "testDir":"projects/jsystemServices/target/classes"
         }
      }
   ]
}

Test Details Resource

Add Test Details

This service is used to add and update a single test details. That means, attributes like the test name, description and uid, the test properties and parameters and the report elements that describes the steps that were performed during the test.

Request

URI: /executions/{execution}/details

Method: POST

Content type: application/json

Body:

{
   "uid":"431438075599-2",
   "reportElements":[      
      {
         "title":"Start time: Tue Jul 28 12:45:54 IDT 2015",
         "message":null,
         "status":"success",
         "type":"regular",
         "time":"12:46:04:"
      },
      {
         "title":"End time  : Tue Jul 28 12:46:04 IDT 2015",
         "message":null,
         "status":"success",
         "type":"regular",
         "time":"12:46:04:"
      },
      {
         "title":"Test running time: 9 sec.",
         "message":null,
         "status":"success",
         "type":"regular",
         "time":"12:46:05:"
      }
   ]
   
}

Add File to Test

This service is used to add attachments to tests. The attachments can be images, text or binary files.

Request

URI: /executions/{execution}/details/{uid}/file

Method: POST

Body: A multipart body with a 'bin' part that stores the binary file

curl --location --request POST 'http://localhost:8080/api/executions/1154/details/7711663154639-1/file' --form 'file=@"/C:/myfile.txt"'

Reports Resource

Get Execution Reports

This call is used by the front end to retrieve the data for the execution table

Request

URI: /reports

Method: GET

Example

> curl http://localhost:8080/api/reports

Plugin Resource

Get Plugins

This call is used by the front end to get the name of all the plugins that are configured in the server

Request

URI: /plugins

Method: GET

Response

Body:

["DefaultMailPlugin"]

Example

> curl http://localhost:8080/api/plugins

Execute Plugin

This call is used by the front end to execute a single plugin on one ore more executions

URI: /plugins/{plugin}

Method: POST

Query Param: plugin, executions, params

Example

> curl -X POST "http://localhost:8080/api/plugins/[email protected]&executions=3&executions=7"

Elastic Resource

Search

This call can be used for sending queries directly to the Elasticsearch server.

Request

URI: api/elastic/{index}/{doc}

Method: Post

Content Type: application/json

Example

> curl -X POST -H "Content-Type:application/json" --data "{\"query\": { \"match_all\": {} }}" "http://localhost:8080/api/elastic/report/test"

Example for Adding report link in Jenkins

(using bash + groovy)

import groovy.json.JsonSlurper
//Getting all reports
String string = new URL("http://172.22.146.32:8080/api/reports/").getText()
//Desciption created by the job - should be unique
String desc =  manager.envVars["Platform"] + "_" +  manager.envVars["BUILD_NUMBER"]
//All tests are in json/data
def json = new JsonSlurper().parseText(string).data
//finding test with matching description, than grabing the link property of that test
def linkString = json.find { it.Description == desc }?.Link
//Adding a badge link
manager.addBadge("info.gif", "Report", "http://<reporterIP>:8080/" + linkString)

in the Jenkins job that runs the test, change the file remoteDifido.properties file so it will contain a unique number, like the build number (example is linux bash script)

#Creating a unique description for execution
sed -i.bak "s/execution.description=Local_Automation_Run/execution.description=${Platform}_${BUILD_NUMBER}/g" tests/remoteDifido.properties
sed -i.bak "s/enabled=false/enabled=true/g" tests/remoteDifido.properties

Clone this wiki locally