blob: 0d23c1f08931f243263b88a1466c28a882bf44b6 [file] [log] [blame]
ZhiQiang Fan39f97222013-09-20 04:49:44 +08001# Copyright 2012 OpenStack Foundation
Jay Pipes13b479b2012-06-11 14:52:27 -04002# 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 Treinish96e9e882014-06-09 18:37:19 -040016from testtools import matchers
17
Sean Dague1937d092013-05-17 16:36:38 -040018from tempest.api.compute import base
Matthew Treinishbc0e03e2014-01-30 16:51:06 +000019from tempest import config
Ken'ichi Ohmichi757833a2017-03-10 10:30:30 -080020from tempest.lib.common.utils import data_utils
Ken'ichi Ohmichi6c92edf2017-01-27 17:32:10 -080021from tempest.lib import decorators
Matthew Treinish96e9e882014-06-09 18:37:19 -040022
rajalakshmi-ganesand3b43f62012-04-03 17:39:23 +053023
Matthew Treinishbc0e03e2014-01-30 16:51:06 +000024CONF = config.CONF
25
rajalakshmi-ganesand3b43f62012-04-03 17:39:23 +053026
ivan-zhuf2b00502013-10-18 10:06:52 +080027class VolumesGetTestJSON(base.BaseV2ComputeTest):
Attila Fazekas19044d52013-02-16 07:35:06 +010028
Felipe Monteiroa40e9b72017-05-05 17:47:10 +010029 # These tests will fail with a 404 starting from microversion 2.36. For
30 # more information, see:
Andreas Jaegerbf30ae72019-07-22 19:22:57 +020031 # https://docs.openstack.org/api-ref/compute/#volume-extension-os-volumes-os-snapshots-deprecated
Felipe Monteiroa40e9b72017-05-05 17:47:10 +010032 max_microversion = '2.35'
33
Attila Fazekas19044d52013-02-16 07:35:06 +010034 @classmethod
Emily Hugenbruch8284a342014-12-11 22:04:55 +000035 def skip_checks(cls):
36 super(VolumesGetTestJSON, cls).skip_checks()
Matthew Treinishbc0e03e2014-01-30 16:51:06 +000037 if not CONF.service_available.cinder:
Matthew Treinish4c412922013-07-16 15:27:42 -040038 skip_msg = ("%s skipped as Cinder is not available" % cls.__name__)
39 raise cls.skipException(skip_msg)
rajalakshmi-ganesand3b43f62012-04-03 17:39:23 +053040
Emily Hugenbruch8284a342014-12-11 22:04:55 +000041 @classmethod
42 def setup_clients(cls):
43 super(VolumesGetTestJSON, cls).setup_clients()
lkuchlan85e59522017-05-25 12:18:03 +030044 cls.volumes_client = cls.volumes_extensions_client
Emily Hugenbruch8284a342014-12-11 22:04:55 +000045
Ken'ichi Ohmichi6c92edf2017-01-27 17:32:10 -080046 @decorators.idempotent_id('f10f25eb-9775-4d9d-9cbe-1cf54dae9d5f')
rajalakshmi-ganesand3b43f62012-04-03 17:39:23 +053047 def test_volume_create_get_delete(self):
Sean Dague4dd2c0b2013-01-03 17:50:28 -050048 # CREATE, GET, DELETE Volume
zhuflc6ce5392016-08-17 14:34:37 +080049 v_name = data_utils.rand_name(self.__class__.__name__ + '-Volume')
Matthew Treinisha2a82182013-06-19 17:03:04 -040050 metadata = {'Type': 'work'}
Attila Fazekasf7f34f92013-08-01 17:01:44 +020051 # Create volume
lkuchlan85e59522017-05-25 12:18:03 +030052 volume = self.create_volume(size=CONF.volume.volume_size,
53 display_name=v_name,
54 metadata=metadata)
Matthew Treinisha2a82182013-06-19 17:03:04 -040055 self.assertEqual(volume['displayName'], v_name,
56 "The created volume name is not equal "
57 "to the requested name")
Attila Fazekasf7f34f92013-08-01 17:01:44 +020058 # GET Volume
lkuchlan85e59522017-05-25 12:18:03 +030059 fetched_volume = self.volumes_client.show_volume(
60 volume['id'])['volume']
nayna-patelc07f77d2014-01-15 12:39:25 +000061 # Verification of details of fetched Volume
Matthew Treinisha2a82182013-06-19 17:03:04 -040062 self.assertEqual(v_name,
63 fetched_volume['displayName'],
64 'The fetched Volume is different '
65 'from the created Volume')
guo yunxianc53b8cc2016-08-10 20:36:52 +080066 self.assertEqual(CONF.volume.volume_size,
67 fetched_volume['size'],
68 'The fetched volume size is different '
69 'from the created Volume')
Matthew Treinisha2a82182013-06-19 17:03:04 -040070 self.assertEqual(volume['id'],
71 fetched_volume['id'],
72 'The fetched Volume is different '
73 'from the created Volume')
Jerry Caic3c49ad2014-01-10 15:38:45 +080074 self.assertThat(fetched_volume['metadata'].items(),
Masayuki Igawa209fd502014-02-17 14:46:43 +090075 matchers.ContainsAll(metadata.items()),
Jerry Caic3c49ad2014-01-10 15:38:45 +080076 'The fetched Volume metadata misses data '
77 'from the created Volume')