ZhiQiang Fan | 39f9722 | 2013-09-20 04:49:44 +0800 | [diff] [blame] | 1 | # Copyright 2012 OpenStack Foundation |
Jay Pipes | 13b479b | 2012-06-11 14:52:27 -0400 | [diff] [blame] | 2 | # All Rights Reserved. |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 5 | # not use this file except in compliance with the License. You may obtain |
| 6 | # a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 12 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 13 | # License for the specific language governing permissions and limitations |
| 14 | # under the License. |
| 15 | |
Matthew Treinish | 96e9e88 | 2014-06-09 18:37:19 -0400 | [diff] [blame] | 16 | from testtools import matchers |
| 17 | |
Sean Dague | 1937d09 | 2013-05-17 16:36:38 -0400 | [diff] [blame] | 18 | from tempest.api.compute import base |
Matthew Treinish | bc0e03e | 2014-01-30 16:51:06 +0000 | [diff] [blame] | 19 | from tempest import config |
Ken'ichi Ohmichi | 757833a | 2017-03-10 10:30:30 -0800 | [diff] [blame] | 20 | from tempest.lib.common.utils import data_utils |
Ken'ichi Ohmichi | 6c92edf | 2017-01-27 17:32:10 -0800 | [diff] [blame] | 21 | from tempest.lib import decorators |
Matthew Treinish | 96e9e88 | 2014-06-09 18:37:19 -0400 | [diff] [blame] | 22 | |
rajalakshmi-ganesan | d3b43f6 | 2012-04-03 17:39:23 +0530 | [diff] [blame] | 23 | |
Matthew Treinish | bc0e03e | 2014-01-30 16:51:06 +0000 | [diff] [blame] | 24 | CONF = config.CONF |
| 25 | |
rajalakshmi-ganesan | d3b43f6 | 2012-04-03 17:39:23 +0530 | [diff] [blame] | 26 | |
ivan-zhu | f2b0050 | 2013-10-18 10:06:52 +0800 | [diff] [blame] | 27 | class VolumesGetTestJSON(base.BaseV2ComputeTest): |
Attila Fazekas | 19044d5 | 2013-02-16 07:35:06 +0100 | [diff] [blame] | 28 | |
Felipe Monteiro | a40e9b7 | 2017-05-05 17:47:10 +0100 | [diff] [blame] | 29 | # These tests will fail with a 404 starting from microversion 2.36. For |
| 30 | # more information, see: |
Andreas Jaeger | bf30ae7 | 2019-07-22 19:22:57 +0200 | [diff] [blame] | 31 | # https://docs.openstack.org/api-ref/compute/#volume-extension-os-volumes-os-snapshots-deprecated |
Felipe Monteiro | a40e9b7 | 2017-05-05 17:47:10 +0100 | [diff] [blame] | 32 | max_microversion = '2.35' |
| 33 | |
Attila Fazekas | 19044d5 | 2013-02-16 07:35:06 +0100 | [diff] [blame] | 34 | @classmethod |
Emily Hugenbruch | 8284a34 | 2014-12-11 22:04:55 +0000 | [diff] [blame] | 35 | def skip_checks(cls): |
| 36 | super(VolumesGetTestJSON, cls).skip_checks() |
Matthew Treinish | bc0e03e | 2014-01-30 16:51:06 +0000 | [diff] [blame] | 37 | if not CONF.service_available.cinder: |
Matthew Treinish | 4c41292 | 2013-07-16 15:27:42 -0400 | [diff] [blame] | 38 | skip_msg = ("%s skipped as Cinder is not available" % cls.__name__) |
| 39 | raise cls.skipException(skip_msg) |
rajalakshmi-ganesan | d3b43f6 | 2012-04-03 17:39:23 +0530 | [diff] [blame] | 40 | |
Emily Hugenbruch | 8284a34 | 2014-12-11 22:04:55 +0000 | [diff] [blame] | 41 | @classmethod |
| 42 | def setup_clients(cls): |
| 43 | super(VolumesGetTestJSON, cls).setup_clients() |
lkuchlan | 85e5952 | 2017-05-25 12:18:03 +0300 | [diff] [blame] | 44 | cls.volumes_client = cls.volumes_extensions_client |
Emily Hugenbruch | 8284a34 | 2014-12-11 22:04:55 +0000 | [diff] [blame] | 45 | |
Ken'ichi Ohmichi | 6c92edf | 2017-01-27 17:32:10 -0800 | [diff] [blame] | 46 | @decorators.idempotent_id('f10f25eb-9775-4d9d-9cbe-1cf54dae9d5f') |
rajalakshmi-ganesan | d3b43f6 | 2012-04-03 17:39:23 +0530 | [diff] [blame] | 47 | def test_volume_create_get_delete(self): |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 48 | # CREATE, GET, DELETE Volume |
zhufl | c6ce539 | 2016-08-17 14:34:37 +0800 | [diff] [blame] | 49 | v_name = data_utils.rand_name(self.__class__.__name__ + '-Volume') |
Matthew Treinish | a2a8218 | 2013-06-19 17:03:04 -0400 | [diff] [blame] | 50 | metadata = {'Type': 'work'} |
Attila Fazekas | f7f34f9 | 2013-08-01 17:01:44 +0200 | [diff] [blame] | 51 | # Create volume |
lkuchlan | 85e5952 | 2017-05-25 12:18:03 +0300 | [diff] [blame] | 52 | volume = self.create_volume(size=CONF.volume.volume_size, |
| 53 | display_name=v_name, |
| 54 | metadata=metadata) |
Matthew Treinish | a2a8218 | 2013-06-19 17:03:04 -0400 | [diff] [blame] | 55 | self.assertEqual(volume['displayName'], v_name, |
| 56 | "The created volume name is not equal " |
| 57 | "to the requested name") |
Attila Fazekas | f7f34f9 | 2013-08-01 17:01:44 +0200 | [diff] [blame] | 58 | # GET Volume |
lkuchlan | 85e5952 | 2017-05-25 12:18:03 +0300 | [diff] [blame] | 59 | fetched_volume = self.volumes_client.show_volume( |
| 60 | volume['id'])['volume'] |
nayna-patel | c07f77d | 2014-01-15 12:39:25 +0000 | [diff] [blame] | 61 | # Verification of details of fetched Volume |
Matthew Treinish | a2a8218 | 2013-06-19 17:03:04 -0400 | [diff] [blame] | 62 | self.assertEqual(v_name, |
| 63 | fetched_volume['displayName'], |
| 64 | 'The fetched Volume is different ' |
| 65 | 'from the created Volume') |
guo yunxian | c53b8cc | 2016-08-10 20:36:52 +0800 | [diff] [blame] | 66 | self.assertEqual(CONF.volume.volume_size, |
| 67 | fetched_volume['size'], |
| 68 | 'The fetched volume size is different ' |
| 69 | 'from the created Volume') |
Matthew Treinish | a2a8218 | 2013-06-19 17:03:04 -0400 | [diff] [blame] | 70 | self.assertEqual(volume['id'], |
| 71 | fetched_volume['id'], |
| 72 | 'The fetched Volume is different ' |
| 73 | 'from the created Volume') |
Jerry Cai | c3c49ad | 2014-01-10 15:38:45 +0800 | [diff] [blame] | 74 | self.assertThat(fetched_volume['metadata'].items(), |
Masayuki Igawa | 209fd50 | 2014-02-17 14:46:43 +0900 | [diff] [blame] | 75 | matchers.ContainsAll(metadata.items()), |
Jerry Cai | c3c49ad | 2014-01-10 15:38:45 +0800 | [diff] [blame] | 76 | 'The fetched Volume metadata misses data ' |
| 77 | 'from the created Volume') |