ZhiQiang Fan | 39f9722 | 2013-09-20 04:49:44 +0800 | [diff] [blame] | 1 | # Copyright 2013 OpenStack Foundation |
Hoisaleshwara Madan V S | 7cba108 | 2013-11-26 12:43:04 +0530 | [diff] [blame] | 2 | # Copyright 2013 IBM Corp |
Matthew Treinish | a62347f | 2013-03-01 16:37:30 -0500 | [diff] [blame] | 3 | # All Rights Reserved. |
Matthew Treinish | a62347f | 2013-03-01 16:37:30 -0500 | [diff] [blame] | 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 6 | # not use this file except in compliance with the License. You may obtain |
| 7 | # a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 13 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 14 | # License for the specific language governing permissions and limitations |
| 15 | # under the License. |
| 16 | |
Matthew Treinish | a62347f | 2013-03-01 16:37:30 -0500 | [diff] [blame] | 17 | import random |
| 18 | |
Matthew Treinish | b0c65f2 | 2015-04-23 09:09:41 -0400 | [diff] [blame] | 19 | from six import moves |
Matthew Treinish | 01472ff | 2015-02-20 17:26:52 -0500 | [diff] [blame] | 20 | |
Takashi NATSUME | 12a4851 | 2015-08-10 18:33:16 +0900 | [diff] [blame] | 21 | from oslo_log import log as logging |
Sean Dague | 1937d09 | 2013-05-17 16:36:38 -0400 | [diff] [blame] | 22 | from tempest.api.image import base |
Fei Long Wang | d39431f | 2015-05-14 11:30:48 +1200 | [diff] [blame] | 23 | from tempest.common.utils import data_utils |
Takashi NATSUME | 12a4851 | 2015-08-10 18:33:16 +0900 | [diff] [blame] | 24 | from tempest import config |
Eiichi Aikawa | 9012f46 | 2014-03-05 16:43:32 +0900 | [diff] [blame] | 25 | from tempest import test |
Matthew Treinish | a62347f | 2013-03-01 16:37:30 -0500 | [diff] [blame] | 26 | |
Takashi NATSUME | 12a4851 | 2015-08-10 18:33:16 +0900 | [diff] [blame] | 27 | CONF = config.CONF |
| 28 | LOG = logging.getLogger(__name__) |
| 29 | |
Matthew Treinish | a62347f | 2013-03-01 16:37:30 -0500 | [diff] [blame] | 30 | |
Hoisaleshwara Madan V S | 7cba108 | 2013-11-26 12:43:04 +0530 | [diff] [blame] | 31 | class BasicOperationsImagesTest(base.BaseV2ImageTest): |
Ken'ichi Ohmichi | 9e3dac0 | 2015-11-19 07:01:07 +0000 | [diff] [blame] | 32 | """Here we test the basic operations of images""" |
Matthew Treinish | a62347f | 2013-03-01 16:37:30 -0500 | [diff] [blame] | 33 | |
Sean Dague | 0a08c7e | 2015-04-30 08:37:02 -0400 | [diff] [blame] | 34 | @test.attr(type='smoke') |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 35 | @test.idempotent_id('139b765e-7f3d-4b3d-8b37-3ca3876ee318') |
Hoisaleshwara Madan V S | e50a6f1 | 2013-10-23 18:01:01 +0530 | [diff] [blame] | 36 | def test_register_upload_get_image_file(self): |
Ken'ichi Ohmichi | 9e3dac0 | 2015-11-19 07:01:07 +0000 | [diff] [blame] | 37 | """Here we test these functionalities |
Hoisaleshwara Madan V S | e50a6f1 | 2013-10-23 18:01:01 +0530 | [diff] [blame] | 38 | |
Ken'ichi Ohmichi | 9e3dac0 | 2015-11-19 07:01:07 +0000 | [diff] [blame] | 39 | Register image, upload the image file, get image and get image |
| 40 | file api's |
Hoisaleshwara Madan V S | e50a6f1 | 2013-10-23 18:01:01 +0530 | [diff] [blame] | 41 | """ |
| 42 | |
Sean Dague | c6ec476 | 2014-05-29 08:54:21 -0400 | [diff] [blame] | 43 | uuid = '00000000-1111-2222-3333-444455556666' |
Hoisaleshwara Madan V S | e50a6f1 | 2013-10-23 18:01:01 +0530 | [diff] [blame] | 44 | image_name = data_utils.rand_name('image') |
Takashi NATSUME | 12a4851 | 2015-08-10 18:33:16 +0900 | [diff] [blame] | 45 | container_format = CONF.image.container_formats[0] |
| 46 | disk_format = CONF.image.disk_formats[0] |
David Kranz | 34f1878 | 2015-01-06 13:43:55 -0500 | [diff] [blame] | 47 | body = self.create_image(name=image_name, |
Takashi NATSUME | 12a4851 | 2015-08-10 18:33:16 +0900 | [diff] [blame] | 48 | container_format=container_format, |
| 49 | disk_format=disk_format, |
David Kranz | 34f1878 | 2015-01-06 13:43:55 -0500 | [diff] [blame] | 50 | visibility='private', |
| 51 | ramdisk_id=uuid) |
Attila Fazekas | e191cb1 | 2013-07-29 06:41:52 +0200 | [diff] [blame] | 52 | self.assertIn('id', body) |
Matthew Treinish | a62347f | 2013-03-01 16:37:30 -0500 | [diff] [blame] | 53 | image_id = body.get('id') |
Attila Fazekas | e191cb1 | 2013-07-29 06:41:52 +0200 | [diff] [blame] | 54 | self.assertIn('name', body) |
Hoisaleshwara Madan V S | e50a6f1 | 2013-10-23 18:01:01 +0530 | [diff] [blame] | 55 | self.assertEqual(image_name, body['name']) |
Attila Fazekas | e191cb1 | 2013-07-29 06:41:52 +0200 | [diff] [blame] | 56 | self.assertIn('visibility', body) |
Aaron Rosen | c772062 | 2014-05-20 10:38:10 -0700 | [diff] [blame] | 57 | self.assertEqual('private', body['visibility']) |
Attila Fazekas | e191cb1 | 2013-07-29 06:41:52 +0200 | [diff] [blame] | 58 | self.assertIn('status', body) |
Hoisaleshwara Madan V S | e50a6f1 | 2013-10-23 18:01:01 +0530 | [diff] [blame] | 59 | self.assertEqual('queued', body['status']) |
Matthew Treinish | a62347f | 2013-03-01 16:37:30 -0500 | [diff] [blame] | 60 | |
| 61 | # Now try uploading an image file |
Mark Washenberger | 5c3b6fe | 2014-07-29 13:40:34 -0700 | [diff] [blame] | 62 | file_content = data_utils.random_bytes() |
Matthew Treinish | b0c65f2 | 2015-04-23 09:09:41 -0400 | [diff] [blame] | 63 | image_file = moves.cStringIO(file_content) |
Ken'ichi Ohmichi | 66494e9 | 2015-06-08 04:28:10 +0000 | [diff] [blame] | 64 | self.client.store_image_file(image_id, image_file) |
Hoisaleshwara Madan V S | e50a6f1 | 2013-10-23 18:01:01 +0530 | [diff] [blame] | 65 | |
| 66 | # Now try to get image details |
Ken'ichi Ohmichi | 5d41076 | 2015-05-22 01:10:03 +0000 | [diff] [blame] | 67 | body = self.client.show_image(image_id) |
Hoisaleshwara Madan V S | e50a6f1 | 2013-10-23 18:01:01 +0530 | [diff] [blame] | 68 | self.assertEqual(image_id, body['id']) |
| 69 | self.assertEqual(image_name, body['name']) |
Sean Dague | c6ec476 | 2014-05-29 08:54:21 -0400 | [diff] [blame] | 70 | self.assertEqual(uuid, body['ramdisk_id']) |
Attila Fazekas | e191cb1 | 2013-07-29 06:41:52 +0200 | [diff] [blame] | 71 | self.assertIn('size', body) |
Matthew Treinish | a62347f | 2013-03-01 16:37:30 -0500 | [diff] [blame] | 72 | self.assertEqual(1024, body.get('size')) |
| 73 | |
Hoisaleshwara Madan V S | e50a6f1 | 2013-10-23 18:01:01 +0530 | [diff] [blame] | 74 | # Now try get image file |
Ken'ichi Ohmichi | 6bd6f20 | 2015-11-20 05:29:38 +0000 | [diff] [blame] | 75 | body = self.client.show_image_file(image_id) |
David Kranz | d7e97b4 | 2015-02-16 09:37:31 -0500 | [diff] [blame] | 76 | self.assertEqual(file_content, body.data) |
Hoisaleshwara Madan V S | e50a6f1 | 2013-10-23 18:01:01 +0530 | [diff] [blame] | 77 | |
Sean Dague | 0a08c7e | 2015-04-30 08:37:02 -0400 | [diff] [blame] | 78 | @test.attr(type='smoke') |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 79 | @test.idempotent_id('f848bb94-1c6e-45a4-8726-39e3a5b23535') |
Hoisaleshwara Madan V S | 7cba108 | 2013-11-26 12:43:04 +0530 | [diff] [blame] | 80 | def test_delete_image(self): |
Sergey Nikitin | c6b2ee8 | 2014-02-03 17:13:50 +0400 | [diff] [blame] | 81 | # Deletes an image by image_id |
Hoisaleshwara Madan V S | 7cba108 | 2013-11-26 12:43:04 +0530 | [diff] [blame] | 82 | |
| 83 | # Create image |
| 84 | image_name = data_utils.rand_name('image') |
Takashi NATSUME | 12a4851 | 2015-08-10 18:33:16 +0900 | [diff] [blame] | 85 | container_format = CONF.image.container_formats[0] |
| 86 | disk_format = CONF.image.disk_formats[0] |
David Kranz | 34f1878 | 2015-01-06 13:43:55 -0500 | [diff] [blame] | 87 | body = self.client.create_image(name=image_name, |
Takashi NATSUME | 12a4851 | 2015-08-10 18:33:16 +0900 | [diff] [blame] | 88 | container_format=container_format, |
| 89 | disk_format=disk_format, |
David Kranz | 34f1878 | 2015-01-06 13:43:55 -0500 | [diff] [blame] | 90 | visibility='private') |
Hoisaleshwara Madan V S | 7cba108 | 2013-11-26 12:43:04 +0530 | [diff] [blame] | 91 | image_id = body['id'] |
| 92 | |
| 93 | # Delete Image |
| 94 | self.client.delete_image(image_id) |
| 95 | self.client.wait_for_resource_deletion(image_id) |
| 96 | |
| 97 | # Verifying deletion |
John Warren | f3b3e95 | 2015-08-17 19:28:12 +0000 | [diff] [blame] | 98 | images = self.client.list_images()['images'] |
Sunil G | 29856a3 | 2014-07-17 23:17:58 +0530 | [diff] [blame] | 99 | images_id = [item['id'] for item in images] |
| 100 | self.assertNotIn(image_id, images_id) |
Hoisaleshwara Madan V S | 7cba108 | 2013-11-26 12:43:04 +0530 | [diff] [blame] | 101 | |
Sean Dague | 0a08c7e | 2015-04-30 08:37:02 -0400 | [diff] [blame] | 102 | @test.attr(type='smoke') |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 103 | @test.idempotent_id('f66891a7-a35c-41a8-b590-a065c2a1caa6') |
Sergey Nikitin | c6b2ee8 | 2014-02-03 17:13:50 +0400 | [diff] [blame] | 104 | def test_update_image(self): |
| 105 | # Updates an image by image_id |
| 106 | |
| 107 | # Create image |
| 108 | image_name = data_utils.rand_name('image') |
Takashi NATSUME | 12a4851 | 2015-08-10 18:33:16 +0900 | [diff] [blame] | 109 | container_format = CONF.image.container_formats[0] |
| 110 | disk_format = CONF.image.disk_formats[0] |
David Kranz | 34f1878 | 2015-01-06 13:43:55 -0500 | [diff] [blame] | 111 | body = self.client.create_image(name=image_name, |
Takashi NATSUME | 12a4851 | 2015-08-10 18:33:16 +0900 | [diff] [blame] | 112 | container_format=container_format, |
| 113 | disk_format=disk_format, |
David Kranz | 34f1878 | 2015-01-06 13:43:55 -0500 | [diff] [blame] | 114 | visibility='private') |
Masayuki Igawa | 930ac37 | 2014-03-11 18:50:26 +0900 | [diff] [blame] | 115 | self.addCleanup(self.client.delete_image, body['id']) |
Sergey Nikitin | c6b2ee8 | 2014-02-03 17:13:50 +0400 | [diff] [blame] | 116 | self.assertEqual('queued', body['status']) |
| 117 | image_id = body['id'] |
| 118 | |
| 119 | # Now try uploading an image file |
Matthew Treinish | b0c65f2 | 2015-04-23 09:09:41 -0400 | [diff] [blame] | 120 | image_file = moves.cStringIO(data_utils.random_bytes()) |
Ken'ichi Ohmichi | 66494e9 | 2015-06-08 04:28:10 +0000 | [diff] [blame] | 121 | self.client.store_image_file(image_id, image_file) |
Sergey Nikitin | c6b2ee8 | 2014-02-03 17:13:50 +0400 | [diff] [blame] | 122 | |
| 123 | # Update Image |
| 124 | new_image_name = data_utils.rand_name('new-image') |
David Kranz | 34f1878 | 2015-01-06 13:43:55 -0500 | [diff] [blame] | 125 | body = self.client.update_image(image_id, [ |
Aaron Rosen | c772062 | 2014-05-20 10:38:10 -0700 | [diff] [blame] | 126 | dict(replace='/name', value=new_image_name)]) |
Sergey Nikitin | c6b2ee8 | 2014-02-03 17:13:50 +0400 | [diff] [blame] | 127 | |
Sergey Nikitin | c6b2ee8 | 2014-02-03 17:13:50 +0400 | [diff] [blame] | 128 | # Verifying updating |
| 129 | |
Ken'ichi Ohmichi | 5d41076 | 2015-05-22 01:10:03 +0000 | [diff] [blame] | 130 | body = self.client.show_image(image_id) |
Sergey Nikitin | c6b2ee8 | 2014-02-03 17:13:50 +0400 | [diff] [blame] | 131 | self.assertEqual(image_id, body['id']) |
| 132 | self.assertEqual(new_image_name, body['name']) |
Sergey Nikitin | c6b2ee8 | 2014-02-03 17:13:50 +0400 | [diff] [blame] | 133 | |
Matthew Treinish | a62347f | 2013-03-01 16:37:30 -0500 | [diff] [blame] | 134 | |
Matthew Treinish | ce3ef92 | 2013-03-11 14:02:46 -0400 | [diff] [blame] | 135 | class ListImagesTest(base.BaseV2ImageTest): |
Ken'ichi Ohmichi | 9e3dac0 | 2015-11-19 07:01:07 +0000 | [diff] [blame] | 136 | """Here we test the listing of image information""" |
Matthew Treinish | a62347f | 2013-03-01 16:37:30 -0500 | [diff] [blame] | 137 | |
| 138 | @classmethod |
Andrea Frittoli | 69a6b63 | 2014-09-15 13:14:53 +0100 | [diff] [blame] | 139 | def resource_setup(cls): |
| 140 | super(ListImagesTest, cls).resource_setup() |
Matthew Treinish | a62347f | 2013-03-01 16:37:30 -0500 | [diff] [blame] | 141 | # We add a few images here to test the listing functionality of |
| 142 | # the images API |
Takashi NATSUME | 12a4851 | 2015-08-10 18:33:16 +0900 | [diff] [blame] | 143 | container_fmts = CONF.image.container_formats |
| 144 | disk_fmts = CONF.image.disk_formats |
| 145 | all_pairs = [(container_fmt, disk_fmt) |
| 146 | for container_fmt in container_fmts |
| 147 | for disk_fmt in disk_fmts] |
| 148 | |
| 149 | for (container_fmt, disk_fmt) in all_pairs[:6]: |
| 150 | LOG.debug("Creating a image" |
| 151 | "(Container format: %s, Disk format: %s).", |
| 152 | container_fmt, disk_fmt) |
| 153 | cls._create_standard_image(container_fmt, disk_fmt) |
Matthew Treinish | a62347f | 2013-03-01 16:37:30 -0500 | [diff] [blame] | 154 | |
| 155 | @classmethod |
Abhijeet Malawade | f268d8e | 2013-09-17 06:20:23 -0700 | [diff] [blame] | 156 | def _create_standard_image(cls, container_format, disk_format): |
Ken'ichi Ohmichi | 9e3dac0 | 2015-11-19 07:01:07 +0000 | [diff] [blame] | 157 | """Create a new standard image and return the newly-registered image-id |
| 158 | |
| 159 | Note that the size of the new image is a random number between |
Matthew Treinish | a62347f | 2013-03-01 16:37:30 -0500 | [diff] [blame] | 160 | 1024 and 4096 |
| 161 | """ |
Mark Washenberger | 5c3b6fe | 2014-07-29 13:40:34 -0700 | [diff] [blame] | 162 | size = random.randint(1024, 4096) |
Matthew Treinish | b0c65f2 | 2015-04-23 09:09:41 -0400 | [diff] [blame] | 163 | image_file = moves.cStringIO(data_utils.random_bytes(size)) |
Ken'ichi Ohmichi | d3906c9 | 2015-03-23 00:26:11 +0000 | [diff] [blame] | 164 | name = data_utils.rand_name('image') |
David Kranz | 34f1878 | 2015-01-06 13:43:55 -0500 | [diff] [blame] | 165 | body = cls.create_image(name=name, |
| 166 | container_format=container_format, |
| 167 | disk_format=disk_format, |
| 168 | visibility='private') |
Matthew Treinish | a62347f | 2013-03-01 16:37:30 -0500 | [diff] [blame] | 169 | image_id = body['id'] |
Ken'ichi Ohmichi | 66494e9 | 2015-06-08 04:28:10 +0000 | [diff] [blame] | 170 | cls.client.store_image_file(image_id, data=image_file) |
Matthew Treinish | a62347f | 2013-03-01 16:37:30 -0500 | [diff] [blame] | 171 | |
| 172 | return image_id |
| 173 | |
Abhijeet Malawade | f268d8e | 2013-09-17 06:20:23 -0700 | [diff] [blame] | 174 | def _list_by_param_value_and_assert(self, params): |
Ken'ichi Ohmichi | 9e3dac0 | 2015-11-19 07:01:07 +0000 | [diff] [blame] | 175 | """Perform list action with given params and validates result.""" |
| 176 | |
John Warren | f3b3e95 | 2015-08-17 19:28:12 +0000 | [diff] [blame] | 177 | images_list = self.client.list_images(params=params)['images'] |
Abhijeet Malawade | f268d8e | 2013-09-17 06:20:23 -0700 | [diff] [blame] | 178 | # Validating params of fetched images |
| 179 | for image in images_list: |
| 180 | for key in params: |
| 181 | msg = "Failed to list images by %s" % key |
| 182 | self.assertEqual(params[key], image[key], msg) |
| 183 | |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 184 | @test.idempotent_id('1e341d7a-90a9-494c-b143-2cdf2aeb6aee') |
Flavio Percoco | 7e26be1 | 2015-09-15 22:33:19 +0200 | [diff] [blame] | 185 | def test_list_no_params(self): |
Matthew Treinish | a62347f | 2013-03-01 16:37:30 -0500 | [diff] [blame] | 186 | # Simple test to see all fixture images returned |
John Warren | f3b3e95 | 2015-08-17 19:28:12 +0000 | [diff] [blame] | 187 | images_list = self.client.list_images()['images'] |
Matthew Treinish | a62347f | 2013-03-01 16:37:30 -0500 | [diff] [blame] | 188 | image_list = map(lambda x: x['id'], images_list) |
Abhijeet Malawade | f268d8e | 2013-09-17 06:20:23 -0700 | [diff] [blame] | 189 | |
Matthew Treinish | a62347f | 2013-03-01 16:37:30 -0500 | [diff] [blame] | 190 | for image in self.created_images: |
Attila Fazekas | e191cb1 | 2013-07-29 06:41:52 +0200 | [diff] [blame] | 191 | self.assertIn(image, image_list) |
Abhijeet Malawade | f268d8e | 2013-09-17 06:20:23 -0700 | [diff] [blame] | 192 | |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 193 | @test.idempotent_id('9959ca1d-1aa7-4b7a-a1ea-0fff0499b37e') |
Abhijeet Malawade | f268d8e | 2013-09-17 06:20:23 -0700 | [diff] [blame] | 194 | def test_list_images_param_container_format(self): |
| 195 | # Test to get all images with container_format='bare' |
| 196 | params = {"container_format": "bare"} |
| 197 | self._list_by_param_value_and_assert(params) |
| 198 | |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 199 | @test.idempotent_id('4a4735a7-f22f-49b6-b0d9-66e1ef7453eb') |
Abhijeet Malawade | f268d8e | 2013-09-17 06:20:23 -0700 | [diff] [blame] | 200 | def test_list_images_param_disk_format(self): |
| 201 | # Test to get all images with disk_format = raw |
| 202 | params = {"disk_format": "raw"} |
| 203 | self._list_by_param_value_and_assert(params) |
| 204 | |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 205 | @test.idempotent_id('7a95bb92-d99e-4b12-9718-7bc6ab73e6d2') |
Abhijeet Malawade | f268d8e | 2013-09-17 06:20:23 -0700 | [diff] [blame] | 206 | def test_list_images_param_visibility(self): |
Aaron Rosen | c772062 | 2014-05-20 10:38:10 -0700 | [diff] [blame] | 207 | # Test to get all images with visibility = private |
| 208 | params = {"visibility": "private"} |
Abhijeet Malawade | f268d8e | 2013-09-17 06:20:23 -0700 | [diff] [blame] | 209 | self._list_by_param_value_and_assert(params) |
| 210 | |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 211 | @test.idempotent_id('cf1b9a48-8340-480e-af7b-fe7e17690876') |
Abhijeet Malawade | f268d8e | 2013-09-17 06:20:23 -0700 | [diff] [blame] | 212 | def test_list_images_param_size(self): |
| 213 | # Test to get all images by size |
Takashi NATSUME | 12a4851 | 2015-08-10 18:33:16 +0900 | [diff] [blame] | 214 | image_id = self.created_images[0] |
Abhijeet Malawade | f268d8e | 2013-09-17 06:20:23 -0700 | [diff] [blame] | 215 | # Get image metadata |
Ken'ichi Ohmichi | 5d41076 | 2015-05-22 01:10:03 +0000 | [diff] [blame] | 216 | image = self.client.show_image(image_id) |
Abhijeet Malawade | f268d8e | 2013-09-17 06:20:23 -0700 | [diff] [blame] | 217 | |
| 218 | params = {"size": image['size']} |
| 219 | self._list_by_param_value_and_assert(params) |
| 220 | |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 221 | @test.idempotent_id('4ad8c157-971a-4ba8-aa84-ed61154b1e7f') |
Abhijeet Malawade | f268d8e | 2013-09-17 06:20:23 -0700 | [diff] [blame] | 222 | def test_list_images_param_min_max_size(self): |
| 223 | # Test to get all images with size between 2000 to 3000 |
Takashi NATSUME | 12a4851 | 2015-08-10 18:33:16 +0900 | [diff] [blame] | 224 | image_id = self.created_images[0] |
Abhijeet Malawade | f268d8e | 2013-09-17 06:20:23 -0700 | [diff] [blame] | 225 | # Get image metadata |
Ken'ichi Ohmichi | 5d41076 | 2015-05-22 01:10:03 +0000 | [diff] [blame] | 226 | image = self.client.show_image(image_id) |
Abhijeet Malawade | f268d8e | 2013-09-17 06:20:23 -0700 | [diff] [blame] | 227 | |
| 228 | size = image['size'] |
| 229 | params = {"size_min": size - 500, "size_max": size + 500} |
John Warren | f3b3e95 | 2015-08-17 19:28:12 +0000 | [diff] [blame] | 230 | images_list = self.client.list_images(params=params)['images'] |
Abhijeet Malawade | f268d8e | 2013-09-17 06:20:23 -0700 | [diff] [blame] | 231 | image_size_list = map(lambda x: x['size'], images_list) |
| 232 | |
| 233 | for image_size in image_size_list: |
| 234 | self.assertTrue(image_size >= params['size_min'] and |
| 235 | image_size <= params['size_max'], |
| 236 | "Failed to get images by size_min and size_max") |
| 237 | |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 238 | @test.idempotent_id('7fc9e369-0f58-4d05-9aa5-0969e2d59d15') |
Abhijeet Malawade | f268d8e | 2013-09-17 06:20:23 -0700 | [diff] [blame] | 239 | def test_list_images_param_status(self): |
Anju Tiwari | ca2249d | 2014-01-23 17:33:02 +0530 | [diff] [blame] | 240 | # Test to get all active images |
| 241 | params = {"status": "active"} |
Abhijeet Malawade | f268d8e | 2013-09-17 06:20:23 -0700 | [diff] [blame] | 242 | self._list_by_param_value_and_assert(params) |
| 243 | |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 244 | @test.idempotent_id('e914a891-3cc8-4b40-ad32-e0a39ffbddbb') |
Abhijeet Malawade | f268d8e | 2013-09-17 06:20:23 -0700 | [diff] [blame] | 245 | def test_list_images_param_limit(self): |
| 246 | # Test to get images by limit |
Takashi NATSUME | 12a4851 | 2015-08-10 18:33:16 +0900 | [diff] [blame] | 247 | params = {"limit": 1} |
John Warren | f3b3e95 | 2015-08-17 19:28:12 +0000 | [diff] [blame] | 248 | images_list = self.client.list_images(params=params)['images'] |
Abhijeet Malawade | f268d8e | 2013-09-17 06:20:23 -0700 | [diff] [blame] | 249 | |
| 250 | self.assertEqual(len(images_list), params['limit'], |
| 251 | "Failed to get images by limit") |
raiesmh08 | a1ce354 | 2014-03-04 11:58:29 +0530 | [diff] [blame] | 252 | |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 253 | @test.idempotent_id('622b925c-479f-4736-860d-adeaf13bc371') |
raiesmh08 | a1ce354 | 2014-03-04 11:58:29 +0530 | [diff] [blame] | 254 | def test_get_image_schema(self): |
| 255 | # Test to get image schema |
| 256 | schema = "image" |
Ken'ichi Ohmichi | 66494e9 | 2015-06-08 04:28:10 +0000 | [diff] [blame] | 257 | body = self.client.show_schema(schema) |
raiesmh08 | a1ce354 | 2014-03-04 11:58:29 +0530 | [diff] [blame] | 258 | self.assertEqual("image", body['name']) |
| 259 | |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 260 | @test.idempotent_id('25c8d7b2-df21-460f-87ac-93130bcdc684') |
raiesmh08 | a1ce354 | 2014-03-04 11:58:29 +0530 | [diff] [blame] | 261 | def test_get_images_schema(self): |
| 262 | # Test to get images schema |
| 263 | schema = "images" |
Ken'ichi Ohmichi | 66494e9 | 2015-06-08 04:28:10 +0000 | [diff] [blame] | 264 | body = self.client.show_schema(schema) |
raiesmh08 | a1ce354 | 2014-03-04 11:58:29 +0530 | [diff] [blame] | 265 | self.assertEqual("images", body['name']) |