Add run_metadata to upstream_run.html

This commit is contained in:
Austin Clark 2015-08-05 13:54:33 -06:00
parent d3073994d6
commit 6b1728b5c5
6 changed files with 116 additions and 10 deletions

View File

@ -0,0 +1,3 @@
.highlight {
font-weight: bold;
}

View File

@ -18,22 +18,67 @@
window.addEventListener('load', function() {
//default panel display
$("#runs-panel").hide();
$("#gerrit-panel").show();
$("#run-metadata-panel").hide();
//dict containing all run_metadata objects, keyed by run_id
var RUN_METADATA = {};
//sets the run metdata of the associated run in the proper div
function show_run_metadata(id) {
$("#run-metadata-table").html("<thead><th>Key</th><th>Value</th></thead>");
var meta = RUN_METADATA[id];
for (var i in meta) {
var obj = meta[i];
var row = $("<tr><td>" + obj['key'] + "</td>" +
"<td>" + obj['value'] + "</td></tr>");
$("#run-metadata-table").append(row);
}
}
//run_metadata will be queried from subunit2sql when given run_id
function get_run_metadata(request, run_id) {
$.getJSON((request),function(metadata) {
RUN_METADATA[run_id]=metadata;
});
}
//Takes a list of runs and creates a pretty div for each
function display_runs(data) {
$("#runs-panel").show();
$("#runs-panel").append("<ul id=\"runs-list\"></ul>");
for (var i in data) {
var run_obj = data[i]
var div = $("<div class=\"span12\" id=\"run-div-" + i + "\"></div>");
$(div.append("<a href=" + run_obj['artifacts'] + " target=\"_blank\">" + run_obj['artifacts'] + "\n</a>"));
$("#runs-panel").append(div);
var run_obj = data[i];
//get run_metadata
var request = 'upstream_api_run_id_' + run_obj['id'] + '.json';
get_run_metadata(request, run_obj['id']);
var li = $("<li class =\"run-li\" id=\"run-li-" + i + "\" value=\"" + run_obj['id'] + "\"></li>");
//on mouseover, show the run_metadata for this run object (li)
$(li).hover(
function () {
$(this).addClass("highlight");
show_run_metadata($(this).attr("value"));
},
function () {
$(this).removeClass("highlight");
}
);
$(li.append("<a href=" + run_obj['artifacts'] + " target=\"_blank\">" + run_obj['artifacts'] + "\n</a>"));
$("#runs-list").append(li);
$("#runs-panel-heading").html("Displaying " + i + " Runs");
}
$("#run-metadata-panel").show();
}
$('#gerrit-id').keypress(function (e) {
if (e.which == 13) {
$( "#gerrit-id-button" ).click();
@ -41,6 +86,8 @@ window.addEventListener('load', function() {
}
});
//click triggers the api call that returns the run data
$('#gerrit-id-button').click(function() {
var request = 'upstream_api_changeid_'+$("#gerrit-id").val()+'.json';
$("#runs-panel").append("<a href=\"https://review.openstack.org/" + $("#gerrit-id").val() +

View File

@ -3,7 +3,10 @@
{% block title %}Upstream Run Metadata{% endblock %}
{% block head-extra %}<script src="{% static 'js/upstream_run.js' %}"></script>{% endblock %}
{% block head-extra %}
<script src="{% static 'js/upstream_run.js' %}"></script>
<script src="{% static 'css/upstream_run.css' %}"></script>
{% endblock %}
{% block body %}
@ -17,7 +20,7 @@
</div>
<div class="row">
<div class="col-lg-12">
<div class="col-lg-6">
<div class="panel panel-default">
<div class="panel panel-heading" id="runs-panel-heading">Analyze Run</div>
<div class="panel panel-body">
@ -29,6 +32,16 @@
</div>
</div>
</div>
<div class="col-lg-6">
<div class="panel panel-default" id="run-metadata-panel">
<div class="panel panel-heading">Run Metadata</div>
<div class="panel panel-body">
<div class="table-responsive" id="run-metadata-table-div">
<table class="table table-bordered table-hover table-striped" id="run-metadata-table"></table>
</div>
</div>
</div>
</div>
</div>

View File

@ -11,4 +11,20 @@
<!-- /.col-lg-12 -->
</div>
<div class="row">
<div class="col-lg-8">
<div class="panel panel-default">
<div class="panel panel-heading" id="runs-panel-heading">Compare Tests</div>
<div class="panel panel-body">
<div class="col-lg-4">
<div id="test-1" class="span6">Test</div>
</div>
<div class="col-lg-4">
<div id="test-avg" class="span6">Avg</div>
</div>
</div>
</div>
</div>
</div>
{% endblock %}

View File

@ -31,10 +31,7 @@ def _get_runs(change_id):
engine = create_engine('mysql://query:query@logstash.openstack.org' +
':3306/subunit2sql')
Session = sessionmaker(bind=engine)
# create a Session
session = Session()
list_of_runs = api.get_runs_by_key_value(key="build_change",
@ -47,8 +44,33 @@ def _get_runs(change_id):
return ret_list
def _get_metadata(run_id):
"""Returns a dict of run_metadata objects associated with a run_id
:param run_id:
:return:
"""
engine = create_engine('mysql://query:query@logstash.openstack.org' +
':3306/subunit2sql')
Session = sessionmaker(bind=engine)
session = Session()
metadata = api.get_run_metadata(run_id,session=session)
ret_list = []
for meta in metadata:
ret_list.append(meta.to_dict())
return ret_list
class GerritURLEndpoint(Endpoint):
def get(self, request, change_id):
return _get_runs(change_id)
class RunMetadataEndpoint(Endpoint):
def get(self, request, run_id):
return _get_metadata(run_id)

View File

@ -19,6 +19,7 @@ from run import RunView
from test import TestView
from api import GerritURLEndpoint
from api import RunMetadataEndpoint
urlpatterns = patterns('',
url(r'^run.html$',
@ -31,5 +32,9 @@ urlpatterns = patterns('',
url(r'^api_changeid_(?P<change_id>\d+).json$',
GerritURLEndpoint.as_view(),
name='gerrit_url')
name='gerrit_url'),
url(r'^api_run_id_(?P<run_id>[a-zA-Z0-9!$* \t\r\n\-]+).json$',
RunMetadataEndpoint.as_view(),
name='run_metadata_url')
)