Skip to content

Commit

Permalink
Fix semantic validation of context images
Browse files Browse the repository at this point in the history
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
  • Loading branch information
tzabal committed Aug 17, 2014
1 parent 103d7cc commit ee03e48
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 22 deletions.
18 changes: 18 additions & 0 deletions rally-scenarios/rally.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 1 addition & 2 deletions rally/benchmark/context/images.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,8 @@ def cleanup(self):
@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 = _(
Expand Down
27 changes: 7 additions & 20 deletions tests/benchmark/context/test_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,26 +141,13 @@ def test_cleanup(self, mock_image_remover, mock_osclients):
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)]

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)]
def test_validate_semantic(self):
users = [fakes.FakeClients()]
images.ImageGenerator.validate_semantic(None, None, users, None)

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)

0 comments on commit ee03e48

Please sign in to comment.