Fix Glance v1 update call

Glance v1 takes the image ID as a positional argument, and errors out
if you try to pass it in as a keyword arg.

Change-Id: I60619b5ff965853ed4d44900d697e22fd4a0d7af
This commit is contained in:
Chris St. Pierre 2017-08-28 15:55:02 -05:00 committed by Andrey Kurilin
parent e63f221952
commit a4fe6622e1
3 changed files with 37 additions and 27 deletions

View File

@ -1,4 +1,5 @@
---
{%- set cirros_image_url = "http://download.cirros-cloud.net/0.3.5/cirros-0.3.5-x86_64-disk.img" %}
{%- set keystone_version = keystone_version|default("v2.0") %}
{% if keystone_version == "v2.0" %}
@ -835,3 +836,24 @@
sla:
failure_rate:
max: 100
GlanceImages.create_and_update_image:
-
args:
image_location: "{{ cirros_image_url }}"
container_format: "bare"
disk_format: "qcow2"
runner:
type: "constant"
times: 4
concurrency: 2
context:
users:
tenants: 2
users_per_tenant: 2
api_versions:
glance:
version: 1
sla:
failure_rate:
max: 100

View File

@ -93,7 +93,7 @@ class GlanceV1Service(service.Service, glance_common.GlanceMixin):
"""
image_name = image_name or self.generate_random_name()
return self._clients.glance("1").images.update(image_id=image_id,
return self._clients.glance("1").images.update(image_id,
name=image_name,
min_disk=min_disk,
min_ram=min_ram)

View File

@ -78,36 +78,24 @@ class GlanceV1ServiceTestCase(test.TestCase):
self.gc.images.create.assert_called_once_with(**call_args)
self.assertEqual(image, self.mock_wait_for_status.mock.return_value)
def test_update_image(self):
@ddt.data({"image_name": None},
{"image_name": "test_image_name"})
@ddt.unpack
def test_update_image(self, image_name):
image_id = "image_id"
image_name1 = self.name_generator.return_value
image_name2 = "image_name"
min_disk = 0
min_ram = 0
expected_image_name = image_name or self.name_generator.return_value
# case: image_name is None:
call_args1 = {"image_id": image_id,
"name": image_name1,
"min_disk": min_disk,
"min_ram": min_ram}
image1 = self.service.update_image(image_id=image_id,
image_name=None,
min_disk=min_disk,
min_ram=min_ram)
self.assertEqual(self.gc.images.update.return_value, image1)
self.gc.images.update.assert_called_once_with(**call_args1)
# case: image_name is not None:
call_args2 = {"image_id": image_id,
"name": image_name2,
"min_disk": min_disk,
"min_ram": min_ram}
image2 = self.service.update_image(image_id=image_id,
image_name=image_name2,
min_disk=min_disk,
min_ram=min_ram)
self.assertEqual(self.gc.images.update.return_value, image2)
self.gc.images.update.assert_called_with(**call_args2)
image = self.service.update_image(image_id=image_id,
image_name=image_name,
min_disk=min_disk,
min_ram=min_ram)
self.assertEqual(self.gc.images.update.return_value, image)
self.gc.images.update.assert_called_once_with(image_id,
name=expected_image_name,
min_disk=min_disk,
min_ram=min_ram)
@ddt.data({"status": "activate", "is_public": True, "owner": "owner"},
{"status": "activate", "is_public": False, "owner": "owner"},