blob: 1eb76a06a2a3af813c2a57dfd212b13ea2565d5f [file] [log] [blame]
Attila Fazekas9fa29472014-08-18 09:48:00 +02001# Copyright 2012 OpenStack Foundation
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
Jordan Pittier1189dd12015-07-09 16:03:56 +020016import testtools
17
Attila Fazekas9fa29472014-08-18 09:48:00 +020018from tempest.api.volume import base
Yaroslav Lobankoved3a35b2016-03-24 22:41:30 -050019from tempest.common import waiters
Jordan Pittier1189dd12015-07-09 16:03:56 +020020from tempest import config
Ken'ichi Ohmichi6b279c72017-01-27 18:26:59 -080021from tempest.lib import decorators
Attila Fazekas9fa29472014-08-18 09:48:00 +020022
Jordan Pittier1189dd12015-07-09 16:03:56 +020023CONF = config.CONF
24
Attila Fazekas9fa29472014-08-18 09:48:00 +020025
Ken'ichi Ohmichie8afb8c2017-03-27 11:25:37 -070026class VolumesExtendTest(base.BaseVolumeTest):
Attila Fazekas9fa29472014-08-18 09:48:00 +020027
Ken'ichi Ohmichi6b279c72017-01-27 18:26:59 -080028 @decorators.idempotent_id('9a36df71-a257-43a5-9555-dc7c88e66e0e')
Attila Fazekas9fa29472014-08-18 09:48:00 +020029 def test_volume_extend(self):
30 # Extend Volume Test.
zhufl7a8f29d2017-02-17 10:16:45 +080031 volume = self.create_volume()
Avi Avrahamd77d3d12017-02-15 16:45:25 +020032 extend_size = volume['size'] + 1
zhufl7a8f29d2017-02-17 10:16:45 +080033 self.volumes_client.extend_volume(volume['id'],
lkuchlanb21fc572016-11-28 12:25:22 +020034 new_size=extend_size)
lkuchlan52d7b0d2016-11-07 20:53:19 +020035 waiters.wait_for_volume_resource_status(self.volumes_client,
36 volume['id'], 'available')
zhufl7a8f29d2017-02-17 10:16:45 +080037 volume = self.volumes_client.show_volume(volume['id'])['volume']
Avi Avrahamd77d3d12017-02-15 16:45:25 +020038 self.assertEqual(volume['size'], extend_size)
Jordan Pittier1189dd12015-07-09 16:03:56 +020039
40 @decorators.idempotent_id('86be1cba-2640-11e5-9c82-635fb964c912')
41 @testtools.skipUnless(CONF.volume_feature_enabled.snapshot,
42 "Cinder volume snapshots are disabled")
Matt Riedemann0fe1c032017-05-05 09:31:07 -040043 @decorators.skip_because(bug='1687044')
Jordan Pittier1189dd12015-07-09 16:03:56 +020044 def test_volume_extend_when_volume_has_snapshot(self):
45 volume = self.create_volume()
46 self.create_snapshot(volume['id'])
47
48 extend_size = volume['size'] + 1
49 self.volumes_client.extend_volume(volume['id'], new_size=extend_size)
50
51 waiters.wait_for_volume_resource_status(self.volumes_client,
52 volume['id'], 'available')
53 resized_volume = self.volumes_client.show_volume(
54 volume['id'])['volume']
55 self.assertEqual(extend_size, resized_volume['size'])