Merge "Fix semantic validation of context images"

This commit is contained in:
Jenkins 2014-08-18 03:50:46 +00:00 committed by Gerrit Code Review
commit 382a4b2b7b
3 changed files with 26 additions and 22 deletions

View File

@ -615,6 +615,24 @@
sla: sla:
max_failure_percent: 0 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: NovaServers.boot_and_delete_server:
- -
args: args:

View File

@ -104,9 +104,8 @@ class ImageGenerator(base.Context):
@classmethod @classmethod
def validate_semantic(cls, config, admin, users, task): def validate_semantic(cls, config, admin, users, task):
"""Check if the image service is available.""" """Check if the image service is available."""
try: try:
glance = osclients.Clients(users[0]["endpoint"]).glance() glance = users[0].glance()
list(glance.images.list(limit=0)) list(glance.images.list(limit=0))
except Exception as e: except Exception as e:
message = _( message = _(

View File

@ -141,26 +141,13 @@ class ImageGeneratorTestCase(test.TestCase):
mock_image_remover.side_effect = Exception('failed_deletion') mock_image_remover.side_effect = Exception('failed_deletion')
self.assertRaises(exceptions.ImageCleanUpException, images_ctx.cleanup) self.assertRaises(exceptions.ImageCleanUpException, images_ctx.cleanup)
@mock.patch("%s.images.osclients" % CTX) def test_validate_semantic(self):
def test_validate_semantic(self, mock_osclients): users = [fakes.FakeClients()]
user_key = [{'id': i, 'tenant_id': j, 'endpoint': 'endpoint'} images.ImageGenerator.validate_semantic(None, None, users, None)
for j in range(2)
for i in range(5)]
fc = fakes.FakeClients() @mock.patch("%s.images.osclients.Clients.glance" % CTX)
mock_osclients.Clients.return_value = fc def test_validate_semantic_unavailabe(self, mock_glance):
images.ImageGenerator.validate_semantic(None, None, mock_glance.side_effect = Exception("list error")
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')
self.assertRaises(exceptions.InvalidScenarioArgument, self.assertRaises(exceptions.InvalidScenarioArgument,
images.ImageGenerator.validate_semantic, None, None, images.ImageGenerator.validate_semantic, None, None,
user_key, None) None, None)