Merge "Fix semantic validation of context images"
This commit is contained in:
commit
382a4b2b7b
@ -615,6 +615,24 @@
|
||||
sla:
|
||||
max_failure_percent: 0
|
||||
|
||||
GlanceImages.list_images:
|
||||
-
|
||||
runner:
|
||||
type: "constant"
|
||||
times: 5
|
||||
concurrency: 5
|
||||
context:
|
||||
users:
|
||||
tenants: 2
|
||||
users_per_tenant: 2
|
||||
images:
|
||||
image_url: "http://download.cirros-cloud.net/0.3.1/cirros-0.3.1-x86_64-disk.img"
|
||||
image_type: "qcow2"
|
||||
image_container: "bare"
|
||||
images_per_tenant: 2
|
||||
sla:
|
||||
max_failure_percent: 0
|
||||
|
||||
NovaServers.boot_and_delete_server:
|
||||
-
|
||||
args:
|
||||
|
@ -104,9 +104,8 @@ class ImageGenerator(base.Context):
|
||||
@classmethod
|
||||
def validate_semantic(cls, config, admin, users, task):
|
||||
"""Check if the image service is available."""
|
||||
|
||||
try:
|
||||
glance = osclients.Clients(users[0]["endpoint"]).glance()
|
||||
glance = users[0].glance()
|
||||
list(glance.images.list(limit=0))
|
||||
except Exception as e:
|
||||
message = _(
|
||||
|
@ -141,26 +141,13 @@ class ImageGeneratorTestCase(test.TestCase):
|
||||
mock_image_remover.side_effect = Exception('failed_deletion')
|
||||
self.assertRaises(exceptions.ImageCleanUpException, images_ctx.cleanup)
|
||||
|
||||
@mock.patch("%s.images.osclients" % CTX)
|
||||
def test_validate_semantic(self, mock_osclients):
|
||||
user_key = [{'id': i, 'tenant_id': j, 'endpoint': 'endpoint'}
|
||||
for j in range(2)
|
||||
for i in range(5)]
|
||||
def test_validate_semantic(self):
|
||||
users = [fakes.FakeClients()]
|
||||
images.ImageGenerator.validate_semantic(None, None, users, None)
|
||||
|
||||
fc = fakes.FakeClients()
|
||||
mock_osclients.Clients.return_value = fc
|
||||
images.ImageGenerator.validate_semantic(None, None,
|
||||
user_key, None)
|
||||
|
||||
@mock.patch("%s.images.osclients" % CTX)
|
||||
def test_validate_semantic_unavailabe(self, mock_osclients):
|
||||
user_key = [{'id': i, 'tenant_id': j, 'endpoint': 'endpoint'}
|
||||
for j in range(2)
|
||||
for i in range(5)]
|
||||
|
||||
endpoint = mock.MagicMock()
|
||||
(mock_osclients.Clients(endpoint).glance().images.list.
|
||||
side_effect) = Exception('list_error')
|
||||
@mock.patch("%s.images.osclients.Clients.glance" % CTX)
|
||||
def test_validate_semantic_unavailabe(self, mock_glance):
|
||||
mock_glance.side_effect = Exception("list error")
|
||||
self.assertRaises(exceptions.InvalidScenarioArgument,
|
||||
images.ImageGenerator.validate_semantic, None, None,
|
||||
user_key, None)
|
||||
None, None)
|
||||
|
Loading…
Reference in New Issue
Block a user