Add GET test results and add report page output
A GET handler was added for retrieving test results with URL of the form: /v1/results/{test_id}. The report page can now be used to view results. It should be accessed with URL of the form: /output.html?test_id={test_id}. This is just to keep it simple for now. Change-Id: I28e9ebf74cc7a6dad360232840b49c6aae27dab0
This commit is contained in:
parent
e9902d7168
commit
62b6c74a33
@ -29,6 +29,18 @@ var capitaliseFirstLetter = function (string) {
|
||||
return string.charAt(0).toUpperCase() + string.slice(1);
|
||||
};
|
||||
|
||||
// Get the value of a GET variable in the URL.
|
||||
var getUrlParam = function(variable) {
|
||||
var searchString = window.location.search.substring(1);
|
||||
var searchVariables = searchString.split('&');
|
||||
for (var i = 0; i < searchVariables.length; i++) {
|
||||
var getVar = searchVariables[i].split('=');
|
||||
if (getVar[0] == variable) {
|
||||
return getVar[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Function searches for test with specified test_id on github and opens result in new window
|
||||
var get_code_url = function (test_id) {
|
||||
var id = test_id.split('/').join('.'),
|
||||
|
@ -26,7 +26,8 @@ pecan.conf
|
||||
# Server Specific Configurations
|
||||
server = {
|
||||
'port': '8000',
|
||||
'host': '0.0.0.0'
|
||||
'host': '0.0.0.0',
|
||||
'protocol': 'http'
|
||||
}
|
||||
|
||||
# Pecan Application Configurations
|
||||
@ -34,8 +35,10 @@ app = {
|
||||
'root': 'refstack.api.controllers.root.RootController',
|
||||
'modules': ['refstack.api'],
|
||||
'db_url': 'mysql://root:r00t@127.0.0.1/refstack',
|
||||
'static_root': '%(confdir)s/public',
|
||||
'template_path': '%(confdir)s/${package}/templates',
|
||||
'static_root': '%(confdir)s/../static',
|
||||
'template_path': '%(confdir)s/../templates',
|
||||
# The 'debug' option should be false in production servers, but needs to be
|
||||
# true in development in order to allow the static_root option to work.
|
||||
'debug': False,
|
||||
'errors': {
|
||||
'404': '/error/404',
|
||||
|
@ -31,6 +31,23 @@ class ResultsController(rest.RestController):
|
||||
"""GET handler."""
|
||||
return {'Result': 'Ok'}
|
||||
|
||||
@pecan.expose("json")
|
||||
def get_one(self, test_id):
|
||||
"""Return test results in JSON format.
|
||||
|
||||
:param test_id: ID of the test to get the JSON for.
|
||||
"""
|
||||
test_info = pecan.request.backend.get_test(test_id)
|
||||
if not test_info:
|
||||
pecan.abort(404)
|
||||
|
||||
test_list = pecan.request.backend.get_test_results(test_id)
|
||||
test_name_list = [test_dict[0] for test_dict in test_list]
|
||||
return {"cpid": test_info.cpid,
|
||||
"created_at": test_info.created_at,
|
||||
"duration_seconds": test_info.duration_seconds,
|
||||
"results": test_name_list}
|
||||
|
||||
@pecan.expose(template='json')
|
||||
def post(self, ):
|
||||
"""POST handler."""
|
||||
|
@ -68,3 +68,21 @@ class LocalBackend(object):
|
||||
session.add(test)
|
||||
session.commit()
|
||||
return test_id
|
||||
|
||||
def get_test(self, test_id):
|
||||
"""Get test information from the database.
|
||||
|
||||
:param test_id: The ID of the test.
|
||||
"""
|
||||
test_info = self.db_session.query(models.Test).\
|
||||
filter_by(id=test_id).first()
|
||||
return test_info
|
||||
|
||||
def get_test_results(self, test_id):
|
||||
"""Get all passed tempest tests for a particular test.
|
||||
|
||||
:param test_id: The ID of the test.
|
||||
"""
|
||||
results = self.db_session.query(models.TestResults.name).filter_by(
|
||||
test_id=test_id).all()
|
||||
return results
|
||||
|
@ -276,7 +276,7 @@ var render_defcore_report_page = function () {
|
||||
schema = '',
|
||||
schema_selector = $('select#schema_selector');
|
||||
|
||||
if (window.result_source === '{{result_source}}') {
|
||||
if (!window.result_source) {
|
||||
window.result_source = 'sample_test_result.json';
|
||||
}
|
||||
if (schema_selector.length === 0) {
|
||||
@ -286,10 +286,10 @@ var render_defcore_report_page = function () {
|
||||
}
|
||||
console.log(schema);
|
||||
$.when(
|
||||
$.get('mustache/report_base.mst', undefined, undefined, 'html'),
|
||||
$.get('mustache/single_header.mst', undefined, undefined, 'html'),
|
||||
$.get('mustache/single_capabilities_details.mst', undefined, undefined, 'html'),
|
||||
$.get('capabilities/' + schema, undefined, undefined, 'json'),
|
||||
$.get('/mustache/report_base.mst', undefined, undefined, 'html'),
|
||||
$.get('/mustache/single_header.mst', undefined, undefined, 'html'),
|
||||
$.get('/mustache/single_capabilities_details.mst', undefined, undefined, 'html'),
|
||||
$.get('/capabilities/' + schema, undefined, undefined, 'json'),
|
||||
$.get(window.result_source, undefined, undefined, 'json')
|
||||
).done(function (base_template, header_template, caps_template, schema, test_result) {
|
||||
var caps_list = window.build_caps_list(schema[0], filters),
|
||||
@ -320,10 +320,10 @@ var render_defcore_diff_report_page = function () {
|
||||
schema = schema_selector[0].value;
|
||||
}
|
||||
$.when(
|
||||
$.get('mustache/report_base.mst', undefined, undefined, 'html'),
|
||||
$.get('mustache/diff_header.mst', undefined, undefined, 'html'),
|
||||
$.get('mustache/diff_capabilities_details.mst', undefined, undefined, 'html'),
|
||||
$.get('capabilities/' + schema, undefined, undefined, 'json'),
|
||||
$.get('/mustache/report_base.mst', undefined, undefined, 'html'),
|
||||
$.get('/mustache/diff_header.mst', undefined, undefined, 'html'),
|
||||
$.get('/mustache/diff_capabilities_details.mst', undefined, undefined, 'html'),
|
||||
$.get('/capabilities/' + schema, undefined, undefined, 'json'),
|
||||
$.get(window.result_source, undefined, undefined, 'json'),
|
||||
$.get(window.prev_result_source, undefined, undefined, 'json')
|
||||
).done(function (base_template, header_template, caps_template, schema,
|
||||
|
@ -11,12 +11,13 @@
|
||||
<script src="/js/jquery.cookie.js"></script>
|
||||
<script src="/js/spin.js"></script>
|
||||
<script src="http://cdnjs.cloudflare.com/ajax/libs/mustache.js/0.8.1/mustache.min.js"></script>
|
||||
<script>
|
||||
window.result_source = '{{result_source}}';
|
||||
</script>
|
||||
<script src="/js/helpers.js"></script>
|
||||
<script src="/js/refstack.js"></script>
|
||||
<script>
|
||||
var test_id = getUrlParam('test_id');
|
||||
if (test_id) {
|
||||
window.result_source = "/v1/results/" + test_id;
|
||||
}
|
||||
render_page = function(){
|
||||
render_defcore_report_page();
|
||||
};
|
||||
|
@ -60,6 +60,25 @@ str:data - a string input containing json as shown in lower example.
|
||||
'message': 'the job_id already has results'
|
||||
}
|
||||
|
||||
----
|
||||
**description:** Get the results of a test run in JSON format.
|
||||
|
||||
**url:** get /v1/results/{test_run_id}
|
||||
|
||||
**normal response:** http:200 - OK
|
||||
|
||||
{
|
||||
'created_at': '2015-01-16 10:10:10',
|
||||
'duration_seconds': 25,
|
||||
'cpid': '6b678f2c7fa94c7e942728b300451b56',
|
||||
'results': [
|
||||
'tempest.api.test.id',
|
||||
'tempest.api.another.test.id'
|
||||
]
|
||||
}
|
||||
|
||||
----
|
||||
|
||||
**Data model impact**
|
||||
|
||||
* add int field called duration_seconds to test model
|
||||
|
Loading…
Reference in New Issue
Block a user