blob: 990900b76e9efacecf30c61b60af3549d1e34c6e [file] [log] [blame]
wanghaoaa1f2f92013-10-10 11:30:37 +08001# Copyright 2013 Huawei Technologies Co.,LTD
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
Zhi Kun Liubb363a22013-11-28 18:47:39 +080016from tempest.api.volume import base
Ken'ichi Ohmichi6b279c72017-01-27 18:26:59 -080017from tempest.lib import decorators
wanghaoaa1f2f92013-10-10 11:30:37 +080018
19
Chandan Kumar457d1632014-11-18 13:46:08 +053020class VolumesActionsV2Test(base.BaseVolumeAdminTest):
wanghaoaa1f2f92013-10-10 11:30:37 +080021
wanghao9d3d6cb2013-11-12 15:10:10 +080022 def _create_reset_and_force_delete_temp_volume(self, status=None):
23 # Create volume, reset volume status, and force delete temp volume
zhufl89403442016-10-09 16:19:28 +080024 temp_volume = self.create_volume()
wanghao9d3d6cb2013-11-12 15:10:10 +080025 if status:
zhufl7e75fcb2016-10-17 09:00:40 +080026 self.admin_volume_client.reset_volume_status(
27 temp_volume['id'], status=status)
Joseph Lanoux6809bab2014-12-18 14:57:18 +000028 self.admin_volume_client.force_delete_volume(temp_volume['id'])
lkuchlanb21fc572016-11-28 12:25:22 +020029 self.volumes_client.wait_for_resource_deletion(temp_volume['id'])
wanghao9d3d6cb2013-11-12 15:10:10 +080030
Ken'ichi Ohmichi6b279c72017-01-27 18:26:59 -080031 @decorators.idempotent_id('d063f96e-a2e0-4f34-8b8a-395c42de1845')
wanghaoaa1f2f92013-10-10 11:30:37 +080032 def test_volume_reset_status(self):
33 # test volume reset status : available->error->available
zhufl7a682fe2016-12-15 17:20:00 +080034 volume = self.create_volume()
Benny Kopilovba37ac42017-03-26 13:25:04 +030035 self.addCleanup(self.admin_volume_client.reset_volume_status,
36 volume['id'], status='available')
37 for status in ['error', 'available', 'maintenance']:
zhufl7a682fe2016-12-15 17:20:00 +080038 self.admin_volume_client.reset_volume_status(
39 volume['id'], status=status)
40 volume_get = self.admin_volume_client.show_volume(
41 volume['id'])['volume']
42 self.assertEqual(status, volume_get['status'])
wanghaoaa1f2f92013-10-10 11:30:37 +080043
Ken'ichi Ohmichi6b279c72017-01-27 18:26:59 -080044 @decorators.idempotent_id('21737d5a-92f2-46d7-b009-a0cc0ee7a570')
wanghao9d3d6cb2013-11-12 15:10:10 +080045 def test_volume_force_delete_when_volume_is_creating(self):
46 # test force delete when status of volume is creating
47 self._create_reset_and_force_delete_temp_volume('creating')
48
Ken'ichi Ohmichi6b279c72017-01-27 18:26:59 -080049 @decorators.idempotent_id('db8d607a-aa2e-4beb-b51d-d4005c232011')
wanghao9d3d6cb2013-11-12 15:10:10 +080050 def test_volume_force_delete_when_volume_is_attaching(self):
51 # test force delete when status of volume is attaching
52 self._create_reset_and_force_delete_temp_volume('attaching')
53
Ken'ichi Ohmichi6b279c72017-01-27 18:26:59 -080054 @decorators.idempotent_id('3e33a8a8-afd4-4d64-a86b-c27a185c5a4a')
wanghao9d3d6cb2013-11-12 15:10:10 +080055 def test_volume_force_delete_when_volume_is_error(self):
56 # test force delete when status of volume is error
57 self._create_reset_and_force_delete_temp_volume('error')