summaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
Diffstat (limited to 'utils')
-rwxr-xr-xutils/jenkins-jnlp-connect.sh1
-rw-r--r--utils/test/dashboard/dashboard/elastic2kibana/main.py211
-rw-r--r--utils/test/dashboard/dashboard/elastic2kibana/templates/dashboard.json61
-rw-r--r--utils/test/dashboard/dashboard/elastic2kibana/templates/visualization.json32
-rw-r--r--utils/test/reporting/css/default.css (renamed from utils/test/reporting/functest/default.css)33
-rwxr-xr-xutils/test/reporting/functest/reporting-status.py7
-rw-r--r--utils/test/reporting/functest/reportingConf.py1
-rw-r--r--utils/test/reporting/functest/template/index-status-tmpl.html96
-rw-r--r--utils/test/reporting/js/gauge.js165
-rw-r--r--utils/test/reporting/js/trend.js75
10 files changed, 505 insertions, 177 deletions
diff --git a/utils/jenkins-jnlp-connect.sh b/utils/jenkins-jnlp-connect.sh
index 4b710cab2..9ef4298ef 100755
--- a/utils/jenkins-jnlp-connect.sh
+++ b/utils/jenkins-jnlp-connect.sh
@@ -151,6 +151,7 @@ fi
usage() {
cat << EOF
+**this file must be copied to the jenkins home directory to work**
jenkins-jnlp-connect.sh configures monit to keep slave connection up
Checks for new versions of slave.jar
run as root to create pid directory and create monit config.
diff --git a/utils/test/dashboard/dashboard/elastic2kibana/main.py b/utils/test/dashboard/dashboard/elastic2kibana/main.py
index 95f758ea8..ae5cbe8fa 100644
--- a/utils/test/dashboard/dashboard/elastic2kibana/main.py
+++ b/utils/test/dashboard/dashboard/elastic2kibana/main.py
@@ -27,10 +27,22 @@ es_creds = CONF.elastic_creds
_installers = {'fuel', 'apex', 'compass', 'joid'}
+env = Environment(loader=PackageLoader('elastic2kibana', 'templates'))
+env.filters['jsonify'] = json.dumps
-class KibanaDashboard(dict):
+
+def dumps(self, items):
+ for key in items:
+ self.visualization[key] = json.dumps(self.visualization[key])
+
+
+def dumps_2depth(self, key1, key2):
+ self.visualization[key1][key2] = json.dumps(self.visualization[key1][key2])
+
+
+class Dashboard(dict):
def __init__(self, project_name, case_name, family, installer, pod, scenarios, visualization):
- super(KibanaDashboard, self).__init__()
+ super(Dashboard, self).__init__()
self.project_name = project_name
self.case_name = case_name
self.family = family
@@ -46,14 +58,14 @@ class KibanaDashboard(dict):
def _create_visualizations(self):
for scenario in self.scenarios:
- self._kibana_visualizations.append(KibanaVisualization(self.project_name,
- self.case_name,
- self.installer,
- self.pod,
- scenario,
- self.visualization))
+ self._kibana_visualizations.append(Visualization(self.project_name,
+ self.case_name,
+ self.installer,
+ self.pod,
+ scenario,
+ self.visualization))
- self._visualization_title = self._kibana_visualizations[0].vis_title
+ self._visualization_title = self._kibana_visualizations[0].vis_state_title
def _publish_visualizations(self):
for visualization in self._kibana_visualizations:
@@ -62,113 +74,39 @@ class KibanaDashboard(dict):
# logger.error("_publish_visualization: %s" % visualization)
elastic_access.publish_docs(url, es_creds, visualization)
- def _construct_panels(self):
- size_x = 6
- size_y = 3
- max_columns = 7
- column = 1
- row = 1
- panel_index = 1
- panels_json = []
- for visualization in self._kibana_visualizations:
- panels_json.append({
- "id": visualization.id,
- "type": 'visualization',
- "panelIndex": panel_index,
- "size_x": size_x,
- "size_y": size_y,
- "col": column,
- "row": row
- })
- panel_index += 1
- column += size_x
- if column > max_columns:
- column = 1
- row += size_y
- return json.dumps(panels_json, separators=(',', ':'))
-
def _create(self):
- self['title'] = '{} {} {} {} {}'.format(self.project_name,
- self.case_name,
- self.installer,
- self._visualization_title,
- self.pod)
- self.id = self['title'].replace(' ', '-').replace('/', '-')
-
- self['hits'] = 0
- self['description'] = "Kibana dashboard for project_name '{}', case_name '{}', installer '{}', data '{}' and" \
- " pod '{}'".format(self.project_name,
- self.case_name,
- self.installer,
- self._visualization_title,
- self.pod)
- self['panelsJSON'] = self._construct_panels()
- self['optionsJSON'] = json.dumps({
- "darkTheme": False
- },
- separators=(',', ':'))
- self['uiStateJSON'] = "{}"
- self['scenario'] = 1
- self['timeRestore'] = False
- self['kibanaSavedObjectMeta'] = {
- 'searchSourceJSON': json.dumps({
- "filter": [
- {
- "query": {
- "query_string": {
- "query": "*",
- "analyze_wildcard": True
- }
- }
- }
- ]
+ db = {
+ "query": {
+ "project_name": self.project_name,
+ "case_name": self.case_name,
+ "installer": self.installer,
+ "metric": self._visualization_title,
+ "pod": self.pod
},
- separators=(',', ':'))
+ "test_family": self.family,
+ "ids": [visualization.id for visualization in self._kibana_visualizations]
}
+ template = env.get_template('dashboard.json')
+ self.dashboard = json.loads(template.render(db=db))
+ dumps(self.dashboard, ['description', 'uiStateJSON', 'panelsJSON','optionsJSON'])
+ dumps_2depth(self.dashboard, 'kibanaSavedObjectMeta', 'searchSourceJSON')
+ self.id = self.dashboard['title'].replace(' ', '-').replace('/', '-')
- label = self.case_name
- if 'label' in self.visualization:
- label += " %s" % self.visualization.get('label')
- label += " %s" % self.visualization.get('name')
- self['metadata'] = {
- "label": label,
- "test_family": self.family
- }
def _publish(self):
url = urlparse.urljoin(base_elastic_url, '/.kibana/dashboard/{}'.format(self.id))
logger.debug("publishing dashboard '{}'".format(url))
- elastic_access.publish_docs(url, es_creds, self)
+ #logger.error("dashboard: %s" % json.dumps(self.dashboard))
+ elastic_access.publish_docs(url, es_creds, self.dashboard)
def publish(self):
self._publish_visualizations()
self._publish()
-class KibanaSearchSourceJSON(dict):
- """
- "filter": [
- {"match": {"installer": {"query": installer, "type": "phrase"}}},
- {"match": {"project_name": {"query": project_name, "type": "phrase"}}},
- {"match": {"case_name": {"query": case_name, "type": "phrase"}}}
- ]
- """
-
- def __init__(self, project_name, case_name, installer, pod, scenario):
- super(KibanaSearchSourceJSON, self).__init__()
- self["filter"] = [
- {"match": {"project_name": {"query": project_name, "type": "phrase"}}},
- {"match": {"case_name": {"query": case_name, "type": "phrase"}}},
- {"match": {"installer": {"query": installer, "type": "phrase"}}},
- {"match": {"scenario": {"query": scenario, "type": "phrase"}}}
- ]
- if pod != 'all':
- self["filter"].append({"match": {"pod_name": {"query": pod, "type": "phrase"}}})
-
-
-class VisualizationBuilder(object):
+class VisStateBuilder(object):
def __init__(self, visualization):
- super(VisualizationBuilder, self).__init__()
+ super(VisStateBuilder, self).__init__()
self.visualization = visualization
def build(self):
@@ -184,14 +122,12 @@ class VisualizationBuilder(object):
})
index += 1
- env = Environment(loader=PackageLoader('elastic2kibana', 'templates'))
- env.filters['jsonify'] = json.dumps
template = env.get_template('{}.json'.format(name))
vis = template.render(aggs=aggs)
return json.loads(vis)
-class KibanaVisualization(dict):
+class Visualization(object):
def __init__(self, project_name, case_name, installer, pod, scenario, visualization):
"""
We need two things
@@ -207,32 +143,28 @@ class KibanaVisualization(dict):
:return:
"""
- super(KibanaVisualization, self).__init__()
- vis = VisualizationBuilder(visualization).build()
- self.vis_title = vis['title']
- self['title'] = '{} {} {} {} {} {}'.format(project_name,
- case_name,
- self.vis_title,
- installer,
- pod,
- scenario)
- self.id = self['title'].replace(' ', '-').replace('/', '-')
- self['visState'] = json.dumps(vis, separators=(',', ':'))
- self['uiStateJSON'] = "{}"
- self['description'] = "Kibana visualization for project_name '{}', case_name '{}', metric '{}', installer '{}'," \
- " pod '{}' and scenario '{}'".format(project_name,
- case_name,
- self.vis_title,
- installer,
- pod,
- scenario)
- self['scenario'] = 1
- self['kibanaSavedObjectMeta'] = {"searchSourceJSON": json.dumps(KibanaSearchSourceJSON(project_name,
- case_name,
- installer,
- pod,
- scenario),
- separators=(',', ':'))}
+ super(Visualization, self).__init__()
+ visState = VisStateBuilder(visualization).build()
+ self.vis_state_title = visState['title']
+
+ vis = {
+ "visState": json.dumps(visState),
+ "filters": {
+ "project_name": project_name,
+ "case_name": case_name,
+ "installer": installer,
+ "metric": self.vis_state_title,
+ "pod_name": pod,
+ "scenario": scenario
+ }
+ }
+
+ template = env.get_template('visualization.json')
+
+ self.visualization = json.loads(template.render(vis=vis))
+ dumps(self.visualization, ['visState', 'description', 'uiStateJSON'])
+ dumps_2depth(self.visualization, 'kibanaSavedObjectMeta', 'searchSourceJSON')
+ self.id = self.visualization['title'].replace(' ', '-').replace('/', '-')
def _get_pods_and_scenarios(project_name, case_name, installer):
@@ -252,7 +184,8 @@ def _get_pods_and_scenarios(project_name, case_name, installer):
})
elastic_data = elastic_access.get_docs(urlparse.urljoin(base_elastic_url, '/test_results/mongo2elastic'),
- es_creds, query_json)
+ es_creds,
+ query_json)
pods_and_scenarios = {}
@@ -290,20 +223,20 @@ def construct_dashboards():
pods_and_scenarios = _get_pods_and_scenarios(project, case_name, installer)
for visualization in visualizations:
for pod, scenarios in pods_and_scenarios.iteritems():
- kibana_dashboards.append(KibanaDashboard(project,
- case_name,
- family,
- installer,
- pod,
- scenarios,
- visualization))
+ kibana_dashboards.append(Dashboard(project,
+ case_name,
+ family,
+ installer,
+ pod,
+ scenarios,
+ visualization))
return kibana_dashboards
def generate_js_inputs(js_file_path, kibana_url, dashboards):
js_dict = {}
for dashboard in dashboards:
- dashboard_meta = dashboard['metadata']
+ dashboard_meta = dashboard.dashboard['metadata']
test_family = dashboard_meta['test_family']
test_label = dashboard_meta['label']
diff --git a/utils/test/dashboard/dashboard/elastic2kibana/templates/dashboard.json b/utils/test/dashboard/dashboard/elastic2kibana/templates/dashboard.json
new file mode 100644
index 000000000..cc8099593
--- /dev/null
+++ b/utils/test/dashboard/dashboard/elastic2kibana/templates/dashboard.json
@@ -0,0 +1,61 @@
+{% set db = db|default({}) -%}
+
+
+{% macro calc_col(index) -%}
+ {% if index is divisibleby 2 %}
+ 7
+ {% else %}
+ 1
+ {% endif %}
+{%- endmacro %}
+
+{% macro calc_row(index) -%}
+{% set num = (index - 1)//2 %}
+ {{1 + num * 3}}
+{%- endmacro %}
+
+{
+ "description": "Kibana dashboard for {{db.query}}",
+ "hits": 0,
+ "kibanaSavedObjectMeta": {
+ "searchSourceJSON": {
+ "filter": [
+ {
+ "query": {
+ "query_string": {
+ "analyze_wildcard": true,
+ "query": "*"
+ }
+ }
+ }
+ ]
+ }
+ },
+ "metadata": {
+ "label": "{{db.query.case_name}} {{db.query.metric}}",
+ "test_family": "{{db.test_family}}"
+ },
+ "optionsJSON": {
+ "darkTheme": false
+ },
+ "panelsJSON": [
+ {% for id in db.ids %}
+ {
+ "col": {{calc_col(loop.index)}},
+ "id": "{{id}}",
+ "panelIndex": {{loop.index}},
+ "row": {{calc_row(loop.index)}},
+ "size_x": 6,
+ "size_y": 3,
+ "type": "visualization"
+ }
+ {% if not loop.last %}
+ ,
+ {% endif %}
+ {% endfor %}
+ ],
+ "scenario": 1,
+ "timeRestore": false,
+ "title": "{{db.query.project_name}} {{db.query.case_name}} {{db.query.installer}} {{db.query.metric}} {{db.query.pod}}",
+ "uiStateJSON": {}
+}
diff --git a/utils/test/dashboard/dashboard/elastic2kibana/templates/visualization.json b/utils/test/dashboard/dashboard/elastic2kibana/templates/visualization.json
new file mode 100644
index 000000000..d51d4174e
--- /dev/null
+++ b/utils/test/dashboard/dashboard/elastic2kibana/templates/visualization.json
@@ -0,0 +1,32 @@
+{% set vis = vis|default({}) -%}
+
+
+{
+ "description": "Kibana visualization for {{ vis.filters }}",
+ "kibanaSavedObjectMeta": {
+ "searchSourceJSON": {
+ "filter": [
+ {% for key, value in vis.filters.iteritems() if key != "metric" %}
+ {% if not (key == "pod_name" and value == "all") %}
+ {
+ "match": {
+ "{{ key }}": {
+ "query": "{{ value }}",
+ "type": "phrase"
+ }
+ }
+ }
+ {% if not loop.last %}
+ ,
+ {% endif %}
+ {% endif %}
+ {% endfor %}
+ ]
+ }
+ },
+ "scenario": 1,
+ "title": "{{vis.filters.project_name}} {{vis.filters.case_name}} {{vis.filters.installer}} {{vis.filters.metric}} {{vis.filters.pod_name}} {{vis.filters.scenario}}",
+ "uiStateJSON": {},
+ "visState": {{ vis.visState }}
+}
+
diff --git a/utils/test/reporting/functest/default.css b/utils/test/reporting/css/default.css
index 897c3b12b..a9fa69db7 100644
--- a/utils/test/reporting/functest/default.css
+++ b/utils/test/reporting/css/default.css
@@ -75,3 +75,36 @@ h2 {
font-weight: bold;
color:rgb(128, 128, 128)
}
+
+#power-gauge g.arc {
+ fill: steelblue;
+}
+
+#power-gauge g.pointer {
+ fill: #e85116;
+ stroke: #b64011;
+}
+
+#power-gauge g.label text {
+ text-anchor: middle;
+ font-size: 14px;
+ font-weight: bold;
+ fill: #666;
+}
+
+#power-gauge path {
+
+}
+
+.axis path,
+.axis line {
+ fill: none;
+ stroke: #000;
+ shape-rendering: crispEdges;
+}
+
+.dot {
+ fill: steelblue;
+ stroke: steelblue;
+ stroke-width: 1.5px;
+}
diff --git a/utils/test/reporting/functest/reporting-status.py b/utils/test/reporting/functest/reporting-status.py
index 90699bd61..9df699629 100755
--- a/utils/test/reporting/functest/reporting-status.py
+++ b/utils/test/reporting/functest/reporting-status.py
@@ -184,8 +184,13 @@ for version in conf.versions:
scenario_criteria = conf.MAX_SCENARIO_CRITERIA
s_score = str(scenario_score) + "/" + str(scenario_criteria)
- s_score_percent = float(
+ s_score_percent = 0.0
+ try:
+ s_score_percent = float(
scenario_score) / float(scenario_criteria) * 100
+ except:
+ logger.error("cannot calculate the score percent")
+
s_status = "KO"
if scenario_score < scenario_criteria:
logger.info(">>>> scenario not OK, score = %s/%s" %
diff --git a/utils/test/reporting/functest/reportingConf.py b/utils/test/reporting/functest/reportingConf.py
index e1c4b61a8..1c9a2ac9f 100644
--- a/utils/test/reporting/functest/reportingConf.py
+++ b/utils/test/reporting/functest/reportingConf.py
@@ -13,7 +13,6 @@ installers = ["apex", "compass", "fuel", "joid"]
# list of test cases declared in testcases.yaml but that must not be
# taken into account for the scoring
blacklist = ["ovno", "security_scan"]
-# versions = ["brahmaputra", "master"]
versions = ["master", "colorado"]
PERIOD = 10
MAX_SCENARIO_CRITERIA = 50
diff --git a/utils/test/reporting/functest/template/index-status-tmpl.html b/utils/test/reporting/functest/template/index-status-tmpl.html
index 67c23491a..2beb9128e 100644
--- a/utils/test/reporting/functest/template/index-status-tmpl.html
+++ b/utils/test/reporting/functest/template/index-status-tmpl.html
@@ -3,17 +3,65 @@
<meta charset="utf-8">
<!-- Bootstrap core CSS -->
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet">
- <link href="default.css" rel="stylesheet">
+ <link href="../../../css/default.css" rel="stylesheet">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
- <script type="text/javascript">
- $(document).ready(function (){
- $(".btn-more").click(function() {
- $(this).hide();
- $(this).parent().find(".panel-default").show();
+ <script type="text/javascript" src="http://d3js.org/d3.v2.min.js"></script>
+ <script type="text/javascript" src="../../../js/gauge.js"></script>
+ <script type="text/javascript" src="../../../js/trend.js"></script>
+ <script>
+ function onDocumentReady() {
+ // Gauge management
+ {% for scenario in scenario_stats.iteritems() -%}
+ var gaugeScenario{{loop.index}} = gauge('#gaugeScenario{{loop.index}}');
+ {%- endfor %}
+
+ // assign success rate to the gauge
+ function updateReadings() {
+ {% for scenario,iteration in scenario_stats.iteritems() -%}
+ gaugeScenario{{loop.index}}.update({{scenario_results[scenario].getScorePercent()}});
+ {%- endfor %}
+ }
+ updateReadings();
+ }
+
+ // trend line management
+ d3.csv("./scenario_history.txt", function(data) {
+ // ***************************************
+ // Create the trend line
+ {% for scenario,iteration in scenario_stats.iteritems() -%}
+ // for scenario {{scenario}}
+ // Filter results
+ var trend{{loop.index}} = data.filter(function(row) {
+ return row["scenario"]=="{{scenario}}" && row["installer"]=="{{installer}}";
+ })
+ // Parse the date
+ trend{{loop.index}}.forEach(function(d) {
+ d.date = parseDate(d.date);
+ d.score = +d.score
});
- })
- </script>
+ // Draw the trend line
+ var mytrend = trend("#trend_svg{{loop.index}}",trend{{loop.index}})
+ // ****************************************
+ {%- endfor %}
+ });
+ if ( !window.isLoaded ) {
+ window.addEventListener("load", function() {
+ onDocumentReady();
+ }, false);
+ } else {
+ onDocumentReady();
+ }
+</script>
+<script type="text/javascript">
+$(document).ready(function (){
+ $(".btn-more").click(function() {
+ $(this).hide();
+ $(this).parent().find(".panel-default").show();
+ });
+})
+</script>
+
</head>
<body>
<div class="container">
@@ -40,41 +88,17 @@
<div class="panel-heading"><h4><b>List of last scenarios ({{version}}) run over the last {{period}} days </b></h4></div>
<table class="table">
<tr>
- <th width="60%">Scenario</th>
+ <th width="40%">Scenario</th>
<th width="20%">Status</th>
+ <th width="20%">Trend</th>
<th width="10%">Score</th>
<th width="10%">Iteration</th>
</tr>
{% for scenario,iteration in scenario_stats.iteritems() -%}
<tr class="tr-ok">
<td><a href={{scenario_results[scenario].getUrlLastRun()}}>{{scenario}}</a></td>
- <td>{%if scenario_results[scenario].getScorePercent() < 8.3 -%}
- <img src="../../img/gauge_0.png">
- {%elif scenario_results[scenario].getScorePercent() < 16.7 -%}
- <img src="../../img/gauge_8.3.png">
- {%elif scenario_results[scenario].getScorePercent() < 25 -%}
- <img src="../../img/gauge_16.7.png">
- {%elif scenario_results[scenario].getScorePercent() < 33.3 -%}
- <img src="../../img/gauge_25.png">
- {%elif scenario_results[scenario].getScorePercent() < 41.7 -%}
- <img src="../../img/gauge_33.3.png">
- {%elif scenario_results[scenario].getScorePercent() < 50 -%}
- <img src="../../img/gauge_41.7.png">
- {%elif scenario_results[scenario].getScorePercent() < 58.3 -%}
- <img src="../../img/gauge_50.png">
- {%elif scenario_results[scenario].getScorePercent() < 66.7 -%}
- <img src="../../img/gauge_58.3.png">
- {%elif scenario_results[scenario].getScorePercent() < 75 -%}
- <img src="../../img/gauge_66.7.png">
- {%elif scenario_results[scenario].getScorePercent() < 83.3 -%}
- <img src="../../img/gauge_75.png">
- {%elif scenario_results[scenario].getScorePercent() < 91.7 -%}
- <img src="../../img/gauge_83.3.png">
- {%elif scenario_results[scenario].getScorePercent() < 100 -%}
- <img src="../../img/gauge_91.7.png">
- {%- else -%}
- <img src="../../img/gauge_100.png">
- {%- endif %}</td>
+ <td><div id="gaugeScenario{{loop.index}}"></div></td>
+ <td><div id="trend_svg{{loop.index}}"></div></td>
<td>{{scenario_results[scenario].getScore()}}</td>
<td>{{iteration}}</td>
</tr>
diff --git a/utils/test/reporting/js/gauge.js b/utils/test/reporting/js/gauge.js
new file mode 100644
index 000000000..4cad16c61
--- /dev/null
+++ b/utils/test/reporting/js/gauge.js
@@ -0,0 +1,165 @@
+// ******************************************
+// Gauge for reporting
+// Each scenario has a score
+// We use a gauge to indicate the trust level
+// ******************************************
+var gauge = function(container) {
+ var that = {};
+ var config = {
+ size : 150,
+ clipWidth : 250,
+ clipHeight : 100,
+ ringInset : 20,
+ ringWidth : 40,
+
+ pointerWidth : 7,
+ pointerTailLength : 5,
+ pointerHeadLengthPercent : 0.8,
+
+ minValue : 0,
+ maxValue : 100,
+
+ minAngle : -90,
+ maxAngle : 90,
+
+ transitionMs : 4000,
+
+ majorTicks : 7,
+ labelFormat : d3.format(',g'),
+ labelInset : 10,
+
+ arcColorFn : d3.interpolateHsl(d3.rgb('#ff0000'), d3.rgb('#00ff00'))
+ };
+
+
+var range = undefined;
+var r = undefined;
+var pointerHeadLength = undefined;
+var value = 0;
+
+var svg = undefined;
+var arc = undefined;
+var scale = undefined;
+var ticks = undefined;
+var tickData = undefined;
+var pointer = undefined;
+
+var donut = d3.layout.pie();
+
+function deg2rad(deg) {
+ return deg * Math.PI / 180;
+}
+
+function newAngle(d) {
+ var ratio = scale(d);
+ var newAngle = config.minAngle + (ratio * range);
+ return newAngle;
+}
+
+function configure() {
+ range = config.maxAngle - config.minAngle;
+ r = config.size / 2;
+ pointerHeadLength = Math.round(r * config.pointerHeadLengthPercent);
+
+ // a linear scale that maps domain values to a percent from 0..1
+ scale = d3.scale.linear()
+ .range([0,1])
+ .domain([config.minValue, config.maxValue]);
+
+ ticks = scale.ticks(config.majorTicks);
+ tickData = d3.range(config.majorTicks).map(function() {return 1/config.majorTicks;});
+
+ arc = d3.svg.arc()
+ .innerRadius(r - config.ringWidth - config.ringInset)
+ .outerRadius(r - config.ringInset)
+ .startAngle(function(d, i) {
+ var ratio = d * i;
+ return deg2rad(config.minAngle + (ratio * range));
+ })
+ .endAngle(function(d, i) {
+ var ratio = d * (i+1);
+ return deg2rad(config.minAngle + (ratio * range));
+ });
+}
+that.configure = configure;
+
+function centerTranslation() {
+ return 'translate('+r +','+ r +')';
+}
+
+function isRendered() {
+ return (svg !== undefined);
+}
+that.isRendered = isRendered;
+
+function render(newValue) {
+ svg = d3.select(container)
+ .append('svg:svg')
+ .attr('class', 'gauge')
+ .attr('width', config.clipWidth)
+ .attr('height', config.clipHeight);
+
+ var centerTx = centerTranslation();
+
+ var arcs = svg.append('g')
+ .attr('class', 'arc')
+ .attr('transform', centerTx);
+
+ arcs.selectAll('path')
+ .data(tickData)
+ .enter().append('path')
+ .attr('fill', function(d, i) {
+ return config.arcColorFn(d * i);
+ })
+ .attr('d', arc);
+
+ var lg = svg.append('g')
+ .attr('class', 'label')
+ .attr('transform', centerTx);
+ lg.selectAll('text')
+ .data(ticks)
+ .enter().append('text')
+ .attr('transform', function(d) {
+ var ratio = scale(d);
+ var newAngle = config.minAngle + (ratio * range);
+ return 'rotate(' +newAngle +') translate(0,' +(config.labelInset - r) +')';
+ })
+ .text(config.labelFormat);
+
+ var lineData = [ [config.pointerWidth / 2, 0],
+ [0, -pointerHeadLength],
+ [-(config.pointerWidth / 2), 0],
+ [0, config.pointerTailLength],
+ [config.pointerWidth / 2, 0] ];
+ var pointerLine = d3.svg.line().interpolate('monotone');
+ var pg = svg.append('g').data([lineData])
+ .attr('class', 'pointer')
+ .attr('transform', centerTx);
+
+ pointer = pg.append('path')
+ .attr('d', pointerLine/*function(d) { return pointerLine(d) +'Z';}*/ )
+ .attr('transform', 'rotate(' +config.minAngle +')');
+
+ update(newValue === undefined ? 0 : newValue);
+}
+that.render = render;
+
+function update(newValue, newConfiguration) {
+ if ( newConfiguration !== undefined) {
+ configure(newConfiguration);
+ }
+ var ratio = scale(newValue);
+ var newAngle = config.minAngle + (ratio * range);
+ pointer.transition()
+ .duration(config.transitionMs)
+ .ease('elastic')
+ .attr('transform', 'rotate(' +newAngle +')');
+}
+that.update = update;
+
+configure();
+
+render();
+
+return that;
+};
diff --git a/utils/test/reporting/js/trend.js b/utils/test/reporting/js/trend.js
new file mode 100644
index 000000000..f24213382
--- /dev/null
+++ b/utils/test/reporting/js/trend.js
@@ -0,0 +1,75 @@
+// ******************************************
+// Trend line for reporting
+// based on scenario_history.txt
+// where data looks like
+// date,scenario,installer,detail,score
+// 2016-09-22 13:12,os-nosdn-fdio-noha,apex,4/12,33.0
+// 2016-09-22 13:13,os-odl_l2-fdio-noha,apex,12/15,80.0
+// 2016-09-22 13:13,os-odl_l2-sfc-noha,apex,18/24,75.0
+// .....
+// ******************************************
+// Set the dimensions of the canvas / graph
+var trend_margin = {top: 20, right: 30, bottom: 50, left: 40},
+ trend_width = 300 - trend_margin.left - trend_margin.right,
+ trend_height = 130 - trend_margin.top - trend_margin.bottom;
+
+// Parse the date / time
+var parseDate = d3.time.format("%Y-%m-%d %H:%M").parse;
+
+// Set the ranges
+var trend_x = d3.time.scale().range([0, trend_width]);
+var trend_y = d3.scale.linear().range([trend_height, 0]);
+
+// Define the axes
+var trend_xAxis = d3.svg.axis().scale(trend_x)
+ .orient("bottom").ticks(2).tickFormat(d3.time.format("%m-%d"));
+
+var trend_yAxis = d3.svg.axis().scale(trend_y)
+ .orient("left").ticks(2);
+
+// Define the line
+var valueline = d3.svg.line()
+ .x(function(d) { return trend_x(d.date); })
+ .y(function(d) { return trend_y(d.score); });
+
+var trend = function(container, trend_data) {
+
+ var trend_svg = d3.select(container)
+ .append("svg")
+ .attr("width", trend_width + trend_margin.left + trend_margin.right)
+ .attr("height", trend_height + trend_margin.top + trend_margin.bottom)
+ .append("g")
+ .attr("transform",
+ "translate(" + trend_margin.left + "," + trend_margin.top + ")");
+
+ // Scale the range of the data
+ trend_x.domain(d3.extent(trend_data, function(d) { return d.date; }));
+ trend_y.domain([0, d3.max(trend_data, function(d) { return d.score; })]);
+
+ // Add the X Axis
+ trend_svg.append("g")
+ .attr("class", "x axis")
+ .attr("transform", "translate(0," + trend_height + ")")
+ .call(trend_xAxis);
+
+ // Add the Y Axis
+ trend_svg.append("g")
+ .attr("class", "y axis")
+ .call(trend_yAxis);
+
+ // Add the valueline path.
+ trend_svg.append("path")
+ .attr("class", "line")
+ .attr("d", valueline(trend_data))
+ .attr("stroke", "steelblue")
+ .attr("fill", "none");
+
+ trend_svg.selectAll(".dot")
+ .data(trend_data)
+ .enter().append("circle")
+ .attr("r", 2.5)
+ .attr("cx", function(d) { return trend_x(d.date); })
+ .attr("cy", function(d) { return trend_y(d.score); });
+
+ return trend;
+}