[Reports] Add an option for embedding JS/CSS libs into report
This change allows running command `report' with `--html-static' option so all required JS/CSS will be embedded to HTML file. Having all required CSS/JS loaded directly from HTML makes report working without access to the Internet. Added third-party libraries files: rally/ui/templates/libs/nv.d3.1.1.15-beta.min.css rally/ui/templates/libs/angular.1.3.3.min.js rally/ui/templates/libs/nv.d3.1.1.15-beta.min.js rally/ui/templates/libs/d3.3.4.13.min.js Notes about licenses compatibility: https://angularjs.org/ https://github.com/angular/angular.js/blob/master/LICENSE The MIT License compatible with Apache License Version 2.0 according to http://www.apache.org/legal/resolved.html http://d3js.org/ https://github.com/mbostock/d3/blob/master/LICENSE BSD 3-clause License compatible with Apache License Version 2.0 according to http://www.apache.org/legal/resolved.html http://nvd3.org/ https://github.com/novus/nvd3/blob/master/LICENSE.md Apache License Version 2.0 Change-Id: I8913ecc585ee17affb1d8a0b29bb475c1e07427f Closes-Bug: #1505533
This commit is contained in:
parent
6d548e633c
commit
081daa9cff
@ -39,7 +39,7 @@ _rally()
|
|||||||
OPTS["task_delete"]="--force --uuid"
|
OPTS["task_delete"]="--force --uuid"
|
||||||
OPTS["task_detailed"]="--uuid --iterations-data"
|
OPTS["task_detailed"]="--uuid --iterations-data"
|
||||||
OPTS["task_list"]="--deployment --all-deployments --status --uuids-only"
|
OPTS["task_list"]="--deployment --all-deployments --status --uuids-only"
|
||||||
OPTS["task_report"]="--tasks --out --open --html --junit"
|
OPTS["task_report"]="--tasks --out --open --html --html-static --junit"
|
||||||
OPTS["task_results"]="--uuid"
|
OPTS["task_results"]="--uuid"
|
||||||
OPTS["task_sla_check"]="--uuid --json"
|
OPTS["task_sla_check"]="--uuid --json"
|
||||||
OPTS["task_start"]="--deployment --task --task-args --task-args-file --tag --no-use --abort-on-sla-failure"
|
OPTS["task_start"]="--deployment --task --task-args --task-args-file --tag --no-use --abort-on-sla-failure"
|
||||||
|
@ -186,14 +186,28 @@ class TaskTestCase(unittest.TestCase):
|
|||||||
self.assertRaises(utils.RallyCliError,
|
self.assertRaises(utils.RallyCliError,
|
||||||
rally, "task status --uuid %s" % FAKE_TASK_UUID)
|
rally, "task status --uuid %s" % FAKE_TASK_UUID)
|
||||||
|
|
||||||
|
def _assert_html_report_libs_are_embedded(self, file_path, expected=True):
|
||||||
|
|
||||||
|
embedded_signatures = ["Copyright (c) 2011-2014 Novus Partners, Inc.",
|
||||||
|
"AngularJS v1.3.3",
|
||||||
|
"Copyright (c) 2010-2015, Michael Bostock"]
|
||||||
|
external_signatures = ["<script type=\"text/javascript\" src=",
|
||||||
|
"<link rel=\"stylesheet\" href="]
|
||||||
|
html = open(file_path).read()
|
||||||
|
result_embedded = all([sig in html for sig in embedded_signatures])
|
||||||
|
result_external = all([sig in html for sig in external_signatures])
|
||||||
|
self.assertEqual(expected, result_embedded)
|
||||||
|
self.assertEqual(not expected, result_external)
|
||||||
|
|
||||||
def test_report_one_uuid(self):
|
def test_report_one_uuid(self):
|
||||||
rally = utils.Rally()
|
rally = utils.Rally()
|
||||||
cfg = self._get_sample_task_config()
|
cfg = self._get_sample_task_config()
|
||||||
config = utils.TaskConfig(cfg)
|
config = utils.TaskConfig(cfg)
|
||||||
rally("task start --task %s" % config.filename)
|
rally("task start --task %s" % config.filename)
|
||||||
rally("task report --out %s" % rally.gen_report_path(extension="html"))
|
rally("task report --out %s" % rally.gen_report_path(extension="html"))
|
||||||
self.assertTrue(os.path.exists(
|
html_report = rally.gen_report_path(extension="html")
|
||||||
rally.gen_report_path(extension="html")))
|
self.assertTrue(os.path.exists(html_report))
|
||||||
|
self._assert_html_report_libs_are_embedded(html_report, False)
|
||||||
self.assertRaises(utils.RallyCliError,
|
self.assertRaises(utils.RallyCliError,
|
||||||
rally, "task report --report %s" % FAKE_TASK_UUID)
|
rally, "task report --report %s" % FAKE_TASK_UUID)
|
||||||
rally("task report --junit --out %s" %
|
rally("task report --junit --out %s" %
|
||||||
@ -213,10 +227,11 @@ class TaskTestCase(unittest.TestCase):
|
|||||||
for line in res.splitlines():
|
for line in res.splitlines():
|
||||||
if "finished" in line:
|
if "finished" in line:
|
||||||
task_uuids.append(line.split(" ")[1][:-1])
|
task_uuids.append(line.split(" ")[1][:-1])
|
||||||
rally("task report --tasks %s --out %s" % (
|
html_report = rally.gen_report_path(extension="html")
|
||||||
" ".join(task_uuids), rally.gen_report_path(extension="html")))
|
rally("task report --tasks %s --out %s" % (" ".join(task_uuids),
|
||||||
self.assertTrue(os.path.exists(
|
html_report))
|
||||||
rally.gen_report_path(extension="html")))
|
self.assertTrue(os.path.exists(html_report))
|
||||||
|
self._assert_html_report_libs_are_embedded(html_report, False)
|
||||||
|
|
||||||
def test_report_bunch_files(self):
|
def test_report_bunch_files(self):
|
||||||
rally = utils.Rally()
|
rally = utils.Rally()
|
||||||
@ -231,10 +246,11 @@ class TaskTestCase(unittest.TestCase):
|
|||||||
os.remove(path)
|
os.remove(path)
|
||||||
rally("task results", report_path=path, raw=True)
|
rally("task results", report_path=path, raw=True)
|
||||||
|
|
||||||
|
html_report = rally.gen_report_path(extension="html")
|
||||||
rally("task report --tasks %s --out %s" % (
|
rally("task report --tasks %s --out %s" % (
|
||||||
" ".join(files), rally.gen_report_path(extension="html")))
|
" ".join(files), html_report))
|
||||||
self.assertTrue(os.path.exists(
|
self.assertTrue(os.path.exists(html_report))
|
||||||
rally.gen_report_path(extension="html")))
|
self._assert_html_report_libs_are_embedded(html_report, False)
|
||||||
|
|
||||||
def test_report_one_uuid_one_file(self):
|
def test_report_one_uuid_one_file(self):
|
||||||
rally = utils.Rally()
|
rally = utils.Rally()
|
||||||
@ -255,13 +271,24 @@ class TaskTestCase(unittest.TestCase):
|
|||||||
else:
|
else:
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
html_report = rally.gen_report_path(extension="html")
|
||||||
rally("task report --tasks"
|
rally("task report --tasks"
|
||||||
" %s %s --out %s" % (task_result_file, task_uuid,
|
" %s %s --out %s" % (task_result_file, task_uuid,
|
||||||
rally.gen_report_path(extension="html")))
|
html_report))
|
||||||
self.assertTrue(os.path.exists(
|
self.assertTrue(os.path.exists(html_report))
|
||||||
rally.gen_report_path(extension="html")))
|
|
||||||
self.assertRaises(utils.RallyCliError,
|
self.assertRaises(utils.RallyCliError,
|
||||||
rally, "task report --report %s" % FAKE_TASK_UUID)
|
rally, "task report --report %s" % FAKE_TASK_UUID)
|
||||||
|
self._assert_html_report_libs_are_embedded(html_report, False)
|
||||||
|
|
||||||
|
def test_report_one_uuid_with_static_libs(self):
|
||||||
|
rally = utils.Rally()
|
||||||
|
cfg = self._get_sample_task_config()
|
||||||
|
config = utils.TaskConfig(cfg)
|
||||||
|
rally("task start --task %s" % config.filename)
|
||||||
|
html_report = rally.gen_report_path(extension="html")
|
||||||
|
rally("task report --out %s --html-static" % html_report)
|
||||||
|
self.assertTrue(os.path.exists(html_report))
|
||||||
|
self._assert_html_report_libs_are_embedded(html_report)
|
||||||
|
|
||||||
def test_delete(self):
|
def test_delete(self):
|
||||||
rally = utils.Rally()
|
rally = utils.Rally()
|
||||||
|
Loading…
Reference in New Issue
Block a user