Commit bbf6c5bb authored by Stevan Radakovic's avatar Stevan Radakovic Committed by Remi Duraffort
Browse files

LAVA-1220 - Update API calls and docs for scheduler changes.

Add new  XML-RPC api calls like to reflect changes in test job and devices models.
Update XML-RPC docs like results.make_custom_query to reflect the scheduler changes.
Update query docs for new conditions with examples.

Change-Id: I26de511abcfbe05de0e0b53504bbd2aa4e4cf1f4
parent 5301ef66
......@@ -79,7 +79,7 @@ test cases in which particular field satisfies a condition. List of supported
fields which can be used as condition field is available as autocomplete list
in the condition 'Field name' field. You can also add conditions with fields in
the object set which is queried (i.e. if test jobs are query object set user
can add conditions such as submitter, device, priority, status...).
can add conditions such as submitter, health, device, priority, state...).
It is also possible to add conditions using custom metadata. Since metadata can
contain custom field names, keep in mind that the query might not return
......@@ -239,7 +239,7 @@ LAVA Query use cases
* Condition 1:
* Condition model: test job
* Field name: status
* Field name: health
* Operator: Exact match
* Field value: Incomplete
......@@ -255,7 +255,7 @@ LAVA Query use cases
* Condition 1:
* Condition model: test job
* Field name: status
* Field name: health
* Operator: Exact match
* Field value: Complete
......@@ -296,6 +296,15 @@ LAVA Query use cases
* Operator: Greater than
* Field value: 40
#. List of jobs stuck in 'Canceling' state:
* Condition 1:
* Condition model: testjob
* Field name: state
* Operator: Exact match
* Field value: Canceling
.. _lava_charts:
......
......@@ -83,11 +83,11 @@ class ResultsAPI(ExposedAPI):
Example
-------
# Get all test jobs submitted by the user 'kernel-ci', and which ended as
# 'Incomplete':
# Get all test jobs submitted by the user 'kernel-ci', and which ended
# as 'Incomplete':
server.results.make_custom_query("testjob",
"testjob__submitter__exact__kernel-ci,"
"testjob__status__exact__Incomplete")
"testjob__health__exact__Incomplete")
[{ jobXX }, { jobXY }, ...]
# Get all test cases in a test suite named 'custom-tests', that failed,
......
......@@ -813,6 +813,8 @@ class SchedulerAPI(ExposedAPI):
"""
Name
----
DEPRECATED - use `job_health` or `job_state` instead.
`job_status` (`job_id`)
Description
......@@ -882,6 +884,8 @@ class SchedulerAPI(ExposedAPI):
"""
Name
----
DEPRECATED - use `job_health` or `job_state` instead.
job_list_status ([job_id, job_id, job_id])
Description
......@@ -932,6 +936,102 @@ class SchedulerAPI(ExposedAPI):
job_status[str(job.display_id)] = job.get_legacy_status_display()
return job_status
def job_health(self, job_id):
"""
Name
----
`job_health` (`job_id`)
Description
-----------
Get the health of given job id.
Arguments
---------
`job_id`: string
Job id for which the output is required.
Return value
------------
This function returns an XML-RPC structures of job health with the
following fields.
The user is authenticated with an username and token.
`job_health`: string
['Unknown'|'Complete'|'Incomplete'|'Canceled']
"""
self._authenticate()
if not job_id:
raise xmlrpclib.Fault(400, "Bad request: TestJob id was not "
"specified.")
try:
job = get_restricted_job(self.user, job_id)
except PermissionDenied:
raise xmlrpclib.Fault(
401, "Permission denied for user to job %s" % job_id)
except TestJob.DoesNotExist:
raise xmlrpclib.Fault(404, "Specified job not found.")
job_health = {
'job_id': job.id,
'job_health': job.get_health_display()
}
if job.is_multinode:
job_health.update({
'sub_id': job.sub_id
})
return job_health
def job_state(self, job_id):
"""
Name
----
`job_state` (`job_id`)
Description
-----------
Get the state of given job id.
Arguments
---------
`job_id`: string
Job id for which the output is required.
Return value
------------
This function returns an XML-RPC structures of job state with the
following fields.
The user is authenticated with an username and token.
`job_state`: string
['Submitted'|'Scheduling'|'Scheduled'|'Running'|'Canceling'|'Finished']
"""
self._authenticate()
if not job_id:
raise xmlrpclib.Fault(400, "Bad request: TestJob id was not "
"specified.")
try:
job = get_restricted_job(self.user, job_id)
except PermissionDenied:
raise xmlrpclib.Fault(
401, "Permission denied for user to job %s" % job_id)
except TestJob.DoesNotExist:
raise xmlrpclib.Fault(404, "Specified job not found.")
job_state = {
'job_id': job.id,
'job_state': job.get_state_display()
}
if job.is_multinode:
job_state.update({
'sub_id': job.sub_id
})
return job_state
def all_jobs(self):
"""
Name
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment