diff --git a/rally-scenarios/rally.yaml b/rally-scenarios/rally.yaml index 91ed7d5b09..01d46529e8 100644 --- a/rally-scenarios/rally.yaml +++ b/rally-scenarios/rally.yaml @@ -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: 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)