Add API samples tests for the coverage extension.
Partially implements blueprint nova-api-samples Fixes bug 1089531 Change-Id: I5b287ea210f275a0c316a28d6dc3614d107aff05
This commit is contained in:
		@@ -0,0 +1,5 @@
 | 
				
			|||||||
 | 
					{
 | 
				
			||||||
 | 
					    "report" : {
 | 
				
			||||||
 | 
					        "file" : "report"
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										4
									
								
								doc/api_samples/os-coverage/coverage-report-post-req.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								doc/api_samples/os-coverage/coverage-report-post-req.xml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,4 @@
 | 
				
			|||||||
 | 
					<?xml version="1.0" encoding="UTF-8"?>
 | 
				
			||||||
 | 
					<report>
 | 
				
			||||||
 | 
					    <file>report</file>
 | 
				
			||||||
 | 
					</report>
 | 
				
			||||||
@@ -0,0 +1,3 @@
 | 
				
			|||||||
 | 
					{
 | 
				
			||||||
 | 
					    "path": "/tmp/tmpV0Pno7/nova-coverage_D8L8SB/report"
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,2 @@
 | 
				
			|||||||
 | 
					<?xml version='1.0' encoding='UTF-8'?>
 | 
				
			||||||
 | 
					<path>/tmp/tmpAqRtz5/nova-coverage_Iqja9E/report</path>
 | 
				
			||||||
@@ -0,0 +1,5 @@
 | 
				
			|||||||
 | 
					{
 | 
				
			||||||
 | 
					    "start" :  {
 | 
				
			||||||
 | 
					        "combine": true
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,4 @@
 | 
				
			|||||||
 | 
					<?xml version="1.0" encoding="UTF-8"?>
 | 
				
			||||||
 | 
					<start>
 | 
				
			||||||
 | 
					    <combine>True</combine>
 | 
				
			||||||
 | 
					</start>
 | 
				
			||||||
							
								
								
									
										4
									
								
								doc/api_samples/os-coverage/coverage-start-post-req.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								doc/api_samples/os-coverage/coverage-start-post-req.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,4 @@
 | 
				
			|||||||
 | 
					{
 | 
				
			||||||
 | 
					    "start" :  {
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										2
									
								
								doc/api_samples/os-coverage/coverage-start-post-req.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								doc/api_samples/os-coverage/coverage-start-post-req.xml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,2 @@
 | 
				
			|||||||
 | 
					<?xml version="1.0" encoding="UTF-8"?>
 | 
				
			||||||
 | 
					<start></start>
 | 
				
			||||||
							
								
								
									
										4
									
								
								doc/api_samples/os-coverage/coverage-stop-post-req.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								doc/api_samples/os-coverage/coverage-stop-post-req.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,4 @@
 | 
				
			|||||||
 | 
					{
 | 
				
			||||||
 | 
					    "stop" : {
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										2
									
								
								doc/api_samples/os-coverage/coverage-stop-post-req.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								doc/api_samples/os-coverage/coverage-stop-post-req.xml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,2 @@
 | 
				
			|||||||
 | 
					<?xml version="1.0" encoding="UTF-8"?>
 | 
				
			||||||
 | 
					<stop></stop>
 | 
				
			||||||
@@ -0,0 +1,6 @@
 | 
				
			|||||||
 | 
					{
 | 
				
			||||||
 | 
					    "report": {
 | 
				
			||||||
 | 
					        "xml": true,
 | 
				
			||||||
 | 
					        "file": "report"
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,5 @@
 | 
				
			|||||||
 | 
					<?xml version="1.0" encoding="UTF-8"?>
 | 
				
			||||||
 | 
					<report>
 | 
				
			||||||
 | 
					    <file>report</file>
 | 
				
			||||||
 | 
					    <xml>True</xml>
 | 
				
			||||||
 | 
					</report>
 | 
				
			||||||
@@ -0,0 +1,3 @@
 | 
				
			|||||||
 | 
					{
 | 
				
			||||||
 | 
					    "path": "/tmp/tmp6kdYaa/nova-coverage_TOTUbz/report"
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,2 @@
 | 
				
			|||||||
 | 
					<?xml version='1.0' encoding='UTF-8'?>
 | 
				
			||||||
 | 
					<path>/tmp/tmp4j87bp/nova-coverage_7ViTA7/report</path>
 | 
				
			||||||
@@ -0,0 +1,5 @@
 | 
				
			|||||||
 | 
					{
 | 
				
			||||||
 | 
					    "report" : {
 | 
				
			||||||
 | 
					        "file" : "%(filename)s"
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,4 @@
 | 
				
			|||||||
 | 
					<?xml version="1.0" encoding="UTF-8"?>
 | 
				
			||||||
 | 
					<report>
 | 
				
			||||||
 | 
					    <file>%(filename)s</file>
 | 
				
			||||||
 | 
					</report>
 | 
				
			||||||
@@ -0,0 +1,3 @@
 | 
				
			|||||||
 | 
					{
 | 
				
			||||||
 | 
					    "path" : "%(path)s"
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,2 @@
 | 
				
			|||||||
 | 
					<?xml version="1.0" encoding="UTF-8"?>
 | 
				
			||||||
 | 
					<path>%(path)s</path>
 | 
				
			||||||
@@ -0,0 +1,5 @@
 | 
				
			|||||||
 | 
					{
 | 
				
			||||||
 | 
					    "start" :  {
 | 
				
			||||||
 | 
					        "combine": true
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,4 @@
 | 
				
			|||||||
 | 
					<?xml version="1.0" encoding="UTF-8"?>
 | 
				
			||||||
 | 
					<start>
 | 
				
			||||||
 | 
					    <combine>True</combine>
 | 
				
			||||||
 | 
					</start>
 | 
				
			||||||
@@ -0,0 +1,4 @@
 | 
				
			|||||||
 | 
					{
 | 
				
			||||||
 | 
					    "start" :  {
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,2 @@
 | 
				
			|||||||
 | 
					<?xml version="1.0" encoding="UTF-8"?>
 | 
				
			||||||
 | 
					<start></start>
 | 
				
			||||||
@@ -0,0 +1,4 @@
 | 
				
			|||||||
 | 
					{
 | 
				
			||||||
 | 
					    "stop" : {
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,2 @@
 | 
				
			|||||||
 | 
					<?xml version="1.0" encoding="UTF-8"?>
 | 
				
			||||||
 | 
					<stop></stop>
 | 
				
			||||||
@@ -0,0 +1,6 @@
 | 
				
			|||||||
 | 
					{
 | 
				
			||||||
 | 
					    "report": {
 | 
				
			||||||
 | 
					        "xml": true,
 | 
				
			||||||
 | 
					        "file": "%(filename)s"
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,5 @@
 | 
				
			|||||||
 | 
					<?xml version="1.0" encoding="UTF-8"?>
 | 
				
			||||||
 | 
					<report>
 | 
				
			||||||
 | 
					    <file>%(filename)s</file>
 | 
				
			||||||
 | 
					    <xml>True</xml>
 | 
				
			||||||
 | 
					</report>
 | 
				
			||||||
@@ -0,0 +1,3 @@
 | 
				
			|||||||
 | 
					{
 | 
				
			||||||
 | 
					    "path" : "%(path)s"
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,2 @@
 | 
				
			|||||||
 | 
					<?xml version='1.0' encoding='UTF-8'?>
 | 
				
			||||||
 | 
					<path>%(path)s</path>
 | 
				
			||||||
@@ -21,8 +21,10 @@ import re
 | 
				
			|||||||
import urllib
 | 
					import urllib
 | 
				
			||||||
import uuid as uuid_lib
 | 
					import uuid as uuid_lib
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					from coverage import coverage
 | 
				
			||||||
from lxml import etree
 | 
					from lxml import etree
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					from nova.api.openstack.compute.contrib import coverage_ext
 | 
				
			||||||
# Import extensions to pull in osapi_compute_extension CONF option used below.
 | 
					# Import extensions to pull in osapi_compute_extension CONF option used below.
 | 
				
			||||||
from nova.api.openstack.compute import extensions
 | 
					from nova.api.openstack.compute import extensions
 | 
				
			||||||
from nova.cloudpipe.pipelib import CloudPipe
 | 
					from nova.cloudpipe.pipelib import CloudPipe
 | 
				
			||||||
@@ -353,7 +355,6 @@ class ApiSamplesTrap(ApiSampleTestBase):
 | 
				
			|||||||
        do_not_approve_additions.append('NMN')
 | 
					        do_not_approve_additions.append('NMN')
 | 
				
			||||||
        do_not_approve_additions.append('OS-FLV-DISABLED')
 | 
					        do_not_approve_additions.append('OS-FLV-DISABLED')
 | 
				
			||||||
        do_not_approve_additions.append('os-config-drive')
 | 
					        do_not_approve_additions.append('os-config-drive')
 | 
				
			||||||
        do_not_approve_additions.append('os-coverage')
 | 
					 | 
				
			||||||
        do_not_approve_additions.append('os-create-server-ext')
 | 
					        do_not_approve_additions.append('os-create-server-ext')
 | 
				
			||||||
        do_not_approve_additions.append('os-fixed-ips')
 | 
					        do_not_approve_additions.append('os-fixed-ips')
 | 
				
			||||||
        do_not_approve_additions.append('os-flavor-access')
 | 
					        do_not_approve_additions.append('os-flavor-access')
 | 
				
			||||||
@@ -719,6 +720,74 @@ class LimitsSampleXmlTest(LimitsSampleJsonTest):
 | 
				
			|||||||
    ctype = 'xml'
 | 
					    ctype = 'xml'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class CoverageExtJsonTests(ApiSampleTestBase):
 | 
				
			||||||
 | 
					    extension_name = ("nova.api.openstack.compute.contrib.coverage_ext."
 | 
				
			||||||
 | 
					                      "Coverage_ext")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def setUp(self):
 | 
				
			||||||
 | 
					        super(CoverageExtJsonTests, self).setUp()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        def _fake_check_coverage(self):
 | 
				
			||||||
 | 
					            return False
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        def _fake_xml_report(self, outfile=None):
 | 
				
			||||||
 | 
					            return
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        self.stubs.Set(coverage_ext.CoverageController, '_check_coverage',
 | 
				
			||||||
 | 
					                       _fake_check_coverage)
 | 
				
			||||||
 | 
					        self.stubs.Set(coverage, 'xml_report', _fake_xml_report)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def test_start_coverage(self):
 | 
				
			||||||
 | 
					        """Start coverage data collection"""
 | 
				
			||||||
 | 
					        subs = {}
 | 
				
			||||||
 | 
					        response = self._do_post('os-coverage/action',
 | 
				
			||||||
 | 
					                                 'coverage-start-post-req', subs)
 | 
				
			||||||
 | 
					        self.assertEqual(response.status, 200)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def test_start_coverage_combine(self):
 | 
				
			||||||
 | 
					        """Start coverage data collection"""
 | 
				
			||||||
 | 
					        subs = {}
 | 
				
			||||||
 | 
					        response = self._do_post('os-coverage/action',
 | 
				
			||||||
 | 
					                                 'coverage-start-combine-post-req', subs)
 | 
				
			||||||
 | 
					        self.assertEqual(response.status, 200)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def test_stop_coverage(self):
 | 
				
			||||||
 | 
					        """Stop coverage data collection"""
 | 
				
			||||||
 | 
					        subs = {}
 | 
				
			||||||
 | 
					        response = self._do_post('os-coverage/action',
 | 
				
			||||||
 | 
					                                 'coverage-stop-post-req', subs)
 | 
				
			||||||
 | 
					        self.assertEqual(response.status, 200)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def test_report_coverage(self):
 | 
				
			||||||
 | 
					        """Generate a coverage report"""
 | 
				
			||||||
 | 
					        subs = {
 | 
				
			||||||
 | 
					            'filename': 'report',
 | 
				
			||||||
 | 
					            'path': '/.*/report',
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        response = self._do_post('os-coverage/action',
 | 
				
			||||||
 | 
					                                 'coverage-report-post-req', subs)
 | 
				
			||||||
 | 
					        self.assertEqual(response.status, 200)
 | 
				
			||||||
 | 
					        subs.update(self._get_regexes())
 | 
				
			||||||
 | 
					        return self._verify_response('coverage-report-post-resp',
 | 
				
			||||||
 | 
					                                     subs, response)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def test_xml_report_coverage(self):
 | 
				
			||||||
 | 
					        subs = {
 | 
				
			||||||
 | 
					            'filename': 'report',
 | 
				
			||||||
 | 
					            'path': '/.*/report',
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        response = self._do_post('os-coverage/action',
 | 
				
			||||||
 | 
					                                 'coverage-xml-report-post-req', subs)
 | 
				
			||||||
 | 
					        self.assertEqual(response.status, 200)
 | 
				
			||||||
 | 
					        subs.update(self._get_regexes())
 | 
				
			||||||
 | 
					        return self._verify_response('coverage-xml-report-post-resp',
 | 
				
			||||||
 | 
					                                     subs, response)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class CoverageExtXmlTests(CoverageExtJsonTests):
 | 
				
			||||||
 | 
					    ctype = "xml"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class ServersActionsJsonTest(ServersSampleBase):
 | 
					class ServersActionsJsonTest(ServersSampleBase):
 | 
				
			||||||
    def _test_server_action(self, uuid, action,
 | 
					    def _test_server_action(self, uuid, action,
 | 
				
			||||||
                            subs={}, resp_tpl=None, code=202):
 | 
					                            subs={}, resp_tpl=None, code=202):
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user