Permit using latest python-cinderclient
Fix a number of unit tests so that they will work with the latest cinderclient, which will be released by the end of Kilo. The problem was that several horizon unit tests made calls into python-cinderclient that should have been stubbed out (but were not). These calls silently did nothing in the released python-cinderclient due to a "feature" where certain GET functions would return an empty list when the auth url was an empty string, instead of returning an auth failure. Recent changes in the python-cinderclient authorization functions closed this hole, which then revealed problems in the horizon unit tests: 1) several tests were lacking stubs to cinder calls, and 2) the auth url in test of cinderclient v2 was empty due to a missing dictionary entry in test_data/keystone_data.py Change-Id: I33967a924f4e47009fdc1613248afd1bd377f34f Closes-Bug: 1423425 Co-Authored-By: Richard Hagarty <richard.hagarty@hp.com>
This commit is contained in:
parent
e26232633d
commit
dca7117fdf
@ -180,13 +180,20 @@ class AggregatesViewTests(test.BaseAdminViewTests):
|
||||
|
||||
@mock.patch('openstack_dashboard.api.nova.extension_supported',
|
||||
mock.Mock(return_value=False))
|
||||
@test.create_stubs({api.nova: ('aggregate_details_list',
|
||||
'availability_zone_list',),
|
||||
api.cinder: ('tenant_absolute_limits',)})
|
||||
def test_panel_not_available(self):
|
||||
api.cinder.tenant_absolute_limits(IsA(http.HttpRequest)). \
|
||||
MultipleTimes().AndReturn(self.cinder_limits['absolute'])
|
||||
self.mox.ReplayAll()
|
||||
|
||||
self.patchers['aggregates'].stop()
|
||||
res = self.client.get(reverse('horizon:admin:overview:index'))
|
||||
self.assertNotIn('Host Aggregates', res.content)
|
||||
|
||||
@test.create_stubs({api.nova: ('aggregate_details_list',
|
||||
'availability_zone_list',), })
|
||||
'availability_zone_list',)})
|
||||
def test_index(self):
|
||||
api.nova.aggregate_details_list(IsA(http.HttpRequest)) \
|
||||
.AndReturn(self.aggregates.list())
|
||||
|
@ -64,6 +64,7 @@ class SystemInfoViewTests(test.BaseAdminViewTests):
|
||||
services_tab._tables['services'].data,
|
||||
['<Service: compute>',
|
||||
'<Service: volume>',
|
||||
'<Service: volumev2>',
|
||||
'<Service: image>',
|
||||
'<Service: identity (native backend)>',
|
||||
'<Service: object-store>',
|
||||
|
@ -25,11 +25,14 @@ from openstack_dashboard.test import helpers as test
|
||||
|
||||
class VolumeTests(test.BaseAdminViewTests):
|
||||
@test.create_stubs({api.nova: ('server_list',),
|
||||
cinder: ('volume_list',),
|
||||
cinder: ('volume_list',
|
||||
'volume_snapshot_list'),
|
||||
keystone: ('tenant_list',)})
|
||||
def test_index(self):
|
||||
cinder.volume_list(IsA(http.HttpRequest), search_opts={
|
||||
'all_tenants': True}).AndReturn(self.cinder_volumes.list())
|
||||
cinder.volume_snapshot_list(IsA(http.HttpRequest), search_opts={
|
||||
'all_tenants': True}).AndReturn([])
|
||||
api.nova.server_list(IsA(http.HttpRequest), search_opts={
|
||||
'all_tenants': True}) \
|
||||
.AndReturn([self.servers.list(), False])
|
||||
|
@ -65,6 +65,7 @@ class QosSpecsTests(test.BaseAdminViewTests):
|
||||
self.assertMessageCount(success=1)
|
||||
|
||||
@test.create_stubs({api.cinder: ('volume_type_list_with_qos_associations',
|
||||
'volume_encryption_type_list',
|
||||
'qos_spec_list',
|
||||
'qos_spec_delete',)})
|
||||
def test_delete_qos_spec(self):
|
||||
@ -74,6 +75,8 @@ class QosSpecsTests(test.BaseAdminViewTests):
|
||||
api.cinder.volume_type_list_with_qos_associations(
|
||||
IsA(http.HttpRequest)).\
|
||||
AndReturn(self.volume_types.list())
|
||||
api.cinder.volume_encryption_type_list(IsA(http.HttpRequest))\
|
||||
.AndReturn(self.cinder_volume_encryption_types.list()[0:1])
|
||||
api.cinder.qos_spec_list(IsA(http.HttpRequest)).\
|
||||
AndReturn(self.cinder_qos_specs.list())
|
||||
api.cinder.qos_spec_delete(IsA(http.HttpRequest),
|
||||
|
@ -82,10 +82,17 @@ class DataProcessingNodeGroupTests(test.TestCase):
|
||||
@test.create_stubs({api.sahara: ('nodegroup_template_get',
|
||||
'plugin_get_version_details'),
|
||||
api.network: ('floating_ip_pools_list',
|
||||
'security_group_list')})
|
||||
'security_group_list'),
|
||||
api.cinder: ('extension_supported',
|
||||
'availability_zone_list')})
|
||||
def test_copy(self):
|
||||
ngt = self.nodegroup_templates.first()
|
||||
configs = self.plugins_configs.first()
|
||||
api.cinder.extension_supported(IsA(http.HttpRequest),
|
||||
'AvailabilityZones') \
|
||||
.AndReturn(True)
|
||||
api.cinder.availability_zone_list(IsA(http.HttpRequest))\
|
||||
.AndReturn(self.availability_zones.list())
|
||||
api.sahara.nodegroup_template_get(IsA(http.HttpRequest),
|
||||
ngt.id) \
|
||||
.AndReturn(ngt)
|
||||
@ -114,7 +121,9 @@ class DataProcessingNodeGroupTests(test.TestCase):
|
||||
'plugin_get_version_details'),
|
||||
api.network: ('floating_ip_pools_list',
|
||||
'security_group_list'),
|
||||
api.nova: ('flavor_list',)})
|
||||
api.nova: ('flavor_list',),
|
||||
api.cinder: ('extension_supported',
|
||||
'availability_zone_list')})
|
||||
def test_create(self):
|
||||
flavor = self.flavors.first()
|
||||
ngt = self.nodegroup_templates.first()
|
||||
@ -123,6 +132,11 @@ class DataProcessingNodeGroupTests(test.TestCase):
|
||||
self.mox.StubOutWithMock(
|
||||
workflow_helpers, 'parse_configs_from_context')
|
||||
|
||||
api.cinder.extension_supported(IsA(http.HttpRequest),
|
||||
'AvailabilityZones') \
|
||||
.AndReturn(True)
|
||||
api.cinder.availability_zone_list(IsA(http.HttpRequest))\
|
||||
.AndReturn(self.availability_zones.list())
|
||||
api.nova.flavor_list(IsA(http.HttpRequest)).AndReturn([flavor])
|
||||
api.sahara.plugin_get_version_details(IsA(http.HttpRequest),
|
||||
ngt.plugin_name,
|
||||
|
@ -805,6 +805,7 @@ class VolumeViewTests(test.TestCase):
|
||||
|
||||
@test.create_stubs({cinder: ('tenant_absolute_limits',
|
||||
'volume_list',
|
||||
'volume_snapshot_list',
|
||||
'volume_backup_supported',
|
||||
'volume_delete',),
|
||||
api.nova: ('server_list',)})
|
||||
@ -818,11 +819,17 @@ class VolumeViewTests(test.TestCase):
|
||||
MultipleTimes().AndReturn(True)
|
||||
cinder.volume_list(IsA(http.HttpRequest), search_opts=None).\
|
||||
AndReturn(volumes)
|
||||
cinder.volume_snapshot_list(IsA(http.HttpRequest),
|
||||
search_opts=None).\
|
||||
AndReturn([])
|
||||
cinder.volume_delete(IsA(http.HttpRequest), volume.id)
|
||||
api.nova.server_list(IsA(http.HttpRequest), search_opts=None).\
|
||||
AndReturn([self.servers.list(), False])
|
||||
cinder.volume_list(IsA(http.HttpRequest), search_opts=None).\
|
||||
AndReturn(volumes)
|
||||
cinder.volume_snapshot_list(IsA(http.HttpRequest),
|
||||
search_opts=None).\
|
||||
AndReturn([])
|
||||
api.nova.server_list(IsA(http.HttpRequest), search_opts=None).\
|
||||
AndReturn([self.servers.list(), False])
|
||||
cinder.tenant_absolute_limits(IsA(http.HttpRequest)).MultipleTimes().\
|
||||
@ -996,6 +1003,7 @@ class VolumeViewTests(test.TestCase):
|
||||
|
||||
@test.create_stubs({cinder: ('tenant_absolute_limits',
|
||||
'volume_list',
|
||||
'volume_snapshot_list',
|
||||
'volume_backup_supported',),
|
||||
api.nova: ('server_list',)})
|
||||
def test_create_button_disabled_when_quota_exceeded(self):
|
||||
@ -1007,6 +1015,9 @@ class VolumeViewTests(test.TestCase):
|
||||
MultipleTimes().AndReturn(True)
|
||||
cinder.volume_list(IsA(http.HttpRequest), search_opts=None)\
|
||||
.AndReturn(volumes)
|
||||
cinder.volume_snapshot_list(IsA(http.HttpRequest),
|
||||
search_opts=None).\
|
||||
AndReturn([])
|
||||
api.nova.server_list(IsA(http.HttpRequest), search_opts=None)\
|
||||
.AndReturn([self.servers.list(), False])
|
||||
cinder.tenant_absolute_limits(IsA(http.HttpRequest))\
|
||||
@ -1431,6 +1442,7 @@ class VolumeViewTests(test.TestCase):
|
||||
self._test_encryption(True)
|
||||
|
||||
@test.create_stubs({cinder: ('volume_list',
|
||||
'volume_snapshot_list',
|
||||
'volume_backup_supported',
|
||||
'tenant_absolute_limits'),
|
||||
api.nova: ('server_list',)})
|
||||
@ -1444,6 +1456,9 @@ class VolumeViewTests(test.TestCase):
|
||||
.MultipleTimes('backup_supported').AndReturn(False)
|
||||
cinder.volume_list(IsA(http.HttpRequest), search_opts=None)\
|
||||
.AndReturn(self.volumes.list())
|
||||
cinder.volume_snapshot_list(IsA(http.HttpRequest),
|
||||
search_opts=None).\
|
||||
AndReturn(self.cinder_volume_snapshots.list())
|
||||
api.nova.server_list(IsA(http.HttpRequest), search_opts=None)\
|
||||
.AndReturn([self.servers.list(), False])
|
||||
cinder.tenant_absolute_limits(IsA(http.HttpRequest))\
|
||||
@ -1492,6 +1507,7 @@ class VolumeViewTests(test.TestCase):
|
||||
|
||||
@test.create_stubs({cinder: ('volume_backup_supported',
|
||||
'volume_list',
|
||||
'volume_snapshot_list',
|
||||
'tenant_absolute_limits'),
|
||||
api.nova: ('server_list',)})
|
||||
def test_create_transfer_availability(self):
|
||||
@ -1501,6 +1517,9 @@ class VolumeViewTests(test.TestCase):
|
||||
.MultipleTimes().AndReturn(False)
|
||||
cinder.volume_list(IsA(http.HttpRequest), search_opts=None)\
|
||||
.AndReturn(self.volumes.list())
|
||||
cinder.volume_snapshot_list(IsA(http.HttpRequest),
|
||||
search_opts=None).\
|
||||
AndReturn([])
|
||||
api.nova.server_list(IsA(http.HttpRequest), search_opts=None)\
|
||||
.AndReturn([self.servers.list(), False])
|
||||
cinder.tenant_absolute_limits(IsA(http.HttpRequest))\
|
||||
@ -1540,6 +1559,7 @@ class VolumeViewTests(test.TestCase):
|
||||
|
||||
@test.create_stubs({cinder: ('volume_backup_supported',
|
||||
'volume_list',
|
||||
'volume_snapshot_list',
|
||||
'transfer_delete',
|
||||
'tenant_absolute_limits'),
|
||||
api.nova: ('server_list',)})
|
||||
@ -1560,6 +1580,9 @@ class VolumeViewTests(test.TestCase):
|
||||
.MultipleTimes().AndReturn(False)
|
||||
cinder.volume_list(IsA(http.HttpRequest), search_opts=None)\
|
||||
.AndReturn(volumes)
|
||||
cinder.volume_snapshot_list(IsA(http.HttpRequest),
|
||||
search_opts=None).\
|
||||
AndReturn([])
|
||||
cinder.transfer_delete(IsA(http.HttpRequest), transfer.id)
|
||||
api.nova.server_list(IsA(http.HttpRequest), search_opts=None).\
|
||||
AndReturn([self.servers.list(), False])
|
||||
|
@ -60,6 +60,18 @@ SERVICE_CATALOG = [
|
||||
"adminURL": "http://admin.nova.example.com:8776/v1",
|
||||
"internalURL": "http://int.nova.example.com:8776/v1",
|
||||
"publicURL": "http://public.nova.example.com:8776/v1"}]},
|
||||
{"type": "volumev2",
|
||||
"name": "cinderv2",
|
||||
"endpoints_links": [],
|
||||
"endpoints": [
|
||||
{"region": "RegionOne",
|
||||
"adminURL": "http://admin.nova.example.com:8776/v2",
|
||||
"internalURL": "http://int.nova.example.com:8776/v2",
|
||||
"publicURL": "http://public.nova.example.com:8776/v2"},
|
||||
{"region": "RegionTwo",
|
||||
"adminURL": "http://admin.nova.example.com:8776/v2",
|
||||
"internalURL": "http://int.nova.example.com:8776/v2",
|
||||
"publicURL": "http://public.nova.example.com:8776/v2"}]},
|
||||
{"type": "image",
|
||||
"name": "glance",
|
||||
"endpoints_links": [],
|
||||
|
Loading…
Reference in New Issue
Block a user