diff options
author | rajesh_4k <4k.rajesh@gmail.com> | 2017-02-27 18:09:00 +0530 |
---|---|---|
committer | Jing Lu <lvjing5@huawei.com> | 2017-03-30 09:46:32 +0000 |
commit | 06c0f074a136414d1e9704aa4e30c62e50f2d5ce (patch) | |
tree | ca1db646cb02b0b7c9b29ac8cd1c282f94e29fc3 /yardstick/common | |
parent | aa499064bf305e41a56a2f86d17c1cc29a1d7b0c (diff) |
Yardstick: User interface for Yardstick.
Currently Yardstick doesnt have any UI which gives detail analysis
of the test-results.
This commit generates a HTML page after the execution of a command
"yardstick report generate <task-ID> <TC-name>" which intern
can be executed after the execution of test-case.
Used: Highcharts.js for the graphs.
JIRA: YARDSTICK-280
Change-Id: Ic98cc348719f3922bff178f52e7944a4a931763a
Signed-off-by: Rajesh K <4k.rajesh@gmail.com>
(cherry picked from commit 25b21add71fcf7c2c795bd950b5117d69fac68fb)
Diffstat (limited to 'yardstick/common')
-rw-r--r-- | yardstick/common/constants.py | 2 | ||||
-rw-r--r-- | yardstick/common/html_template.py | 133 |
2 files changed, 135 insertions, 0 deletions
diff --git a/yardstick/common/constants.py b/yardstick/common/constants.py index 54ddf33dc..6550cc8fd 100644 --- a/yardstick/common/constants.py +++ b/yardstick/common/constants.py @@ -65,3 +65,5 @@ ASYNC_TASK_API = BASE_URL + '/yardstick/asynctask' SQLITE = 'sqlite:////tmp/yardstick.db' DEFAULT_OUTPUT_FILE = '/tmp/yardstick.out' + +DEFAULT_HTML_FILE = '/tmp/yardstick.htm' diff --git a/yardstick/common/html_template.py b/yardstick/common/html_template.py new file mode 100644 index 000000000..4b46e77a0 --- /dev/null +++ b/yardstick/common/html_template.py @@ -0,0 +1,133 @@ +############################################################################# +# Copyright (c) 2017 Rajesh Kudaka +# +# Author: Rajesh Kudaka 4k.rajesh@gmail.com +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################# + +template = """ +<html> +<body> +<head> +<meta charset="utf-8"> +<meta name="viewport" content="width=device-width, initial-scale=1"> +<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7\ +/css/bootstrap.min.css"> +<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1\ +/jquery.min.js"></script> +<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7\ +/js/bootstrap.min.js"></script> +<script src="https://code.highcharts.com/highcharts.js"></script> +<script src="jquery.min.js"></script> +<script src="highcharts.js"></script> +</head> +<style> + +table{ + overflow-y: scroll; + height: 360px; + display: block; + } + + header,h3{ + font-family:Frutiger; + clear: left; + text-align: center; +} +</style> +<header class="jumbotron text-center"> + <h1>Yardstick User Interface</h1> + <h4>Report of {{task_id}} Generated</h4> +</header> + +<div class="container"> + <div class="row"> + <div class="col-md-4"> + <div class="table-responsive" > + <table class="table table-hover" > </table> + </div> + </div> + <div class="col-md-8" > + <div id="container" ></div> + </div> + </div> +</div> +<script> + var arr, tab, th, tr, td, tn, row, col, thead, tbody; + arr={{table|safe}} + tab = document.getElementsByTagName('table')[0]; + thead=document.createElement('thead'); + tr = document.createElement('tr'); + for(row=0;row<Object.keys(arr).length;row++) + { + th = document.createElement('th'); + tn = document.createTextNode(Object.keys(arr).sort()[row]); + th.appendChild(tn); + tr.appendChild(th); + thead.appendChild(tr); + } + tab.appendChild(thead); + tbody=document.createElement('tbody'); + + for (col = 0; col < arr[Object.keys(arr)[0]].length; col++){ + tr = document.createElement('tr'); + for(row=0;row<Object.keys(arr).length;row++) + { + td = document.createElement('td'); + tn = document.createTextNode(arr[Object.keys(arr).sort()[row]][col]); + td.appendChild(tn); + tr.appendChild(td); + } + tbody.appendChild(tr); + } +tab.appendChild(tbody); + +</script> + +<script language="JavaScript"> + +$(function() { + $('#container').highcharts({ + title: { + text: 'Yardstick test results', + x: -20 //center + }, + subtitle: { + text: 'Report of {{task_id}} Task Generated', + x: -20 + }, + xAxis: { + title: { + text: 'Timestamp' + }, + categories:{{Timestamp|safe}} + }, + yAxis: { + + plotLines: [{ + value: 0, + width: 1, + color: '#808080' + }] + }, + tooltip: { + valueSuffix: '' + }, + legend: { + layout: 'vertical', + align: 'right', + verticalAlign: 'middle', + borderWidth: 0 + }, + series: {{series|safe}} + }); +}); + +</script> + + +</body> +</html>""" |