summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/api_samples/os-coverage/coverage-stop-post-resp.json3
-rw-r--r--doc/api_samples/os-coverage/coverage-stop-post-resp.xml2
-rw-r--r--nova/api/openstack/compute/contrib/coverage_ext.py18
-rw-r--r--nova/tests/api/openstack/compute/contrib/test_coverage_ext.py4
-rw-r--r--nova/tests/integrated/api_samples/os-coverage/coverage-stop-post-resp.json.tpl3
-rw-r--r--nova/tests/integrated/api_samples/os-coverage/coverage-stop-post-resp.xml.tpl2
-rw-r--r--nova/tests/integrated/test_api_samples.py7
7 files changed, 32 insertions, 7 deletions
diff --git a/doc/api_samples/os-coverage/coverage-stop-post-resp.json b/doc/api_samples/os-coverage/coverage-stop-post-resp.json
new file mode 100644
index 000000000..d3caf3a5a
--- /dev/null
+++ b/doc/api_samples/os-coverage/coverage-stop-post-resp.json
@@ -0,0 +1,3 @@
+{
+ "path": "/tmp/tmpua9HvB/nova-coverage_rs2CaS"
+} \ No newline at end of file
diff --git a/doc/api_samples/os-coverage/coverage-stop-post-resp.xml b/doc/api_samples/os-coverage/coverage-stop-post-resp.xml
new file mode 100644
index 000000000..f0c921847
--- /dev/null
+++ b/doc/api_samples/os-coverage/coverage-stop-post-resp.xml
@@ -0,0 +1,2 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<path>/tmp/tmpCLve38/nova-coverage_GJ4BZ_</path> \ No newline at end of file
diff --git a/nova/api/openstack/compute/contrib/coverage_ext.py b/nova/api/openstack/compute/contrib/coverage_ext.py
index 98a067fc8..bf47fe451 100644
--- a/nova/api/openstack/compute/contrib/coverage_ext.py
+++ b/nova/api/openstack/compute/contrib/coverage_ext.py
@@ -71,7 +71,6 @@ class CoverageController(object):
"network": self.network_api.get_backdoor_port,
}
ports = []
- temp = {}
#TODO(mtreinish): Figure out how to bind the backdoor socket to 0.0.0.0
# Currently this will only work if the host is resolved as loopback on
# the same host as api-server
@@ -110,7 +109,7 @@ class CoverageController(object):
def _start_coverage(self, req, body):
'''Begin recording coverage information.'''
- LOG.debug("Coverage begin")
+ LOG.debug(_("Coverage begin"))
body = body['start']
self.combine = False
if 'combine' in body.keys():
@@ -144,8 +143,9 @@ class CoverageController(object):
for service in self.services:
self._stop_coverage_telnet(service['telnet'])
if self._check_coverage():
- msg = ("Coverage not running")
+ msg = _("Coverage not running")
raise exc.HTTPNotFound(explanation=msg)
+ return {'path': self.data_path}
def _report_coverage_telnet(self, tn, path, xml=False):
if xml:
@@ -165,26 +165,34 @@ class CoverageController(object):
def _report_coverage(self, req, body):
self._stop_coverage(req)
xml = False
+ html = False
path = None
body = body['report']
if 'file' in body.keys():
path = body['file']
if path != os.path.basename(path):
- msg = ("Invalid path")
+ msg = _("Invalid path")
raise exc.HTTPBadRequest(explanation=msg)
path = os.path.join(self.data_path, path)
else:
- msg = ("No path given for report file")
+ msg = _("No path given for report file")
raise exc.HTTPBadRequest(explanation=msg)
if 'xml' in body.keys():
xml = body['xml']
+ elif 'html' in body.keys():
+ if not self.combine:
+ msg = _("You can't use html reports without combining")
+ raise exc.HTTPBadRequest(explanation=msg)
+ html = body['html']
if self.combine:
self.coverInst.combine()
if xml:
self.coverInst.xml_report(outfile=path)
+ elif html:
+ self.coverInst.html_report(directory=path)
else:
output = open(path, 'w')
self.coverInst.report(file=output)
diff --git a/nova/tests/api/openstack/compute/contrib/test_coverage_ext.py b/nova/tests/api/openstack/compute/contrib/test_coverage_ext.py
index e7d00e68a..bbbf2160a 100644
--- a/nova/tests/api/openstack/compute/contrib/test_coverage_ext.py
+++ b/nova/tests/api/openstack/compute/contrib/test_coverage_ext.py
@@ -90,6 +90,8 @@ class CoverageExtensionTest(test.TestCase):
res = req.get_response(fakes.wsgi_app(
fake_auth_context=self.admin_context))
self.assertEqual(res.status_int, 200)
+ resp_dict = jsonutils.loads(res.body)
+ self.assertTrue('path' in resp_dict)
def test_report_coverage_action_file(self):
self.stubs.Set(coverage_ext.CoverageController,
@@ -180,7 +182,7 @@ class CoverageExtensionTest(test.TestCase):
self.assertEqual(res.status_int, 404)
def test_report_coverage_action_nostart(self):
- body = {'stop': {}}
+ body = {'report': {}}
req = webob.Request.blank('/v2/fake/os-coverage/action')
req.method = "POST"
req.body = jsonutils.dumps(body)
diff --git a/nova/tests/integrated/api_samples/os-coverage/coverage-stop-post-resp.json.tpl b/nova/tests/integrated/api_samples/os-coverage/coverage-stop-post-resp.json.tpl
new file mode 100644
index 000000000..6cdd1f37d
--- /dev/null
+++ b/nova/tests/integrated/api_samples/os-coverage/coverage-stop-post-resp.json.tpl
@@ -0,0 +1,3 @@
+{
+ "path" : "%(path)s"
+}
diff --git a/nova/tests/integrated/api_samples/os-coverage/coverage-stop-post-resp.xml.tpl b/nova/tests/integrated/api_samples/os-coverage/coverage-stop-post-resp.xml.tpl
new file mode 100644
index 000000000..65f5e16bc
--- /dev/null
+++ b/nova/tests/integrated/api_samples/os-coverage/coverage-stop-post-resp.xml.tpl
@@ -0,0 +1,2 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<path>%(path)s</path>
diff --git a/nova/tests/integrated/test_api_samples.py b/nova/tests/integrated/test_api_samples.py
index ab6770a23..ece8f321e 100644
--- a/nova/tests/integrated/test_api_samples.py
+++ b/nova/tests/integrated/test_api_samples.py
@@ -753,10 +753,15 @@ class CoverageExtJsonTests(ApiSampleTestBase):
def test_stop_coverage(self):
"""Stop coverage data collection"""
- subs = {}
+ subs = {
+ 'path': '/.*',
+ }
response = self._do_post('os-coverage/action',
'coverage-stop-post-req', subs)
self.assertEqual(response.status, 200)
+ subs.update(self._get_regexes())
+ return self._verify_response('coverage-stop-post-resp',
+ subs, response)
def test_report_coverage(self):
"""Generate a coverage report"""