Update plot plugin
- update plot plugin to use convert xml - update test cases Change-Id: I37fff234992dd419222459e808d022bfcf1a8215 Signed-off-by: Thanh Ha <thanh.ha@linuxfoundation.org>
This commit is contained in:
parent
cc200dade0
commit
0d7e6b113c
@ -27,7 +27,6 @@ the build is complete.
|
||||
|
||||
import logging
|
||||
import pkg_resources
|
||||
import random
|
||||
import xml.etree.ElementTree as XML
|
||||
|
||||
import six
|
||||
@ -4199,12 +4198,14 @@ def plot(registry, xml_parent, data):
|
||||
Xpath which selects the values that should be plotted.
|
||||
|
||||
|
||||
Example:
|
||||
Minimal Example:
|
||||
|
||||
.. literalinclude:: /../../tests/publishers/fixtures/plot004.yaml
|
||||
.. literalinclude:: /../../tests/publishers/fixtures/plot-minimal.yaml
|
||||
:language: yaml
|
||||
|
||||
.. literalinclude:: /../../tests/publishers/fixtures/plot005.yaml
|
||||
Full Example:
|
||||
|
||||
.. literalinclude:: /../../tests/publishers/fixtures/plot-full.yaml
|
||||
:language: yaml
|
||||
"""
|
||||
top = XML.SubElement(xml_parent, 'hudson.plugins.plot.PlotPublisher')
|
||||
@ -4219,14 +4220,43 @@ def plot(registry, xml_parent, data):
|
||||
'exclude-by-string': 'EXCLUDE_BY_STRING',
|
||||
'include-by-column': 'INCLUDE_BY_COLUMN',
|
||||
'exclude-by-column': 'EXCLUDE_BY_COLUMN'}
|
||||
|
||||
style_list = ['area', 'bar', 'bar3d', 'line', 'line3d', 'stackedArea',
|
||||
'stackedbar', 'stackedbar3d', 'waterfall']
|
||||
|
||||
plot_mappings = [
|
||||
('title', 'title', ''),
|
||||
('yaxis', 'yaxis', ''),
|
||||
('width', 'width', '750'),
|
||||
('height', 'height', '450'),
|
||||
('csv-file-name', 'csvFileName', ''),
|
||||
('group', 'group', None),
|
||||
('use-description', 'useDescr', False),
|
||||
('exclude-zero-yaxis', 'exclZero', False),
|
||||
('logarithmic-yaxis', 'logarithmic', False),
|
||||
('keep-records', 'keepRecords', False),
|
||||
('num-builds', 'numBuilds', ''),
|
||||
('style', 'style', 'line', style_list),
|
||||
]
|
||||
|
||||
plot_csv_mappings = [
|
||||
('inclusion-flag', 'inclusionFlag', 'off', inclusion_dict),
|
||||
('exclude', 'exclusionValues', ''),
|
||||
('url', 'url', ''),
|
||||
('display-table', 'displayTableFlag', False)
|
||||
]
|
||||
|
||||
plot_xml_mappings = [
|
||||
('url', 'url', ''),
|
||||
('xpath', 'xpathString', ''),
|
||||
('xpath-type', 'nodeTypeString', 'node', xpath_dict)
|
||||
]
|
||||
|
||||
for plot in data:
|
||||
plugin = XML.SubElement(plots, 'hudson.plugins.plot.Plot')
|
||||
XML.SubElement(plugin, 'title').text = plot.get('title', '')
|
||||
XML.SubElement(plugin, 'yaxis').text = plot['yaxis']
|
||||
XML.SubElement(plugin, 'width').text = str(plot.get('width', '750'))
|
||||
XML.SubElement(plugin, 'height').text = str(plot.get('height', '450'))
|
||||
XML.SubElement(plugin, 'csvFileName').text = \
|
||||
plot.get('csv-file-name', '%s.csv' % random.randrange(2 << 32))
|
||||
helpers.convert_mapping_to_xml(
|
||||
plugin, plot, plot_mappings, fail_required=True)
|
||||
|
||||
topseries = XML.SubElement(plugin, 'series')
|
||||
series = plot['series']
|
||||
for serie in series:
|
||||
@ -4240,56 +4270,19 @@ def plot(registry, xml_parent, data):
|
||||
if format_data == 'properties':
|
||||
XML.SubElement(subserie, 'label').text = serie.get('label', '')
|
||||
if format_data == 'csv':
|
||||
inclusion_flag = serie.get('inclusion-flag', 'off')
|
||||
if inclusion_flag not in inclusion_dict:
|
||||
raise JenkinsJobsException("Inclusion flag result entered "
|
||||
"is not valid, must be one of: "
|
||||
"%s"
|
||||
% ", ".join(inclusion_dict))
|
||||
XML.SubElement(subserie, 'inclusionFlag').text = \
|
||||
inclusion_dict.get(inclusion_flag)
|
||||
XML.SubElement(subserie, 'exclusionValues').text = \
|
||||
serie.get('exclude', '')
|
||||
helpers.convert_mapping_to_xml(
|
||||
subserie, serie, plot_csv_mappings, fail_required=True)
|
||||
if serie.get('exclude', ''):
|
||||
exclude_strings = serie.get('exclude', '').split(',')
|
||||
exclusionset = XML.SubElement(subserie, 'strExclusionSet')
|
||||
for exclude_string in exclude_strings:
|
||||
XML.SubElement(exclusionset, 'string').text = \
|
||||
exclude_string
|
||||
XML.SubElement(subserie, 'url').text = serie.get('url', '')
|
||||
XML.SubElement(subserie, 'displayTableFlag').text = \
|
||||
str(serie.get('display-table', False)).lower()
|
||||
if format_data == 'xml':
|
||||
XML.SubElement(subserie, 'url').text = serie.get('url', '')
|
||||
XML.SubElement(subserie, 'xpathString').text = \
|
||||
serie.get('xpath')
|
||||
xpathtype = serie.get('xpath-type', 'node')
|
||||
if xpathtype not in xpath_dict:
|
||||
raise JenkinsJobsException("XPath result entered is not "
|
||||
"valid, must be one of: %s" %
|
||||
", ".join(xpath_dict))
|
||||
XML.SubElement(subserie, 'nodeTypeString').text = \
|
||||
xpath_dict.get(xpathtype)
|
||||
helpers.convert_mapping_to_xml(
|
||||
subserie, serie, plot_xml_mappings, fail_required=True)
|
||||
XML.SubElement(subserie, 'fileType').text = serie.get('format')
|
||||
|
||||
mappings = [
|
||||
('group', 'group', None),
|
||||
('use-description', 'useDescr', False),
|
||||
('exclude-zero-yaxis', 'exclZero', False),
|
||||
('logarithmic-yaxis', 'logarithmic', False),
|
||||
('keep-records', 'keepRecords', False),
|
||||
('num-builds', 'numBuilds', '')]
|
||||
helpers.convert_mapping_to_xml(
|
||||
plugin, plot, mappings, fail_required=True)
|
||||
|
||||
style_list = ['area', 'bar', 'bar3d', 'line', 'line3d', 'stackedArea',
|
||||
'stackedbar', 'stackedbar3d', 'waterfall']
|
||||
style = plot.get('style', 'line')
|
||||
if style not in style_list:
|
||||
raise JenkinsJobsException("style entered is not valid, must be "
|
||||
"one of: %s" % ", ".join(style_list))
|
||||
XML.SubElement(plugin, 'style').text = style
|
||||
|
||||
|
||||
def git(registry, xml_parent, data):
|
||||
"""yaml: git
|
||||
|
66
tests/publishers/fixtures/plot-full.xml
Normal file
66
tests/publishers/fixtures/plot-full.xml
Normal file
@ -0,0 +1,66 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<publishers>
|
||||
<hudson.plugins.plot.PlotPublisher>
|
||||
<plots>
|
||||
<hudson.plugins.plot.Plot>
|
||||
<title>MyPlot</title>
|
||||
<yaxis>Y</yaxis>
|
||||
<width>900</width>
|
||||
<height>1000</height>
|
||||
<csvFileName>myplot.csv</csvFileName>
|
||||
<group>PlotGroup</group>
|
||||
<useDescr>true</useDescr>
|
||||
<exclZero>true</exclZero>
|
||||
<logarithmic>true</logarithmic>
|
||||
<keepRecords>true</keepRecords>
|
||||
<numBuilds>1</numBuilds>
|
||||
<style>line</style>
|
||||
<series>
|
||||
<hudson.plugins.plot.PropertiesSeries>
|
||||
<file>graph-me-second.properties</file>
|
||||
<label>MyLabel</label>
|
||||
<fileType>properties</fileType>
|
||||
</hudson.plugins.plot.PropertiesSeries>
|
||||
<hudson.plugins.plot.CSVSeries>
|
||||
<file>graph-me-first.csv</file>
|
||||
<inclusionFlag>INCLUDE_BY_STRING</inclusionFlag>
|
||||
<exclusionValues>Column 1,Column 2,Column 3</exclusionValues>
|
||||
<url>http://srv1</url>
|
||||
<displayTableFlag>true</displayTableFlag>
|
||||
<strExclusionSet>
|
||||
<string>Column 1</string>
|
||||
<string>Column 2</string>
|
||||
<string>Column 3</string>
|
||||
</strExclusionSet>
|
||||
<fileType>csv</fileType>
|
||||
</hudson.plugins.plot.CSVSeries>
|
||||
</series>
|
||||
</hudson.plugins.plot.Plot>
|
||||
<hudson.plugins.plot.Plot>
|
||||
<title>MyPlot2</title>
|
||||
<yaxis>Y</yaxis>
|
||||
<width>750</width>
|
||||
<height>450</height>
|
||||
<csvFileName>myplot2.csv</csvFileName>
|
||||
<group>PlotGroup</group>
|
||||
<useDescr>false</useDescr>
|
||||
<exclZero>false</exclZero>
|
||||
<logarithmic>false</logarithmic>
|
||||
<keepRecords>false</keepRecords>
|
||||
<numBuilds/>
|
||||
<style>bar</style>
|
||||
<series>
|
||||
<hudson.plugins.plot.XMLSeries>
|
||||
<file>graph-me-third.xml</file>
|
||||
<url>http://srv2</url>
|
||||
<xpathString>/*</xpathString>
|
||||
<nodeTypeString>STRING</nodeTypeString>
|
||||
<fileType>xml</fileType>
|
||||
</hudson.plugins.plot.XMLSeries>
|
||||
</series>
|
||||
</hudson.plugins.plot.Plot>
|
||||
</plots>
|
||||
</hudson.plugins.plot.PlotPublisher>
|
||||
</publishers>
|
||||
</project>
|
36
tests/publishers/fixtures/plot-full.yaml
Normal file
36
tests/publishers/fixtures/plot-full.yaml
Normal file
@ -0,0 +1,36 @@
|
||||
publishers:
|
||||
- plot:
|
||||
- title: MyPlot
|
||||
yaxis: Y
|
||||
width: 900
|
||||
height: 1000
|
||||
csv-file-name: myplot.csv
|
||||
group: PlotGroup
|
||||
num-builds: '1'
|
||||
style: line
|
||||
exclude-zero-yaxis: true
|
||||
logarithmic-yaxis: true
|
||||
use-description: true
|
||||
keep-records: true
|
||||
series:
|
||||
- file: graph-me-second.properties
|
||||
label: MyLabel
|
||||
format: properties
|
||||
- file: graph-me-first.csv
|
||||
url: 'http://srv1'
|
||||
inclusion-flag: 'include-by-string'
|
||||
exclude: 'Column 1,Column 2,Column 3'
|
||||
display-table: true
|
||||
format: csv
|
||||
- title: MyPlot2
|
||||
yaxis: Y
|
||||
csv-file-name: myplot2.csv
|
||||
group: PlotGroup
|
||||
style: bar
|
||||
use-description: false
|
||||
series:
|
||||
- file: graph-me-third.xml
|
||||
url: 'http://srv2'
|
||||
format: xml
|
||||
xpath-type: 'string'
|
||||
xpath: '/*'
|
33
tests/publishers/fixtures/plot-minimal.xml
Normal file
33
tests/publishers/fixtures/plot-minimal.xml
Normal file
@ -0,0 +1,33 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<publishers>
|
||||
<hudson.plugins.plot.PlotPublisher>
|
||||
<plots>
|
||||
<hudson.plugins.plot.Plot>
|
||||
<title/>
|
||||
<yaxis/>
|
||||
<width>750</width>
|
||||
<height>450</height>
|
||||
<csvFileName/>
|
||||
<group>bench</group>
|
||||
<useDescr>false</useDescr>
|
||||
<exclZero>false</exclZero>
|
||||
<logarithmic>false</logarithmic>
|
||||
<keepRecords>false</keepRecords>
|
||||
<numBuilds/>
|
||||
<style>line</style>
|
||||
<series>
|
||||
<hudson.plugins.plot.CSVSeries>
|
||||
<file>data.csv</file>
|
||||
<inclusionFlag>OFF</inclusionFlag>
|
||||
<exclusionValues/>
|
||||
<url/>
|
||||
<displayTableFlag>false</displayTableFlag>
|
||||
<fileType>csv</fileType>
|
||||
</hudson.plugins.plot.CSVSeries>
|
||||
</series>
|
||||
</hudson.plugins.plot.Plot>
|
||||
</plots>
|
||||
</hudson.plugins.plot.PlotPublisher>
|
||||
</publishers>
|
||||
</project>
|
7
tests/publishers/fixtures/plot-minimal.yaml
Normal file
7
tests/publishers/fixtures/plot-minimal.yaml
Normal file
@ -0,0 +1,7 @@
|
||||
publishers:
|
||||
- plot:
|
||||
- yaxis: ''
|
||||
group: 'bench'
|
||||
series:
|
||||
- file: 'data.csv'
|
||||
format: 'csv'
|
@ -9,6 +9,13 @@
|
||||
<width>750</width>
|
||||
<height>450</height>
|
||||
<csvFileName>persisted.csv</csvFileName>
|
||||
<group>bench</group>
|
||||
<useDescr>false</useDescr>
|
||||
<exclZero>false</exclZero>
|
||||
<logarithmic>false</logarithmic>
|
||||
<keepRecords>true</keepRecords>
|
||||
<numBuilds/>
|
||||
<style>line</style>
|
||||
<series>
|
||||
<hudson.plugins.plot.CSVSeries>
|
||||
<file>data.csv</file>
|
||||
@ -19,13 +26,6 @@
|
||||
<fileType>csv</fileType>
|
||||
</hudson.plugins.plot.CSVSeries>
|
||||
</series>
|
||||
<group>bench</group>
|
||||
<useDescr>false</useDescr>
|
||||
<exclZero>false</exclZero>
|
||||
<logarithmic>false</logarithmic>
|
||||
<keepRecords>true</keepRecords>
|
||||
<numBuilds/>
|
||||
<style>line</style>
|
||||
</hudson.plugins.plot.Plot>
|
||||
</plots>
|
||||
</hudson.plugins.plot.PlotPublisher>
|
||||
|
@ -9,13 +9,6 @@
|
||||
<width>750</width>
|
||||
<height>450</height>
|
||||
<csvFileName>persisted.csv</csvFileName>
|
||||
<series>
|
||||
<hudson.plugins.plot.PropertiesSeries>
|
||||
<file>data.properties</file>
|
||||
<label/>
|
||||
<fileType>properties</fileType>
|
||||
</hudson.plugins.plot.PropertiesSeries>
|
||||
</series>
|
||||
<group>bench</group>
|
||||
<useDescr>false</useDescr>
|
||||
<exclZero>false</exclZero>
|
||||
@ -23,6 +16,13 @@
|
||||
<keepRecords>false</keepRecords>
|
||||
<numBuilds/>
|
||||
<style>line</style>
|
||||
<series>
|
||||
<hudson.plugins.plot.PropertiesSeries>
|
||||
<file>data.properties</file>
|
||||
<label/>
|
||||
<fileType>properties</fileType>
|
||||
</hudson.plugins.plot.PropertiesSeries>
|
||||
</series>
|
||||
</hudson.plugins.plot.Plot>
|
||||
</plots>
|
||||
</hudson.plugins.plot.PlotPublisher>
|
||||
|
@ -9,6 +9,13 @@
|
||||
<width>750</width>
|
||||
<height>450</height>
|
||||
<csvFileName>persisted.csv</csvFileName>
|
||||
<group>bench</group>
|
||||
<useDescr>false</useDescr>
|
||||
<exclZero>false</exclZero>
|
||||
<logarithmic>false</logarithmic>
|
||||
<keepRecords>false</keepRecords>
|
||||
<numBuilds/>
|
||||
<style>line</style>
|
||||
<series>
|
||||
<hudson.plugins.plot.XMLSeries>
|
||||
<file>data.xml</file>
|
||||
@ -18,13 +25,6 @@
|
||||
<fileType>xml</fileType>
|
||||
</hudson.plugins.plot.XMLSeries>
|
||||
</series>
|
||||
<group>bench</group>
|
||||
<useDescr>false</useDescr>
|
||||
<exclZero>false</exclZero>
|
||||
<logarithmic>false</logarithmic>
|
||||
<keepRecords>false</keepRecords>
|
||||
<numBuilds/>
|
||||
<style>line</style>
|
||||
</hudson.plugins.plot.Plot>
|
||||
</plots>
|
||||
</hudson.plugins.plot.PlotPublisher>
|
||||
|
@ -9,6 +9,13 @@
|
||||
<width>750</width>
|
||||
<height>450</height>
|
||||
<csvFileName>myplot.csv</csvFileName>
|
||||
<group>PlotGroup</group>
|
||||
<useDescr>false</useDescr>
|
||||
<exclZero>true</exclZero>
|
||||
<logarithmic>true</logarithmic>
|
||||
<keepRecords>false</keepRecords>
|
||||
<numBuilds/>
|
||||
<style>line</style>
|
||||
<series>
|
||||
<hudson.plugins.plot.PropertiesSeries>
|
||||
<file>graph-me-second.properties</file>
|
||||
@ -24,13 +31,6 @@
|
||||
<fileType>csv</fileType>
|
||||
</hudson.plugins.plot.CSVSeries>
|
||||
</series>
|
||||
<group>PlotGroup</group>
|
||||
<useDescr>false</useDescr>
|
||||
<exclZero>true</exclZero>
|
||||
<logarithmic>true</logarithmic>
|
||||
<keepRecords>false</keepRecords>
|
||||
<numBuilds/>
|
||||
<style>line</style>
|
||||
</hudson.plugins.plot.Plot>
|
||||
<hudson.plugins.plot.Plot>
|
||||
<title>MyPlot2</title>
|
||||
@ -38,6 +38,13 @@
|
||||
<width>750</width>
|
||||
<height>450</height>
|
||||
<csvFileName>myplot2.csv</csvFileName>
|
||||
<group>PlotGroup</group>
|
||||
<useDescr>false</useDescr>
|
||||
<exclZero>false</exclZero>
|
||||
<logarithmic>false</logarithmic>
|
||||
<keepRecords>false</keepRecords>
|
||||
<numBuilds/>
|
||||
<style>line</style>
|
||||
<series>
|
||||
<hudson.plugins.plot.XMLSeries>
|
||||
<file>graph-me-third.xml</file>
|
||||
@ -47,13 +54,6 @@
|
||||
<fileType>xml</fileType>
|
||||
</hudson.plugins.plot.XMLSeries>
|
||||
</series>
|
||||
<group>PlotGroup</group>
|
||||
<useDescr>false</useDescr>
|
||||
<exclZero>false</exclZero>
|
||||
<logarithmic>false</logarithmic>
|
||||
<keepRecords>false</keepRecords>
|
||||
<numBuilds/>
|
||||
<style>line</style>
|
||||
</hudson.plugins.plot.Plot>
|
||||
</plots>
|
||||
</hudson.plugins.plot.PlotPublisher>
|
||||
|
@ -9,21 +9,6 @@
|
||||
<width>750</width>
|
||||
<height>450</height>
|
||||
<csvFileName>persisted.csv</csvFileName>
|
||||
<series>
|
||||
<hudson.plugins.plot.CSVSeries>
|
||||
<file>data.csv</file>
|
||||
<inclusionFlag>INCLUDE_BY_STRING</inclusionFlag>
|
||||
<exclusionValues>Column 1,Column 2,Column 3</exclusionValues>
|
||||
<strExclusionSet>
|
||||
<string>Column 1</string>
|
||||
<string>Column 2</string>
|
||||
<string>Column 3</string>
|
||||
</strExclusionSet>
|
||||
<url/>
|
||||
<displayTableFlag>false</displayTableFlag>
|
||||
<fileType>csv</fileType>
|
||||
</hudson.plugins.plot.CSVSeries>
|
||||
</series>
|
||||
<group>bench</group>
|
||||
<useDescr>false</useDescr>
|
||||
<exclZero>false</exclZero>
|
||||
@ -31,6 +16,21 @@
|
||||
<keepRecords>false</keepRecords>
|
||||
<numBuilds/>
|
||||
<style>line</style>
|
||||
<series>
|
||||
<hudson.plugins.plot.CSVSeries>
|
||||
<file>data.csv</file>
|
||||
<inclusionFlag>INCLUDE_BY_STRING</inclusionFlag>
|
||||
<exclusionValues>Column 1,Column 2,Column 3</exclusionValues>
|
||||
<url/>
|
||||
<displayTableFlag>false</displayTableFlag>
|
||||
<strExclusionSet>
|
||||
<string>Column 1</string>
|
||||
<string>Column 2</string>
|
||||
<string>Column 3</string>
|
||||
</strExclusionSet>
|
||||
<fileType>csv</fileType>
|
||||
</hudson.plugins.plot.CSVSeries>
|
||||
</series>
|
||||
</hudson.plugins.plot.Plot>
|
||||
</plots>
|
||||
</hudson.plugins.plot.PlotPublisher>
|
||||
|
@ -9,6 +9,13 @@
|
||||
<width>900</width>
|
||||
<height>1000</height>
|
||||
<csvFileName>persisted.csv</csvFileName>
|
||||
<group>bench</group>
|
||||
<useDescr>false</useDescr>
|
||||
<exclZero>false</exclZero>
|
||||
<logarithmic>false</logarithmic>
|
||||
<keepRecords>true</keepRecords>
|
||||
<numBuilds/>
|
||||
<style>line</style>
|
||||
<series>
|
||||
<hudson.plugins.plot.CSVSeries>
|
||||
<file>data.csv</file>
|
||||
@ -19,13 +26,6 @@
|
||||
<fileType>csv</fileType>
|
||||
</hudson.plugins.plot.CSVSeries>
|
||||
</series>
|
||||
<group>bench</group>
|
||||
<useDescr>false</useDescr>
|
||||
<exclZero>false</exclZero>
|
||||
<logarithmic>false</logarithmic>
|
||||
<keepRecords>true</keepRecords>
|
||||
<numBuilds/>
|
||||
<style>line</style>
|
||||
</hudson.plugins.plot.Plot>
|
||||
</plots>
|
||||
</hudson.plugins.plot.PlotPublisher>
|
||||
|
Loading…
Reference in New Issue
Block a user