Speed up api.openstack.compute.contrib tests
Use init_only parameter to select the minimal number of extensions and resources needed for test execution. Improvement on a test machine was from 59.770s to 15.218s (508 tests). Implements bp:api-tests-speed Change-Id: Id27bd5c29eaee1ef7225b7aeb43210063aaf0d4e
This commit is contained in:
@@ -94,9 +94,13 @@ class AdminActionsTest(test.TestCase):
|
||||
self.stubs.Set(scheduler_rpcapi.SchedulerAPI,
|
||||
'live_migration',
|
||||
fake_scheduler_api_live_migration)
|
||||
self.flags(
|
||||
osapi_compute_extension=[
|
||||
'nova.api.openstack.compute.contrib.select_extensions'],
|
||||
osapi_compute_ext_list=['Admin_actions'])
|
||||
|
||||
def test_admin_api_actions(self):
|
||||
app = fakes.wsgi_app()
|
||||
app = fakes.wsgi_app(init_only=('servers',))
|
||||
for _action in self._actions:
|
||||
req = webob.Request.blank('/v2/fake/servers/%s/action' %
|
||||
self.UUID)
|
||||
@@ -107,7 +111,7 @@ class AdminActionsTest(test.TestCase):
|
||||
self.assertEqual(res.status_int, 202)
|
||||
|
||||
def test_admin_api_actions_raise_conflict_on_invalid_state(self):
|
||||
app = fakes.wsgi_app()
|
||||
app = fakes.wsgi_app(init_only=('servers',))
|
||||
|
||||
for _action, _method in self._actions_that_check_state:
|
||||
self.stubs.Set(compute_api.API, _method,
|
||||
@@ -128,7 +132,7 @@ class AdminActionsTest(test.TestCase):
|
||||
ctxt.user_id = 'fake'
|
||||
ctxt.project_id = 'fake'
|
||||
ctxt.is_admin = True
|
||||
app = fakes.wsgi_app(fake_auth_context=ctxt)
|
||||
app = fakes.wsgi_app(fake_auth_context=ctxt, init_only=('servers',))
|
||||
req = webob.Request.blank('/v2/fake/servers/%s/action' % self.UUID)
|
||||
req.method = 'POST'
|
||||
req.body = jsonutils.dumps({
|
||||
@@ -154,7 +158,7 @@ class AdminActionsTest(test.TestCase):
|
||||
ctxt.user_id = 'fake'
|
||||
ctxt.project_id = 'fake'
|
||||
ctxt.is_admin = True
|
||||
app = fakes.wsgi_app(fake_auth_context=ctxt)
|
||||
app = fakes.wsgi_app(fake_auth_context=ctxt, init_only=('servers',))
|
||||
req = webob.Request.blank('/v2/fake/servers/%s/action' % self.UUID)
|
||||
req.method = 'POST'
|
||||
req.body = jsonutils.dumps({
|
||||
@@ -176,7 +180,7 @@ class CreateBackupTests(test.TestCase):
|
||||
|
||||
self.stubs.Set(compute_api.API, 'get', fake_compute_api_get)
|
||||
self.backup_stubs = fakes.stub_out_compute_api_backup(self.stubs)
|
||||
self.app = compute.APIRouter()
|
||||
self.app = compute.APIRouter(init_only=('servers',))
|
||||
self.uuid = utils.gen_uuid()
|
||||
|
||||
def _get_request(self, body):
|
||||
|
@@ -31,13 +31,17 @@ class ConfigDriveTest(test.TestCase):
|
||||
fakes.stub_out_networking(self.stubs)
|
||||
fakes.stub_out_rate_limiting(self.stubs)
|
||||
nova.tests.image.fake.stub_out_image_service(self.stubs)
|
||||
self.flags(
|
||||
osapi_compute_extension=[
|
||||
'nova.api.openstack.compute.contrib.select_extensions'],
|
||||
osapi_compute_ext_list=['Config_drive'])
|
||||
|
||||
def test_show(self):
|
||||
self.stubs.Set(db, 'instance_get',
|
||||
fakes.fake_instance_get())
|
||||
req = webob.Request.blank('/v2/fake/servers/1')
|
||||
req.headers['Content-Type'] = 'application/json'
|
||||
response = req.get_response(fakes.wsgi_app())
|
||||
response = req.get_response(fakes.wsgi_app(init_only=('servers',)))
|
||||
self.assertEquals(response.status_int, 200)
|
||||
res_dict = jsonutils.loads(response.body)
|
||||
self.assertTrue('config_drive' in res_dict['server'])
|
||||
@@ -46,7 +50,7 @@ class ConfigDriveTest(test.TestCase):
|
||||
self.stubs.Set(db, 'instance_get',
|
||||
fakes.fake_instance_get())
|
||||
req = fakes.HTTPRequest.blank('/v2/fake/servers/detail')
|
||||
res = req.get_response(fakes.wsgi_app())
|
||||
res = req.get_response(fakes.wsgi_app(init_only=('servers,')))
|
||||
server_dicts = jsonutils.loads(res.body)['servers']
|
||||
for server_dict in server_dicts:
|
||||
self.asserTrue('config_drive' in server_dict)
|
||||
|
@@ -50,6 +50,11 @@ class ConsoleOutputExtensionTest(test.TestCase):
|
||||
self.stubs.Set(compute_api.API, 'get_console_output',
|
||||
fake_get_console_output)
|
||||
self.stubs.Set(compute_api.API, 'get', fake_get)
|
||||
self.flags(
|
||||
osapi_compute_extension=[
|
||||
'nova.api.openstack.compute.contrib.select_extensions'],
|
||||
osapi_compute_ext_list=['Console_output'])
|
||||
self.app = fakes.wsgi_app(init_only=('servers',))
|
||||
|
||||
def test_get_text_console_instance_action(self):
|
||||
body = {'os-getConsoleOutput': {}}
|
||||
@@ -58,7 +63,7 @@ class ConsoleOutputExtensionTest(test.TestCase):
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
|
||||
res = req.get_response(fakes.wsgi_app())
|
||||
res = req.get_response(self.app)
|
||||
output = jsonutils.loads(res.body)
|
||||
self.assertEqual(res.status_int, 200)
|
||||
self.assertEqual(output, {'output': '0\n1\n2\n3\n4'})
|
||||
@@ -69,7 +74,7 @@ class ConsoleOutputExtensionTest(test.TestCase):
|
||||
req.method = "POST"
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
res = req.get_response(fakes.wsgi_app())
|
||||
res = req.get_response(self.app)
|
||||
output = jsonutils.loads(res.body)
|
||||
self.assertEqual(res.status_int, 200)
|
||||
self.assertEqual(output, {'output': '2\n3\n4'})
|
||||
@@ -80,7 +85,7 @@ class ConsoleOutputExtensionTest(test.TestCase):
|
||||
req.method = "POST"
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
res = req.get_response(fakes.wsgi_app())
|
||||
res = req.get_response(self.app)
|
||||
output = jsonutils.loads(res.body)
|
||||
self.assertEqual(res.status_int, 200)
|
||||
self.assertEqual(output, {'output': '2\n3\n4'})
|
||||
@@ -91,7 +96,7 @@ class ConsoleOutputExtensionTest(test.TestCase):
|
||||
req.method = "POST"
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
res = req.get_response(fakes.wsgi_app())
|
||||
res = req.get_response(self.app)
|
||||
output = jsonutils.loads(res.body)
|
||||
self.assertEqual(res.status_int, 400)
|
||||
|
||||
@@ -103,7 +108,7 @@ class ConsoleOutputExtensionTest(test.TestCase):
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
|
||||
res = req.get_response(fakes.wsgi_app())
|
||||
res = req.get_response(self.app)
|
||||
self.assertEqual(res.status_int, 404)
|
||||
|
||||
def test_get_text_console_no_instance_on_get_output(self):
|
||||
@@ -116,7 +121,7 @@ class ConsoleOutputExtensionTest(test.TestCase):
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
|
||||
res = req.get_response(fakes.wsgi_app())
|
||||
res = req.get_response(self.app)
|
||||
self.assertEqual(res.status_int, 404)
|
||||
|
||||
def test_get_text_console_bad_body(self):
|
||||
@@ -126,5 +131,5 @@ class ConsoleOutputExtensionTest(test.TestCase):
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
|
||||
res = req.get_response(fakes.wsgi_app())
|
||||
res = req.get_response(self.app)
|
||||
self.assertEqual(res.status_int, 400)
|
||||
|
@@ -54,6 +54,11 @@ class ConsolesExtensionTest(test.TestCase):
|
||||
self.stubs.Set(compute_api.API, 'get_vnc_console',
|
||||
fake_get_vnc_console)
|
||||
self.stubs.Set(compute_api.API, 'get', fake_get)
|
||||
self.flags(
|
||||
osapi_compute_extension=[
|
||||
'nova.api.openstack.compute.contrib.select_extensions'],
|
||||
osapi_compute_ext_list=['Consoles'])
|
||||
self.app = fakes.wsgi_app(init_only=('servers',))
|
||||
|
||||
def test_get_vnc_console(self):
|
||||
body = {'os-getVNCConsole': {'type': 'novnc'}}
|
||||
@@ -62,7 +67,7 @@ class ConsolesExtensionTest(test.TestCase):
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
|
||||
res = req.get_response(fakes.wsgi_app())
|
||||
res = req.get_response(self.app)
|
||||
output = jsonutils.loads(res.body)
|
||||
self.assertEqual(res.status_int, 200)
|
||||
self.assertEqual(output,
|
||||
@@ -77,7 +82,7 @@ class ConsolesExtensionTest(test.TestCase):
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
|
||||
res = req.get_response(fakes.wsgi_app())
|
||||
res = req.get_response(self.app)
|
||||
output = jsonutils.loads(res.body)
|
||||
self.assertEqual(res.status_int, 409)
|
||||
|
||||
@@ -90,7 +95,7 @@ class ConsolesExtensionTest(test.TestCase):
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
|
||||
res = req.get_response(fakes.wsgi_app())
|
||||
res = req.get_response(self.app)
|
||||
self.assertEqual(res.status_int, 400)
|
||||
|
||||
def test_get_vnc_console_no_instance(self):
|
||||
@@ -101,7 +106,7 @@ class ConsolesExtensionTest(test.TestCase):
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
|
||||
res = req.get_response(fakes.wsgi_app())
|
||||
res = req.get_response(self.app)
|
||||
self.assertEqual(res.status_int, 404)
|
||||
|
||||
def test_get_vnc_console_no_instance_on_console_get(self):
|
||||
@@ -113,7 +118,7 @@ class ConsolesExtensionTest(test.TestCase):
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
|
||||
res = req.get_response(fakes.wsgi_app())
|
||||
res = req.get_response(self.app)
|
||||
self.assertEqual(res.status_int, 404)
|
||||
|
||||
def test_get_vnc_console_invalid_type(self):
|
||||
@@ -125,5 +130,5 @@ class ConsolesExtensionTest(test.TestCase):
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
|
||||
res = req.get_response(fakes.wsgi_app())
|
||||
res = req.get_response(self.app)
|
||||
self.assertEqual(res.status_int, 400)
|
||||
|
@@ -99,6 +99,16 @@ class CreateserverextTest(test.TestCase):
|
||||
'progress': 0}], resv_id)
|
||||
|
||||
self.stubs.Set(compute_api.API, 'create', create)
|
||||
self.flags(
|
||||
osapi_compute_extension=[
|
||||
'nova.api.openstack.compute.contrib.select_extensions'],
|
||||
osapi_compute_ext_list=['Createserverext', 'User_data',
|
||||
'Security_groups', 'Networks'])
|
||||
|
||||
def _make_stub_method(self, canned_return):
|
||||
def stub_method(*args, **kwargs):
|
||||
return canned_return
|
||||
return stub_method
|
||||
|
||||
def _create_security_group_request_dict(self, security_groups):
|
||||
server = {}
|
||||
@@ -182,19 +192,22 @@ class CreateserverextTest(test.TestCase):
|
||||
def _create_instance_with_networks_json(self, networks):
|
||||
body_dict = self._create_networks_request_dict(networks)
|
||||
request = self._get_create_request_json(body_dict)
|
||||
response = request.get_response(fakes.wsgi_app())
|
||||
response = request.get_response(fakes.wsgi_app(
|
||||
init_only=('servers', 'os-create-server-ext')))
|
||||
return request, response, self.networks
|
||||
|
||||
def _create_instance_with_user_data_json(self, networks):
|
||||
body_dict = self._create_user_data_request_dict(networks)
|
||||
request = self._get_create_request_json(body_dict)
|
||||
response = request.get_response(fakes.wsgi_app())
|
||||
response = request.get_response(fakes.wsgi_app(
|
||||
init_only=('servers', 'os-create-server-ext')))
|
||||
return request, response, self.user_data
|
||||
|
||||
def _create_instance_with_networks_xml(self, networks):
|
||||
body_dict = self._create_networks_request_dict(networks)
|
||||
request = self._get_create_request_xml(body_dict)
|
||||
response = request.get_response(fakes.wsgi_app())
|
||||
response = request.get_response(fakes.wsgi_app(
|
||||
init_only=('servers', 'os-create-server-ext')))
|
||||
return request, response, self.networks
|
||||
|
||||
def test_create_instance_with_no_networks(self):
|
||||
@@ -249,7 +262,8 @@ class CreateserverextTest(test.TestCase):
|
||||
body_dict = self._create_networks_request_dict([FAKE_NETWORKS[0]])
|
||||
del body_dict['server']['networks'][0]['uuid']
|
||||
request = self._get_create_request_json(body_dict)
|
||||
response = request.get_response(fakes.wsgi_app())
|
||||
response = request.get_response(fakes.wsgi_app(
|
||||
init_only=('servers', 'os-create-server-ext')))
|
||||
self.assertEquals(response.status_int, 400)
|
||||
self.assertEquals(self.networks, None)
|
||||
|
||||
@@ -258,7 +272,8 @@ class CreateserverextTest(test.TestCase):
|
||||
request = self._get_create_request_xml(body_dict)
|
||||
uuid = ' uuid="aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"'
|
||||
request.body = request.body.replace(uuid, '')
|
||||
response = request.get_response(fakes.wsgi_app())
|
||||
response = request.get_response(fakes.wsgi_app(
|
||||
init_only=('servers', 'os-create-server-ext')))
|
||||
self.assertEquals(response.status_int, 400)
|
||||
self.assertEquals(self.networks, None)
|
||||
|
||||
@@ -299,7 +314,8 @@ class CreateserverextTest(test.TestCase):
|
||||
body_dict = self._create_networks_request_dict([FAKE_NETWORKS[0]])
|
||||
del body_dict['server']['networks'][0]['fixed_ip']
|
||||
request = self._get_create_request_json(body_dict)
|
||||
response = request.get_response(fakes.wsgi_app())
|
||||
response = request.get_response(fakes.wsgi_app(
|
||||
init_only=('servers', 'os-create-server-ext')))
|
||||
self.assertEquals(response.status_int, 202)
|
||||
self.assertEquals(self.networks,
|
||||
[('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', None)])
|
||||
@@ -308,7 +324,8 @@ class CreateserverextTest(test.TestCase):
|
||||
body_dict = self._create_networks_request_dict([FAKE_NETWORKS[0]])
|
||||
request = self._get_create_request_xml(body_dict)
|
||||
request.body = request.body.replace(' fixed_ip="10.0.1.12"', '')
|
||||
response = request.get_response(fakes.wsgi_app())
|
||||
response = request.get_response(fakes.wsgi_app(
|
||||
init_only=('servers', 'os-create-server-ext')))
|
||||
self.assertEquals(response.status_int, 202)
|
||||
self.assertEquals(self.networks,
|
||||
[('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa', None)])
|
||||
@@ -343,7 +360,8 @@ class CreateserverextTest(test.TestCase):
|
||||
return_instance_add_security_group)
|
||||
body_dict = self._create_security_group_request_dict(security_groups)
|
||||
request = self._get_create_request_json(body_dict)
|
||||
response = request.get_response(fakes.wsgi_app())
|
||||
response = request.get_response(fakes.wsgi_app(
|
||||
init_only=('servers', 'os-create-server-ext')))
|
||||
self.assertEquals(response.status_int, 202)
|
||||
self.assertEquals(self.security_group, security_groups)
|
||||
|
||||
@@ -351,7 +369,8 @@ class CreateserverextTest(test.TestCase):
|
||||
self.stubs.Set(db, 'instance_get', fakes.fake_instance_get())
|
||||
req = webob.Request.blank('/v2/fake/os-create-server-ext/1')
|
||||
req.headers['Content-Type'] = 'application/json'
|
||||
response = req.get_response(fakes.wsgi_app())
|
||||
response = req.get_response(fakes.wsgi_app(
|
||||
init_only=('os-create-server-ext', 'servers')))
|
||||
self.assertEquals(response.status_int, 200)
|
||||
res_dict = jsonutils.loads(response.body)
|
||||
expected_security_group = [{"name": "test"}]
|
||||
@@ -362,7 +381,8 @@ class CreateserverextTest(test.TestCase):
|
||||
self.stubs.Set(db, 'instance_get', fakes.fake_instance_get())
|
||||
req = webob.Request.blank('/v2/fake/os-create-server-ext/1')
|
||||
req.headers['Accept'] = 'application/xml'
|
||||
response = req.get_response(fakes.wsgi_app())
|
||||
response = req.get_response(fakes.wsgi_app(
|
||||
init_only=('os-create-server-ext', 'servers')))
|
||||
self.assertEquals(response.status_int, 200)
|
||||
dom = minidom.parseString(response.body)
|
||||
server = dom.childNodes[0]
|
||||
|
@@ -45,7 +45,10 @@ class DiskConfigTestCase(test.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(DiskConfigTestCase, self).setUp()
|
||||
self.flags(verbose=True)
|
||||
self.flags(verbose=True,
|
||||
osapi_compute_extension=[
|
||||
'nova.api.openstack.compute.contrib.select_extensions'],
|
||||
osapi_compute_ext_list=['Disk_config'])
|
||||
nova.tests.image.fake.stub_out_image_service(self.stubs)
|
||||
|
||||
fakes.stub_out_nw_api(self.stubs)
|
||||
@@ -125,7 +128,7 @@ class DiskConfigTestCase(test.TestCase):
|
||||
|
||||
self.stubs.Set(nova.db, 'instance_create', fake_instance_create)
|
||||
|
||||
self.app = compute.APIRouter()
|
||||
self.app = compute.APIRouter(init_only=('servers', 'images'))
|
||||
|
||||
def tearDown(self):
|
||||
super(DiskConfigTestCase, self).tearDown()
|
||||
|
@@ -59,11 +59,15 @@ class ExtendedServerAttributesTest(test.TestCase):
|
||||
self.stubs.Set(compute.api.API, 'get', fake_compute_get)
|
||||
self.stubs.Set(compute.api.API, 'get_all', fake_compute_get_all)
|
||||
self.stubs.Set(db, 'compute_node_get_by_host', fake_cn_get)
|
||||
self.flags(
|
||||
osapi_compute_extension=[
|
||||
'nova.api.openstack.compute.contrib.select_extensions'],
|
||||
osapi_compute_ext_list=['Extended_server_attributes'])
|
||||
|
||||
def _make_request(self, url):
|
||||
req = webob.Request.blank(url)
|
||||
req.headers['Accept'] = self.content_type
|
||||
res = req.get_response(fakes.wsgi_app())
|
||||
res = req.get_response(fakes.wsgi_app(init_only=('servers',)))
|
||||
return res
|
||||
|
||||
def _get_server(self, body):
|
||||
|
@@ -56,11 +56,15 @@ class ExtendedStatusTest(test.TestCase):
|
||||
fakes.stub_out_nw_api(self.stubs)
|
||||
self.stubs.Set(compute.api.API, 'get', fake_compute_get)
|
||||
self.stubs.Set(compute.api.API, 'get_all', fake_compute_get_all)
|
||||
self.flags(
|
||||
osapi_compute_extension=[
|
||||
'nova.api.openstack.compute.contrib.select_extensions'],
|
||||
osapi_compute_ext_list=['Extended_status'])
|
||||
|
||||
def _make_request(self, url):
|
||||
req = webob.Request.blank(url)
|
||||
req.headers['Accept'] = self.content_type
|
||||
res = req.get_response(fakes.wsgi_app())
|
||||
res = req.get_response(fakes.wsgi_app(init_only=('servers',)))
|
||||
return res
|
||||
|
||||
def _get_server(self, body):
|
||||
|
@@ -85,8 +85,14 @@ class FlavorManageTest(test.TestCase):
|
||||
fake_get_instance_type_by_flavor_id)
|
||||
self.stubs.Set(instance_types, "destroy", fake_destroy)
|
||||
self.stubs.Set(instance_types, "create", fake_create)
|
||||
self.flags(
|
||||
osapi_compute_extension=[
|
||||
'nova.api.openstack.compute.contrib.select_extensions'],
|
||||
osapi_compute_ext_list=['Flavormanage', 'Flavorextradata',
|
||||
'Flavor_access', 'Flavor_rxtx', 'Flavor_swap'])
|
||||
|
||||
self.controller = flavormanage.FlavorManageController()
|
||||
self.app = fakes.wsgi_app(init_only=('flavors',))
|
||||
|
||||
def test_delete(self):
|
||||
req = fakes.HTTPRequest.blank('/v2/123/flavors/1234')
|
||||
@@ -117,7 +123,7 @@ class FlavorManageTest(test.TestCase):
|
||||
req.headers['Content-Type'] = 'application/json'
|
||||
req.method = 'POST'
|
||||
req.body = jsonutils.dumps(expected)
|
||||
res = req.get_response(fakes.wsgi_app())
|
||||
res = req.get_response(self.app)
|
||||
body = jsonutils.loads(res.body)
|
||||
for key in expected["flavor"]:
|
||||
self.assertEquals(body["flavor"][key], expected["flavor"][key])
|
||||
@@ -156,7 +162,7 @@ class FlavorManageTest(test.TestCase):
|
||||
req.headers['Content-Type'] = 'application/json'
|
||||
req.method = 'POST'
|
||||
req.body = jsonutils.dumps(flavor)
|
||||
res = req.get_response(fakes.wsgi_app())
|
||||
res = req.get_response(self.app)
|
||||
body = jsonutils.loads(res.body)
|
||||
for key in expected["flavor"]:
|
||||
self.assertEquals(body["flavor"][key], expected["flavor"][key])
|
||||
@@ -180,7 +186,7 @@ class FlavorManageTest(test.TestCase):
|
||||
req.headers['Content-Type'] = 'application/json'
|
||||
req.method = 'POST'
|
||||
req.body = jsonutils.dumps(expected)
|
||||
res = req.get_response(fakes.wsgi_app())
|
||||
res = req.get_response(self.app)
|
||||
body = jsonutils.loads(res.body)
|
||||
for key in expected["flavor"]:
|
||||
self.assertEquals(body["flavor"][key], expected["flavor"][key])
|
||||
@@ -210,5 +216,5 @@ class FlavorManageTest(test.TestCase):
|
||||
req.headers['Content-Type'] = 'application/json'
|
||||
req.method = 'POST'
|
||||
req.body = jsonutils.dumps(expected)
|
||||
res = req.get_response(fakes.wsgi_app())
|
||||
res = req.get_response(self.app)
|
||||
self.assertEqual(res.status_int, 409)
|
||||
|
@@ -77,7 +77,7 @@ class FlavorextradataTest(test.TestCase):
|
||||
url = '/v2/fake/flavors/1'
|
||||
req = webob.Request.blank(url)
|
||||
req.headers['Content-Type'] = 'application/json'
|
||||
res = req.get_response(fakes.wsgi_app())
|
||||
res = req.get_response(fakes.wsgi_app(init_only=('flavors',)))
|
||||
body = jsonutils.loads(res.body)
|
||||
self._verify_flavor_response(body['flavor'], expected['flavor'])
|
||||
|
||||
@@ -104,7 +104,7 @@ class FlavorextradataTest(test.TestCase):
|
||||
url = '/v2/fake/flavors/detail'
|
||||
req = webob.Request.blank(url)
|
||||
req.headers['Content-Type'] = 'application/json'
|
||||
res = req.get_response(fakes.wsgi_app())
|
||||
res = req.get_response(fakes.wsgi_app(init_only=('flavors',)))
|
||||
body = jsonutils.loads(res.body)
|
||||
for i, flavor in enumerate(body['flavors']):
|
||||
self._verify_flavor_response(flavor, expected[i])
|
||||
|
@@ -147,6 +147,10 @@ class FloatingIpTest(test.TestCase):
|
||||
get_instance_by_floating_ip_addr)
|
||||
self.stubs.Set(compute_utils, "get_nw_info_for_instance",
|
||||
stub_nw_info(self.stubs))
|
||||
self.flags(
|
||||
osapi_compute_extension=[
|
||||
'nova.api.openstack.compute.contrib.select_extensions'],
|
||||
osapi_compute_ext_list=['Floating_ips'])
|
||||
|
||||
fake_network.stub_out_nw_api_get_instance_nw_info(self.stubs,
|
||||
spectacular=True)
|
||||
@@ -207,7 +211,7 @@ class FloatingIpTest(test.TestCase):
|
||||
|
||||
req = fakes.HTTPRequest.blank('/v2/fake/os-floating-ips/9876')
|
||||
req.method = 'DELETE'
|
||||
res = req.get_response(fakes.wsgi_app())
|
||||
res = req.get_response(fakes.wsgi_app(init_only=('os-floating-ips',)))
|
||||
self.assertEqual(res.status_int, 404)
|
||||
expected_msg = ('{"itemNotFound": {"message": "Floating ip not found '
|
||||
'for id 9876", "code": 404}}')
|
||||
@@ -230,7 +234,7 @@ class FloatingIpTest(test.TestCase):
|
||||
|
||||
req = fakes.HTTPRequest.blank('/v2/fake/os-floating-ips/9876')
|
||||
|
||||
res = req.get_response(fakes.wsgi_app())
|
||||
res = req.get_response(fakes.wsgi_app(init_only=('os-floating-ips',)))
|
||||
self.assertEqual(res.status_int, 404)
|
||||
expected_msg = ('{"itemNotFound": {"message": "Floating ip not found '
|
||||
'for id 9876", "code": 404}}')
|
||||
@@ -340,7 +344,7 @@ class FloatingIpTest(test.TestCase):
|
||||
req.method = "POST"
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
resp = req.get_response(fakes.wsgi_app())
|
||||
resp = req.get_response(fakes.wsgi_app(init_only=('servers',)))
|
||||
res_dict = jsonutils.loads(resp.body)
|
||||
self.assertEqual(resp.status_int, 404)
|
||||
self.assertEqual(res_dict['itemNotFound']['message'],
|
||||
|
@@ -66,10 +66,15 @@ class KeypairsTest(test.TestCase):
|
||||
db_key_pair_create)
|
||||
self.stubs.Set(db, "key_pair_destroy",
|
||||
db_key_pair_destroy)
|
||||
self.flags(
|
||||
osapi_compute_extension=[
|
||||
'nova.api.openstack.compute.contrib.select_extensions'],
|
||||
osapi_compute_ext_list=['Keypairs'])
|
||||
self.app = fakes.wsgi_app(init_only=('os-keypairs',))
|
||||
|
||||
def test_keypair_list(self):
|
||||
req = webob.Request.blank('/v2/fake/os-keypairs')
|
||||
res = req.get_response(fakes.wsgi_app())
|
||||
res = req.get_response(self.app)
|
||||
self.assertEqual(res.status_int, 200)
|
||||
res_dict = jsonutils.loads(res.body)
|
||||
response = {'keypairs': [{'keypair': fake_keypair('FAKE')}]}
|
||||
@@ -81,7 +86,7 @@ class KeypairsTest(test.TestCase):
|
||||
req.method = 'POST'
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.headers['Content-Type'] = 'application/json'
|
||||
res = req.get_response(fakes.wsgi_app())
|
||||
res = req.get_response(self.app)
|
||||
self.assertEqual(res.status_int, 200)
|
||||
res_dict = jsonutils.loads(res.body)
|
||||
self.assertTrue(len(res_dict['keypair']['fingerprint']) > 0)
|
||||
@@ -93,7 +98,7 @@ class KeypairsTest(test.TestCase):
|
||||
req.method = 'POST'
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.headers['Content-Type'] = 'application/json'
|
||||
res = req.get_response(fakes.wsgi_app())
|
||||
res = req.get_response(self.app)
|
||||
self.assertEqual(res.status_int, 400)
|
||||
|
||||
def test_keypair_create_with_invalid_name(self):
|
||||
@@ -106,7 +111,7 @@ class KeypairsTest(test.TestCase):
|
||||
req.method = 'POST'
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.headers['Content-Type'] = 'application/json'
|
||||
res = req.get_response(fakes.wsgi_app())
|
||||
res = req.get_response(self.app)
|
||||
self.assertEqual(res.status_int, 400)
|
||||
|
||||
def test_keypair_create_with_non_alphanumeric_name(self):
|
||||
@@ -119,7 +124,7 @@ class KeypairsTest(test.TestCase):
|
||||
req.method = 'POST'
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.headers['Content-Type'] = 'application/json'
|
||||
res = req.get_response(fakes.wsgi_app())
|
||||
res = req.get_response(self.app)
|
||||
res_dict = jsonutils.loads(res.body)
|
||||
self.assertEqual(res.status_int, 400)
|
||||
|
||||
@@ -143,7 +148,7 @@ class KeypairsTest(test.TestCase):
|
||||
req.method = 'POST'
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.headers['Content-Type'] = 'application/json'
|
||||
res = req.get_response(fakes.wsgi_app())
|
||||
res = req.get_response(self.app)
|
||||
self.assertEqual(res.status_int, 200)
|
||||
# FIXME(ja): sholud we check that public_key was sent to create?
|
||||
res_dict = jsonutils.loads(res.body)
|
||||
@@ -176,7 +181,7 @@ class KeypairsTest(test.TestCase):
|
||||
req.method = 'POST'
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.headers['Content-Type'] = 'application/json'
|
||||
res = req.get_response(fakes.wsgi_app())
|
||||
res = req.get_response(self.app)
|
||||
self.assertEqual(res.status_int, 413)
|
||||
|
||||
def test_keypair_create_quota_limit(self):
|
||||
@@ -196,7 +201,7 @@ class KeypairsTest(test.TestCase):
|
||||
req.method = 'POST'
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.headers['Content-Type'] = 'application/json'
|
||||
res = req.get_response(fakes.wsgi_app())
|
||||
res = req.get_response(self.app)
|
||||
self.assertEqual(res.status_int, 413)
|
||||
|
||||
def test_keypair_create_duplicate(self):
|
||||
@@ -206,7 +211,7 @@ class KeypairsTest(test.TestCase):
|
||||
req.method = 'POST'
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.headers['Content-Type'] = 'application/json'
|
||||
res = req.get_response(fakes.wsgi_app())
|
||||
res = req.get_response(self.app)
|
||||
self.assertEqual(res.status_int, 409)
|
||||
|
||||
def test_keypair_import_bad_key(self):
|
||||
@@ -221,14 +226,14 @@ class KeypairsTest(test.TestCase):
|
||||
req.method = 'POST'
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.headers['Content-Type'] = 'application/json'
|
||||
res = req.get_response(fakes.wsgi_app())
|
||||
res = req.get_response(self.app)
|
||||
self.assertEqual(res.status_int, 400)
|
||||
|
||||
def test_keypair_delete(self):
|
||||
req = webob.Request.blank('/v2/fake/os-keypairs/FAKE')
|
||||
req.method = 'DELETE'
|
||||
req.headers['Content-Type'] = 'application/json'
|
||||
res = req.get_response(fakes.wsgi_app())
|
||||
res = req.get_response(self.app)
|
||||
self.assertEqual(res.status_int, 202)
|
||||
|
||||
def test_keypair_delete_not_found(self):
|
||||
@@ -239,7 +244,7 @@ class KeypairsTest(test.TestCase):
|
||||
self.stubs.Set(db, "key_pair_get",
|
||||
db_key_pair_get_not_found)
|
||||
req = webob.Request.blank('/v2/fake/os-keypairs/WHAT')
|
||||
res = req.get_response(fakes.wsgi_app())
|
||||
res = req.get_response(self.app)
|
||||
self.assertEqual(res.status_int, 404)
|
||||
|
||||
def test_keypair_show(self):
|
||||
@@ -252,7 +257,7 @@ class KeypairsTest(test.TestCase):
|
||||
req = webob.Request.blank('/v2/fake/os-keypairs/FAKE')
|
||||
req.method = 'GET'
|
||||
req.headers['Content-Type'] = 'application/json'
|
||||
res = req.get_response(fakes.wsgi_app())
|
||||
res = req.get_response(self.app)
|
||||
res_dict = jsonutils.loads(res.body)
|
||||
self.assertEqual(res.status_int, 200)
|
||||
self.assertEqual('foo', res_dict['keypair']['name'])
|
||||
@@ -269,7 +274,7 @@ class KeypairsTest(test.TestCase):
|
||||
req = webob.Request.blank('/v2/fake/os-keypairs/FAKE')
|
||||
req.method = 'GET'
|
||||
req.headers['Content-Type'] = 'application/json'
|
||||
res = req.get_response(fakes.wsgi_app())
|
||||
res = req.get_response(self.app)
|
||||
self.assertEqual(res.status_int, 404)
|
||||
|
||||
def test_show_server(self):
|
||||
@@ -277,7 +282,7 @@ class KeypairsTest(test.TestCase):
|
||||
fakes.fake_instance_get())
|
||||
req = webob.Request.blank('/v2/fake/servers/1')
|
||||
req.headers['Content-Type'] = 'application/json'
|
||||
response = req.get_response(fakes.wsgi_app())
|
||||
response = req.get_response(fakes.wsgi_app(init_only=('servers',)))
|
||||
self.assertEquals(response.status_int, 200)
|
||||
res_dict = jsonutils.loads(response.body)
|
||||
self.assertTrue('key_name' in res_dict['server'])
|
||||
@@ -287,7 +292,7 @@ class KeypairsTest(test.TestCase):
|
||||
self.stubs.Set(db, 'instance_get_all_by_filters',
|
||||
fakes.fake_instance_get_all_by_filters())
|
||||
req = fakes.HTTPRequest.blank('/v2/fake/servers/detail')
|
||||
res = req.get_response(fakes.wsgi_app())
|
||||
res = req.get_response(fakes.wsgi_app(init_only=('servers',)))
|
||||
server_dicts = jsonutils.loads(res.body)['servers']
|
||||
self.assertEquals(len(server_dicts), 5)
|
||||
|
||||
@@ -301,7 +306,7 @@ class KeypairsTest(test.TestCase):
|
||||
req.method = 'POST'
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.headers['Content-Type'] = 'application/json'
|
||||
res = req.get_response(fakes.wsgi_app())
|
||||
res = req.get_response(self.app)
|
||||
res_dict = jsonutils.loads(res.body)
|
||||
self.assertEqual(res.status_int, 400)
|
||||
self.assertEqual(res_dict['badRequest']['message'],
|
||||
|
@@ -52,6 +52,11 @@ class FixedIpTest(test.TestCase):
|
||||
self.stubs.Set(compute.api.API, "remove_fixed_ip",
|
||||
compute_api_remove_fixed_ip)
|
||||
self.stubs.Set(compute.api.API, 'get', compute_api_get)
|
||||
self.flags(
|
||||
osapi_compute_extension=[
|
||||
'nova.api.openstack.compute.contrib.select_extensions'],
|
||||
osapi_compute_ext_list=['Multinic'])
|
||||
self.app = fakes.wsgi_app(init_only=('servers',))
|
||||
|
||||
def test_add_fixed_ip(self):
|
||||
global last_add_fixed_ip
|
||||
@@ -63,7 +68,7 @@ class FixedIpTest(test.TestCase):
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.headers['content-type'] = 'application/json'
|
||||
|
||||
resp = req.get_response(fakes.wsgi_app())
|
||||
resp = req.get_response(self.app)
|
||||
self.assertEqual(resp.status_int, 202)
|
||||
self.assertEqual(last_add_fixed_ip, (UUID, 'test_net'))
|
||||
|
||||
@@ -77,7 +82,7 @@ class FixedIpTest(test.TestCase):
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.headers['content-type'] = 'application/json'
|
||||
|
||||
resp = req.get_response(fakes.wsgi_app())
|
||||
resp = req.get_response(self.app)
|
||||
self.assertEqual(resp.status_int, 422)
|
||||
self.assertEqual(last_add_fixed_ip, (None, None))
|
||||
|
||||
@@ -91,7 +96,7 @@ class FixedIpTest(test.TestCase):
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.headers['content-type'] = 'application/json'
|
||||
|
||||
resp = req.get_response(fakes.wsgi_app())
|
||||
resp = req.get_response(self.app)
|
||||
self.assertEqual(resp.status_int, 202)
|
||||
self.assertEqual(last_remove_fixed_ip, (UUID, '10.10.10.1'))
|
||||
|
||||
@@ -105,6 +110,6 @@ class FixedIpTest(test.TestCase):
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.headers['content-type'] = 'application/json'
|
||||
|
||||
resp = req.get_response(fakes.wsgi_app())
|
||||
resp = req.get_response(self.app)
|
||||
self.assertEqual(resp.status_int, 422)
|
||||
self.assertEqual(last_remove_fixed_ip, (None, None))
|
||||
|
@@ -43,6 +43,11 @@ class RescueTest(test.TestCase):
|
||||
self.stubs.Set(compute.api.API, "get", fake_compute_get)
|
||||
self.stubs.Set(compute.api.API, "rescue", rescue)
|
||||
self.stubs.Set(compute.api.API, "unrescue", unrescue)
|
||||
self.flags(
|
||||
osapi_compute_extension=[
|
||||
'nova.api.openstack.compute.contrib.select_extensions'],
|
||||
osapi_compute_ext_list=['Rescue'])
|
||||
self.app = fakes.wsgi_app(init_only=('servers',))
|
||||
|
||||
def test_rescue_with_preset_password(self):
|
||||
body = {"rescue": {"adminPass": "AABBCC112233"}}
|
||||
@@ -51,7 +56,7 @@ class RescueTest(test.TestCase):
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
|
||||
resp = req.get_response(fakes.wsgi_app())
|
||||
resp = req.get_response(self.app)
|
||||
self.assertEqual(resp.status_int, 200)
|
||||
resp_json = jsonutils.loads(resp.body)
|
||||
self.assertEqual("AABBCC112233", resp_json['adminPass'])
|
||||
@@ -63,7 +68,7 @@ class RescueTest(test.TestCase):
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
|
||||
resp = req.get_response(fakes.wsgi_app())
|
||||
resp = req.get_response(self.app)
|
||||
self.assertEqual(resp.status_int, 200)
|
||||
resp_json = jsonutils.loads(resp.body)
|
||||
self.assertEqual(FLAGS.password_length, len(resp_json['adminPass']))
|
||||
@@ -80,7 +85,7 @@ class RescueTest(test.TestCase):
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
|
||||
resp = req.get_response(fakes.wsgi_app())
|
||||
resp = req.get_response(self.app)
|
||||
self.assertEqual(resp.status_int, 409)
|
||||
|
||||
def test_unrescue(self):
|
||||
@@ -90,7 +95,7 @@ class RescueTest(test.TestCase):
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
|
||||
resp = req.get_response(fakes.wsgi_app())
|
||||
resp = req.get_response(self.app)
|
||||
self.assertEqual(resp.status_int, 202)
|
||||
|
||||
def test_unrescue_of_active_instance(self):
|
||||
@@ -105,5 +110,5 @@ class RescueTest(test.TestCase):
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.headers["content-type"] = "application/json"
|
||||
|
||||
resp = req.get_response(fakes.wsgi_app())
|
||||
resp = req.get_response(self.app)
|
||||
self.assertEqual(resp.status_int, 409)
|
||||
|
@@ -31,7 +31,11 @@ class SchedulerHintsTestCase(test.TestCase):
|
||||
def setUp(self):
|
||||
super(SchedulerHintsTestCase, self).setUp()
|
||||
self.fake_instance = fakes.stub_instance(1, uuid=UUID)
|
||||
self.app = compute.APIRouter()
|
||||
self.flags(
|
||||
osapi_compute_extension=[
|
||||
'nova.api.openstack.compute.contrib.select_extensions'],
|
||||
osapi_compute_ext_list=['Scheduler_hints'])
|
||||
self.app = compute.APIRouter(init_only=('servers',))
|
||||
|
||||
def test_create_server_without_hints(self):
|
||||
|
||||
|
@@ -1310,6 +1310,10 @@ class SecurityGroupsOutputTest(test.TestCase):
|
||||
self.stubs.Set(compute.api.API, 'get', fake_compute_get)
|
||||
self.stubs.Set(compute.api.API, 'get_all', fake_compute_get_all)
|
||||
self.stubs.Set(compute.api.API, 'create', fake_compute_create)
|
||||
self.flags(
|
||||
osapi_compute_extension=[
|
||||
'nova.api.openstack.compute.contrib.select_extensions'],
|
||||
osapi_compute_ext_list=['Security_groups'])
|
||||
|
||||
def _make_request(self, url, body=None):
|
||||
req = webob.Request.blank(url)
|
||||
@@ -1318,7 +1322,7 @@ class SecurityGroupsOutputTest(test.TestCase):
|
||||
req.body = self._encode_body(body)
|
||||
req.content_type = self.content_type
|
||||
req.headers['Accept'] = self.content_type
|
||||
res = req.get_response(fakes.wsgi_app())
|
||||
res = req.get_response(fakes.wsgi_app(init_only=('servers',)))
|
||||
return res
|
||||
|
||||
def _encode_body(self, body):
|
||||
|
@@ -43,12 +43,15 @@ class ServerDiagnosticsTest(test.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(ServerDiagnosticsTest, self).setUp()
|
||||
self.flags(verbose=True)
|
||||
self.flags(verbose=True,
|
||||
osapi_compute_extension=[
|
||||
'nova.api.openstack.compute.contrib.select_extensions'],
|
||||
osapi_compute_ext_list=['Server_diagnostics'])
|
||||
self.stubs.Set(compute_api.API, 'get_diagnostics',
|
||||
fake_get_diagnostics)
|
||||
self.stubs.Set(compute_api.API, 'get', fake_instance_get)
|
||||
|
||||
self.router = compute.APIRouter()
|
||||
self.router = compute.APIRouter(init_only=('servers', 'diagnostics'))
|
||||
|
||||
def test_get_diagnostics(self):
|
||||
req = fakes.HTTPRequest.blank('/fake/servers/%s/diagnostics' % UUID)
|
||||
|
@@ -93,6 +93,10 @@ class SimpleTenantUsageTest(test.TestCase):
|
||||
self.alt_user_context = context.RequestContext('fakeadmin_0',
|
||||
'faketenant_1',
|
||||
is_admin=False)
|
||||
self.flags(
|
||||
osapi_compute_extension=[
|
||||
'nova.api.openstack.compute.contrib.select_extensions'],
|
||||
osapi_compute_ext_list=['Simple_tenant_usage'])
|
||||
|
||||
def _test_verify_index(self, start, stop):
|
||||
req = webob.Request.blank(
|
||||
@@ -102,7 +106,8 @@ class SimpleTenantUsageTest(test.TestCase):
|
||||
req.headers["content-type"] = "application/json"
|
||||
|
||||
res = req.get_response(fakes.wsgi_app(
|
||||
fake_auth_context=self.admin_context))
|
||||
fake_auth_context=self.admin_context,
|
||||
init_only=('os-simple-tenant-usage',)))
|
||||
|
||||
self.assertEqual(res.status_int, 200)
|
||||
res_dict = jsonutils.loads(res.body)
|
||||
@@ -141,7 +146,8 @@ class SimpleTenantUsageTest(test.TestCase):
|
||||
req.headers["content-type"] = "application/json"
|
||||
|
||||
res = req.get_response(fakes.wsgi_app(
|
||||
fake_auth_context=self.admin_context))
|
||||
fake_auth_context=self.admin_context,
|
||||
init_only=('os-simple-tenant-usage',)))
|
||||
self.assertEqual(res.status_int, 200)
|
||||
res_dict = jsonutils.loads(res.body)
|
||||
return res_dict['tenant_usages']
|
||||
@@ -174,7 +180,8 @@ class SimpleTenantUsageTest(test.TestCase):
|
||||
req.headers["content-type"] = "application/json"
|
||||
|
||||
res = req.get_response(fakes.wsgi_app(
|
||||
fake_auth_context=self.user_context))
|
||||
fake_auth_context=self.user_context,
|
||||
init_only=('os-simple-tenant-usage',)))
|
||||
self.assertEqual(res.status_int, 200)
|
||||
res_dict = jsonutils.loads(res.body)
|
||||
|
||||
@@ -208,7 +215,8 @@ class SimpleTenantUsageTest(test.TestCase):
|
||||
|
||||
try:
|
||||
res = req.get_response(fakes.wsgi_app(
|
||||
fake_auth_context=self.alt_user_context))
|
||||
fake_auth_context=self.alt_user_context,
|
||||
init_only=('os-simple-tenant-usage',)))
|
||||
self.assertEqual(res.status_int, 403)
|
||||
finally:
|
||||
policy.reset()
|
||||
|
@@ -100,8 +100,13 @@ class SnapshotApiTest(test.TestCase):
|
||||
self.stubs.Set(volume.api.API, "get_all_snapshots",
|
||||
stub_snapshot_get_all)
|
||||
self.stubs.Set(volume.api.API, "get", fakes.stub_volume_get)
|
||||
self.flags(
|
||||
osapi_compute_extension=[
|
||||
'nova.api.openstack.compute.contrib.select_extensions'],
|
||||
osapi_compute_ext_list=['Volumes'])
|
||||
|
||||
self.context = context.get_admin_context()
|
||||
self.app = fakes.wsgi_app(init_only=('os-snapshots',))
|
||||
|
||||
def test_snapshot_create(self):
|
||||
global _last_param
|
||||
@@ -117,7 +122,7 @@ class SnapshotApiTest(test.TestCase):
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.headers['content-type'] = 'application/json'
|
||||
|
||||
resp = req.get_response(fakes.wsgi_app())
|
||||
resp = req.get_response(self.app)
|
||||
LOG.debug(_("test_snapshot_create: param=%s"), _last_param)
|
||||
self.assertEqual(resp.status_int, 200)
|
||||
|
||||
@@ -148,7 +153,7 @@ class SnapshotApiTest(test.TestCase):
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.headers['content-type'] = 'application/json'
|
||||
|
||||
resp = req.get_response(fakes.wsgi_app())
|
||||
resp = req.get_response(self.app)
|
||||
LOG.debug(_("test_snapshot_create_force: param=%s"), _last_param)
|
||||
self.assertEqual(resp.status_int, 200)
|
||||
|
||||
@@ -174,7 +179,7 @@ class SnapshotApiTest(test.TestCase):
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.headers['content-type'] = 'application/json'
|
||||
|
||||
resp = req.get_response(fakes.wsgi_app())
|
||||
resp = req.get_response(self.app)
|
||||
LOG.debug(_("test_snapshot_create_force: param=%s"), _last_param)
|
||||
self.assertEqual(resp.status_int, 400)
|
||||
|
||||
@@ -186,7 +191,7 @@ class SnapshotApiTest(test.TestCase):
|
||||
req = webob.Request.blank('/v2/fake/os-snapshots/%d' % snapshot_id)
|
||||
req.method = 'DELETE'
|
||||
|
||||
resp = req.get_response(fakes.wsgi_app())
|
||||
resp = req.get_response(self.app)
|
||||
self.assertEqual(resp.status_int, 202)
|
||||
self.assertEqual(str(_last_param['id']), str(snapshot_id))
|
||||
|
||||
@@ -198,7 +203,7 @@ class SnapshotApiTest(test.TestCase):
|
||||
req = webob.Request.blank('/v2/fake/os-snapshots/%d' % snapshot_id)
|
||||
req.method = 'DELETE'
|
||||
|
||||
resp = req.get_response(fakes.wsgi_app())
|
||||
resp = req.get_response(self.app)
|
||||
self.assertEqual(resp.status_int, 404)
|
||||
self.assertEqual(str(_last_param['snapshot_id']), str(snapshot_id))
|
||||
|
||||
@@ -209,7 +214,7 @@ class SnapshotApiTest(test.TestCase):
|
||||
snapshot_id = 123
|
||||
req = webob.Request.blank('/v2/fake/os-snapshots/%d' % snapshot_id)
|
||||
req.method = 'GET'
|
||||
resp = req.get_response(fakes.wsgi_app())
|
||||
resp = req.get_response(self.app)
|
||||
|
||||
LOG.debug(_("test_snapshot_show: resp=%s"), resp)
|
||||
self.assertEqual(resp.status_int, 200)
|
||||
@@ -226,14 +231,14 @@ class SnapshotApiTest(test.TestCase):
|
||||
snapshot_id = 234
|
||||
req = webob.Request.blank('/v2/fake/os-snapshots/%d' % snapshot_id)
|
||||
req.method = 'GET'
|
||||
resp = req.get_response(fakes.wsgi_app())
|
||||
resp = req.get_response(self.app)
|
||||
self.assertEqual(resp.status_int, 404)
|
||||
self.assertEqual(str(_last_param['snapshot_id']), str(snapshot_id))
|
||||
|
||||
def test_snapshot_detail(self):
|
||||
req = webob.Request.blank('/v2/fake/os-snapshots/detail')
|
||||
req.method = 'GET'
|
||||
resp = req.get_response(fakes.wsgi_app())
|
||||
resp = req.get_response(self.app)
|
||||
self.assertEqual(resp.status_int, 200)
|
||||
|
||||
resp_dict = jsonutils.loads(resp.body)
|
||||
|
@@ -47,11 +47,16 @@ class ServerVirtualInterfaceTest(test.TestCase):
|
||||
compute_api_get)
|
||||
self.stubs.Set(network.api.API, "get_vifs_by_instance",
|
||||
get_vifs_by_instance)
|
||||
self.flags(
|
||||
osapi_compute_extension=[
|
||||
'nova.api.openstack.compute.contrib.select_extensions'],
|
||||
osapi_compute_ext_list=['Virtual_interfaces'])
|
||||
|
||||
def test_get_virtual_interfaces_list(self):
|
||||
url = '/v2/fake/servers/abcd/os-virtual-interfaces'
|
||||
req = webob.Request.blank(url)
|
||||
res = req.get_response(fakes.wsgi_app())
|
||||
res = req.get_response(fakes.wsgi_app(
|
||||
init_only=('os-virtual-interfaces',)))
|
||||
self.assertEqual(res.status_int, 200)
|
||||
res_dict = jsonutils.loads(res.body)
|
||||
response = {'virtual_interfaces': [
|
||||
|
@@ -103,6 +103,10 @@ class BootFromVolumeTest(test.TestCase):
|
||||
super(BootFromVolumeTest, self).setUp()
|
||||
self.stubs.Set(compute_api.API, 'create', fake_compute_api_create)
|
||||
fakes.stub_out_nw_api(self.stubs)
|
||||
self.flags(
|
||||
osapi_compute_extension=[
|
||||
'nova.api.openstack.compute.contrib.select_extensions'],
|
||||
osapi_compute_ext_list=['Volumes'])
|
||||
|
||||
def test_create_root_volume(self):
|
||||
body = dict(server=dict(
|
||||
@@ -121,7 +125,8 @@ class BootFromVolumeTest(test.TestCase):
|
||||
req.method = 'POST'
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.headers['content-type'] = 'application/json'
|
||||
res = req.get_response(fakes.wsgi_app())
|
||||
res = req.get_response(fakes.wsgi_app(
|
||||
init_only=('os-volumes_boot', 'servers')))
|
||||
self.assertEqual(res.status_int, 202)
|
||||
server = jsonutils.loads(res.body)['server']
|
||||
self.assertEqual(FAKE_UUID, server['id'])
|
||||
@@ -146,8 +151,13 @@ class VolumeApiTest(test.TestCase):
|
||||
self.stubs.Set(volume_api.API, "delete", fakes.stub_volume_delete)
|
||||
self.stubs.Set(volume_api.API, "get", fakes.stub_volume_get)
|
||||
self.stubs.Set(volume_api.API, "get_all", fakes.stub_volume_get_all)
|
||||
self.flags(
|
||||
osapi_compute_extension=[
|
||||
'nova.api.openstack.compute.contrib.select_extensions'],
|
||||
osapi_compute_ext_list=['Volumes'])
|
||||
|
||||
self.context = context.get_admin_context()
|
||||
self.app = fakes.wsgi_app(init_only=('os-volumes',))
|
||||
|
||||
def test_volume_create(self):
|
||||
self.stubs.Set(volume_api.API, "create", fakes.stub_volume_create)
|
||||
@@ -161,7 +171,7 @@ class VolumeApiTest(test.TestCase):
|
||||
req.method = 'POST'
|
||||
req.body = jsonutils.dumps(body)
|
||||
req.headers['content-type'] = 'application/json'
|
||||
resp = req.get_response(fakes.wsgi_app())
|
||||
resp = req.get_response(self.app)
|
||||
|
||||
self.assertEqual(resp.status_int, 200)
|
||||
|
||||
@@ -178,30 +188,30 @@ class VolumeApiTest(test.TestCase):
|
||||
|
||||
def test_volume_index(self):
|
||||
req = webob.Request.blank('/v2/fake/os-volumes')
|
||||
resp = req.get_response(fakes.wsgi_app())
|
||||
resp = req.get_response(self.app)
|
||||
self.assertEqual(resp.status_int, 200)
|
||||
|
||||
def test_volume_detail(self):
|
||||
req = webob.Request.blank('/v2/fake/os-volumes/detail')
|
||||
resp = req.get_response(fakes.wsgi_app())
|
||||
resp = req.get_response(self.app)
|
||||
self.assertEqual(resp.status_int, 200)
|
||||
|
||||
def test_volume_show(self):
|
||||
req = webob.Request.blank('/v2/fake/os-volumes/123')
|
||||
resp = req.get_response(fakes.wsgi_app())
|
||||
resp = req.get_response(self.app)
|
||||
self.assertEqual(resp.status_int, 200)
|
||||
|
||||
def test_volume_show_no_volume(self):
|
||||
self.stubs.Set(volume_api.API, "get", fakes.stub_volume_get_notfound)
|
||||
|
||||
req = webob.Request.blank('/v2/fake/os-volumes/456')
|
||||
resp = req.get_response(fakes.wsgi_app())
|
||||
resp = req.get_response(self.app)
|
||||
self.assertEqual(resp.status_int, 404)
|
||||
|
||||
def test_volume_delete(self):
|
||||
req = webob.Request.blank('/v2/fake/os-volumes/123')
|
||||
req.method = 'DELETE'
|
||||
resp = req.get_response(fakes.wsgi_app())
|
||||
resp = req.get_response(self.app)
|
||||
self.assertEqual(resp.status_int, 202)
|
||||
|
||||
def test_volume_delete_no_volume(self):
|
||||
@@ -209,7 +219,7 @@ class VolumeApiTest(test.TestCase):
|
||||
|
||||
req = webob.Request.blank('/v2/fake/os-volumes/456')
|
||||
req.method = 'DELETE'
|
||||
resp = req.get_response(fakes.wsgi_app())
|
||||
resp = req.get_response(self.app)
|
||||
self.assertEqual(resp.status_int, 404)
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user