From ee03e48bc600ff462b5d8256ee5391c6687efae3 Mon Sep 17 00:00:00 2001 From: Tzanetos Balitsaris Date: Wed, 13 Aug 2014 17:11:58 +0300 Subject: [PATCH] Fix semantic validation of context images In the semantic validation of the images context it was assumed that the parameter users is a dictionary that contains the key endpoint, whereas users is a list of Clients objects. This was leading to a validation error and any benchmark scenario that had in its configuration file this context was failing. Closes-Bug: 1356336 Change-Id: I6452a47975cd3adcd31ec7b7c4ca0159aec8776f --- rally-scenarios/rally.yaml | 18 +++++++++++++++++ rally/benchmark/context/images.py | 3 +-- tests/benchmark/context/test_images.py | 27 +++++++------------------- 3 files changed, 26 insertions(+), 22 deletions(-) diff --git a/rally-scenarios/rally.yaml b/rally-scenarios/rally.yaml index cbf499c28c..0ff03942c8 100644 --- a/rally-scenarios/rally.yaml +++ b/rally-scenarios/rally.yaml @@ -642,6 +642,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: diff --git a/rally/benchmark/context/images.py b/rally/benchmark/context/images.py index 68d2dff903..d1527b1a3c 100644 --- a/rally/benchmark/context/images.py +++ b/rally/benchmark/context/images.py @@ -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 = _( diff --git a/tests/benchmark/context/test_images.py b/tests/benchmark/context/test_images.py index e08ac23570..0f137a52d6 100644 --- a/tests/benchmark/context/test_images.py +++ b/tests/benchmark/context/test_images.py @@ -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)