REST API and web-based service to control Emender and to show test results generated by Emender.
- JVM version 6 or better
- Leiningen
- GNU Make
- JRE version 6 or better (JRE 7 is recommended)
- GIT CLI client
-
Clone the emender-service repository
-
Run the following command:
$ make all
To start the service, run the following command:
$ make run
All options needs to be provided in the configuration file emender-service.ini
The main configuration file is written in so-called INI format. File is divided into several sections, each section contain various pairs key=value. Please don't use quotes for string values, it's not necessary.
[jenkins]
hostname=http://my.jenkins.instance.org
port=8080
[tests]
job-suffix=(test)
[result-cache]
filename=results.edn
pretty-print=true
use-cache=false
[api]
prefix=/api/v1
[ui]
[email protected]
[emender]
path=/home/user/emender/
tests=/home/user/emender/test/
[config]
verbose=false
delete-workdirs=true
The only section that needs to be changed is [emender]. You need to provide path to Emender itself and to Emender tests directory as well. The section [jenkins] and [tests] is not used at this moment, as it needs much better integration with Jenkins (not needed ATM).
Emender-service can be controlled via set of simple REST API calls. Every supported API calls are described below:
Address: http://$hostname:$port/api/info
Method: GET
Example:
$ curl -v localhost:3000/api/info
Return value (example):
{"toasterNotifications":["info|Api response|<strong>Emender Service<\/strong> api v1 on<\/br>$hostname"],"configuration":$configuration}
Address: http://$hostname:$port/api/v1/books http://$hostname:$port/api/v1/book-list
Method: GET
Example:
$ curl -v localhost:3000/api/v1/books
$ curl -v localhost:3000/api/v1/book-list
Return value (example):
["doc-Other-Book (test)","doc-Red_Hat_Developer_Toolset-1-Release_Notes-en-US (test)"]
Address: http://$hostname:$port/api/v1/jobs http://$hostname:$port/api/v1/job-list
Method: GET
Example:
$ curl -v localhost:3000/api/v1/jobs
$ curl -v localhost:3000/api/v1/job-list
Return value (example):
[{"id":1,"job":"doc-Red_Hat_Developer_Toolset-1-Release_Notes-en-US (test)"},
{"id":2,"job":"doc-Other-Book (test)"},
{"id":3,"job":"doc-Red_Hat_Developer_Toolset-1-Release_Notes-en-US (test)"}]
Address: http://$hostname:$port/api/v1/job-info/$job-id
Method: GET
Example:
$ curl -v localhost:3000/api/v1/job-info/1
Return value (job number is correct):
{"id":2,"datetime":"2016-04-19 16:16:31","job":"doc-Other-Book (test)","url":null,"branch":null,"results":"actual test results"}
Return value (job number is incorrect):
{"status":"error","error":"Bad job ID","uri":"\/api\/v1\/job-info\/gfdgdfs"}
Address: http://$hostname:$port/api/v1/job-started/$book-name
Method: POST
Example:
$ curl -X POST --header "Content-Type: application/json" -v "localhost:3000/api/v1/job-started/doc-Other-Book+(test)"
Return value:
{"status":"ok"}
Address: http://$hostname:$port/api/v1/job-finished/$book-name
Method: POST
Example:
$ curl -X POST --header "Content-Type: application/json" -v "localhost:3000/api/v1/job-finished/doc-Other-Book+(test)"
Return value:
{"status":"ok"}
Address: localhost:3000/api/v1/job-results/$book-name
Method: POST
Example:
$ curl -X POST --header "Content-Type: application/json" -d "@results.json" -v "localhost:3000/api/v1/job-results/$book-name
The file results.json should be generated by Emender, ie. it must use its format.
Return value:
{"status":"ok"}
Address: localhost:3000/api/v1/job-results-html/$book-name
Method: POST
Example:
$ curl -X POST --header "Content-Type: text/plain" -d "@results.txt" -v "localhost:3000/api/v1/job-results-html/$book-name
The file results.txt should contain two parts:
- results.html generated by Emender
- results.json generated by Emender as well
The service will separate those two parts automatically, so please don't try to fool it :)
Return value:
{"status":"ok"}
Address: http://$hostname:$port/api/v1/run-test/$book-name
Method: POST
Example:
$ curl -X POST --header "Content-Type: application/json" -d "@testinfo.json" -v "localhost:3000/api/v1/run-test/doc-Test-Book1+(test)"
Content of testinfo.json
{
"repository": {
"url" : "[email protected]:emender/emender-testbook.git"
"branch" : "master"
},
"tests": [
"Test1",
"Test2",
]
}
Possible return values:
{"status":"ok","results":{"Test1": actual test results}}
{"status":"repo-clone-failed"}
Copyright © 2016 Pavel Tisnovsky [email protected], Red Hat
Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.