Intial commit of test crossection page and json data

Change-Id: I649012ae28bd6ecd617cbb50b84d2d6cf7ebaf3c
Signed-off-by: Ryan Moats <rmoats@us.ibm.com>
This commit is contained in:
Ryan Moats 2015-09-15 14:39:56 -05:00
parent c614729c18
commit 6eb5415332
2 changed files with 287 additions and 0 deletions

View File

@ -0,0 +1,153 @@
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Highcharts Example</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<style type="text/css">
${demo.css}
</style>
<script src="test_data_cross_section.json"></script>
<script src="http://code.highcharts.com/stock/highstock.js"></script>
<script src="http://code.highcharts.com/highcharts.js"></script>
<script src="http://code.highcharts.com/highcharts-more.js"></script>
<script src="http://code.highcharts.com/modules/solid-gauge.js"></script>
</head>
<body>
<button id="button" class"autocompare">Update</button>
<div id="timegraph1" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
<div id="timegraph2" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
<table id="jobtable">
<tr><td>Test Name</td><td>Passed</td><td>Failed</td><td>%Failed</td><td>Run Time</td></tr>
</table>
<script type="text/javascript">
var data = JSON.parse(project_data);
$(function () {
$('#timegraph1').highcharts('StockChart',{
title: {
text: 'tempest.api.orchestration.stacks.test_neutron_resources.NeutronResourcesTestJSON.test_created_router_interface Failures',
x: -20 //center
},
xAxis: {
categories: []
},
yAxis: {
title: {
text: 'Counts'
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}]
},
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'middle',
borderWidth: 0
},
});
$('#timegraph2').highcharts('StockChart',{
title: {
text: 'run time',
x: -20 //center
},
xAxis: {
categories: []
},
yAxis: {
title: {
text: 'Time'
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}]
},
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'middle',
borderWidth: 0
},
});
});
$('#button').click(function() {
var range = new Array();
var pass = new Array();
var fail = new Array();
var run_time = new Array();
var jobs = new Array();
for (var ele=0; ele < data.timedata.length; ele++) {
var obj = data.timedata[ele];
range[ele]=obj.datetime;
var n_fail = 0;
var n_pass = 0;
var mean_run_time = 0;
for (var loop=0; loop < obj.job_data.length; loop++) {
var job = obj.job_data[loop].job_name;
n_fail += obj.job_data[loop].fail;
n_pass += obj.job_data[loop].pass;
mean_run_time += obj.job_data[loop].mean_run_time;
var found = 0;
for (loop2=0; loop2 < jobs.length; loop2++) {
if (jobs[loop2].job_name === job) {
found = 1;
jobs[loop2].fail += obj.job_data[loop].fail;
jobs[loop2].pass += obj.job_data[loop].pass;
jobs[loop2].run_time += obj.job_data[loop].mean_run_time;
}
}
if (found === 0) {
jobs.push({job_name: job, pass: obj.job_data[loop].pass, fail: obj.job_data[loop].fail, run_time: obj.job_data[loop].mean_run_time});
}
}
pass[ele] = n_pass;
fail[ele] = n_fail;
run_time[ele] = mean_run_time
}
function prettify(s1) {
if (s1.length <= 50)
return s1;
for (var i=50; i>0; i--)
if (s1[i] === '.')
return s1.substring(0,i+1)+"<br>"+prettify(s1.substring(i+1));
}
var tgraph = $('#timegraph1').highcharts();
while(tgraph.series.length > 0)
tgraph.series[0].remove(true);
tgraph.addSeries({name: "Pass", data: pass});
tgraph.addSeries({name: "Failed", data: fail});
tgraph.xAxis[0].setCategories(range);
tgraph.redraw();
var tgraph2 = $('#timegraph2').highcharts();
while(tgraph2.series.length > 0)
tgraph2.series[0].remove(true);
tgraph2.addSeries({name: "Run Time", data: run_time});
tgraph2.xAxis[0].setCategories(range);
tgraph2.redraw();
var ttable=$('#jobtable').find('tbody');
for (var loop=0; loop<jobs.length; loop++) {
pct = ( jobs[loop].fail * 100 ) / (jobs[loop].fail + jobs[loop].pass);
job_name = prettify(jobs[loop].job_name);
ttable.append($('<tr>')
.append($('<td>'+job_name+'</td>'))
.append($('<td>'+jobs[loop].pass+'</td>'))
.append($('<td>'+jobs[loop].fail+'</td>'))
.append($('<td>'+pct+'</td></tr>'))
.append($('<td>'+jobs[loop].run_time+'</td>'))
);
}
});
</script>
</body>
</html>

View File

@ -0,0 +1,134 @@
project_data = '{ "timedata": ['+
' { "datetime": "02 Jun 2015",'+
' "job_data": ['+
' { "job_name": "gate-devstack-dsvm-cells",'+
' "pass": 20,'+
' "fail": 40,'+
' "mean_run_time": 10.5 },'+
' { "job_name": "gate-nove-tox-functional",'+
' "pass": 15,'+
' "fail": 45,'+
' "mean_run_time": 5.3 },'+
' { "job_name": "gate-grenade-dsvm-partial",'+
' "pass": 40,'+
' "fail": 20,'+
' "mean_run_time": 50 },'+
' { "job_name": "gate-grenade-dsvm-ironic-sideways",'+
' "pass": 45,'+
' "fail": 15,'+
' "mean_run_time": 70 } ]'+
' },'+
' { "datetime": "03 Jun 2015",'+
' "job_data": ['+
' { "job_name": "gate-devstack-dsvm-cells",'+
' "pass": 30,'+
' "fail": 30,'+
' "mean_run_time": 12 },'+
' { "job_name": "gate-nove-tox-functional",'+
' "pass": 20,'+
' "fail": 40,'+
' "mean_run_time": 6 },'+
' { "job_name": "gate-grenade-dsvm-partial",'+
' "pass": 45,'+
' "fail": 15,'+
' "mean_run_time": 35 },'+
' { "job_name": "gate-grenade-dsvm-ironic-sideways",'+
' "pass": 45,'+
' "fail": 15,'+
' "mean_run_time": 70 } ]'+
' },'+
' { "datetime": "04 Jun 2015",'+
' "job_data": ['+
' { "job_name": "gate-devstack-dsvm-cells",'+
' "pass": 35,'+
' "fail": 25,'+
' "mean_run_time": 15 },'+
' { "job_name": "gate-nove-tox-functional",'+
' "pass": 45,'+
' "fail": 15,'+
' "mean_run_time": 8.2 },'+
' { "job_name": "gate-grenade-dsvm-partial",'+
' "pass": 50,'+
' "fail": 10,'+
' "mean_run_time": 45 },'+
' { "job_name": "gate-grenade-dsvm-ironic-sideways",'+
' "pass": 55,'+
' "fail": 5,'+
' "mean_run_time": 60 } ]'+
' },'+
' { "datetime": "05 Jun 2015",'+
' "job_data": ['+
' { "job_name": "gate-devstack-dsvm-cells",'+
' "pass": 60,'+
' "fail": 0,'+
' "mean_run_time": 20.5 },'+
' { "job_name": "gate-nove-tox-functional",'+
' "pass": 60,'+
' "fail": 0,'+
' "mean_run_time": 8 },'+
' { "job_name": "gate-grenade-dsvm-partial",'+
' "pass": 60,'+
' "fail": 0,'+
' "mean_run_time": 40 },'+
' { "job_name": "gate-grenade-dsvm-ironic-sideways",'+
' "pass": 60,'+
' "fail": 0,'+
' "mean_run_time": 45 } ]'+
' },'+
' { "datetime": "06 Jun 2015",'+
' "job_data": ['+
' { "job_name": "gate-devstack-dsvm-cells",'+
' "pass": 60,'+
' "fail": 0,'+
' "mean_run_time": 20.5 },'+
' { "job_name": "gate-nove-tox-functional",'+
' "pass": 60,'+
' "fail": 0,'+
' "mean_run_time": 8 },'+
' { "job_name": "gate-grenade-dsvm-partial",'+
' "pass": 60,'+
' "fail": 0,'+
' "mean_run_time": 40 },'+
' { "job_name": "gate-grenade-dsvm-ironic-sideways",'+
' "pass": 60,'+
' "fail": 0,'+
' "mean_run_time": 45 } ]'+
' },'+
' { "datetime": "07 Jun 2015",'+
' "job_data": ['+
' { "job_name": "gate-devstack-dsvm-cells",'+
' "pass": 60,'+
' "fail": 0,'+
' "mean_run_time": 20.5 },'+
' { "job_name": "gate-nove-tox-functional",'+
' "pass": 60,'+
' "fail": 0,'+
' "mean_run_time": 8 },'+
' { "job_name": "gate-grenade-dsvm-partial",'+
' "pass": 60,'+
' "fail": 0,'+
' "mean_run_time": 40 },'+
' { "job_name": "gate-grenade-dsvm-ironic-sideways",'+
' "pass": 60,'+
' "fail": 0,'+
' "mean_run_time": 45 } ]'+
' },'+
' { "datetime": "08 Jun 2015",'+
' "job_data": ['+
' { "job_name": "gate-devstack-dsvm-cells",'+
' "pass": 60,'+
' "fail": 0,'+
' "mean_run_time": 20.5 },'+
' { "job_name": "gate-nove-tox-functional",'+
' "pass": 60,'+
' "fail": 0,'+
' "mean_run_time": 8 },'+
' { "job_name": "gate-grenade-dsvm-partial",'+
' "pass": 60,'+
' "fail": 0,'+
' "mean_run_time": 40 },'+
' { "job_name": "gate-grenade-dsvm-ironic-sideways",'+
' "pass": 60,'+
' "fail": 0,'+
' "mean_run_time": 45 } ]'+
' } ] }';