summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMitsuhiko Yamazaki <yamazaki-mitsuhiko@cnt.mxc.nes.nec.co.jp>2013-02-04 14:08:52 +0900
committerMitsuhiko Yamazaki <yamazaki-mitsuhiko@cnt.mxc.nes.nec.co.jp>2013-02-12 10:22:37 +0900
commit0933c64251b24e1558676ef7f9d6ab446e386fea (patch)
tree75a2b5146f73cc1608faba05776c214c68c5a696
parent0db2ff24c6e7e9104fbe1edc867297a40642ffcb (diff)
downloadpython-novaclient-2.11.0.tar.gz
Add format options to 'nova coverage-report'.2.11.0
This adds --html and --xml options to 'nova coverage-report' to enable selection of coverage report format. If specifying none of these, text-formatted report will be created. This also adds --combine option to 'nova coverage-start' to make sure that 'nova coverage-report --html' works fine. Fixes bug 1114766 Change-Id: I9fee26bd5c45cac35f425ac7abbced4e2f3ff4df
-rw-r--r--novaclient/v1_1/shell.py22
-rw-r--r--tests/v1_1/test_shell.py15
2 files changed, 35 insertions, 2 deletions
diff --git a/novaclient/v1_1/shell.py b/novaclient/v1_1/shell.py
index e969d6a3..8dd4dce7 100644
--- a/novaclient/v1_1/shell.py
+++ b/novaclient/v1_1/shell.py
@@ -2442,9 +2442,14 @@ def do_host_action(cs, args):
utils.print_list([result], ['HOST', 'power_action'])
+@utils.arg('--combine',
+ dest='combine',
+ action="store_true",
+ default=False,
+ help='Generate a single report for all services.')
def do_coverage_start(cs, args):
"""Start Nova coverage reporting"""
- cs.coverage.start()
+ cs.coverage.start(combine=args.combine)
print "Coverage collection started"
@@ -2455,9 +2460,22 @@ def do_coverage_stop(cs, args):
@utils.arg('filename', metavar='<filename>', help='report filename')
+@utils.arg('--html',
+ dest='html',
+ action="store_true",
+ default=False,
+ help='Generate HTML reports instead of text ones.')
+@utils.arg('--xml',
+ dest='xml',
+ action="store_true",
+ default=False,
+ help='Generate XML reports instead of text ones.')
def do_coverage_report(cs, args):
"""Generate a coverage report"""
- cov = cs.coverage.report(args.filename)
+ if args.html == True and args.xml == True:
+ raise exceptions.CommandError("--html and --xml must not be "
+ "specified together.")
+ cov = cs.coverage.report(args.filename, xml=args.xml, html=args.html)
print "Report path: %s" % cov[-1]['path']
diff --git a/tests/v1_1/test_shell.py b/tests/v1_1/test_shell.py
index dd449922..db508226 100644
--- a/tests/v1_1/test_shell.py
+++ b/tests/v1_1/test_shell.py
@@ -689,6 +689,11 @@ class ShellTest(utils.TestCase):
self.run_command('coverage-start')
self.assert_called('POST', '/os-coverage/action')
+ def test_coverage_start_with_combine(self):
+ self.run_command('coverage-start --combine')
+ body = {'start': {'combine': True}}
+ self.assert_called('POST', '/os-coverage/action', body)
+
def test_coverage_stop(self):
self.run_command('coverage-stop')
self.assert_called_anytime('POST', '/os-coverage/action')
@@ -697,6 +702,16 @@ class ShellTest(utils.TestCase):
self.run_command('coverage-report report')
self.assert_called_anytime('POST', '/os-coverage/action')
+ def test_coverage_report_with_html(self):
+ self.run_command('coverage-report report --html')
+ body = {'report': {'html': True, 'file': 'report'}}
+ self.assert_called_anytime('POST', '/os-coverage/action', body)
+
+ def test_coverage_report_with_xml(self):
+ self.run_command('coverage-report report --xml')
+ body = {'report': {'xml': True, 'file': 'report'}}
+ self.assert_called_anytime('POST', '/os-coverage/action', body)
+
def test_hypervisor_list(self):
self.run_command('hypervisor-list')
self.assert_called('GET', '/os-hypervisors')