blob: 6fd2a5ea28318912d566bbce0c78b767d868e2e8 [file] [log] [blame]
Giulio Fidente74b08ad2014-01-18 04:02:51 +01001# Copyright 2014 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
Doug Hellmann583ce2c2015-03-11 14:55:46 +000016from oslo_log import log as logging
Matthew Treinish01472ff2015-02-20 17:26:52 -050017from tempest_lib.common.utils import data_utils
18
Masayuki Igawa1edf94f2014-03-04 18:34:16 +090019from tempest.api.volume import base
Giulio Fidente74b08ad2014-01-18 04:02:51 +010020from tempest import config
Giulio Fidente74b08ad2014-01-18 04:02:51 +010021from tempest import test
22
23CONF = config.CONF
24LOG = logging.getLogger(__name__)
25
26
jun xieebc3da32014-11-18 14:34:56 +080027class VolumesBackupsV2Test(base.BaseVolumeAdminTest):
Giulio Fidente74b08ad2014-01-18 04:02:51 +010028
29 @classmethod
Rohan Kanade05749152015-01-30 17:15:18 +053030 def skip_checks(cls):
31 super(VolumesBackupsV2Test, cls).skip_checks()
Giulio Fidente74b08ad2014-01-18 04:02:51 +010032 if not CONF.volume_feature_enabled.backup:
33 raise cls.skipException("Cinder backup feature disabled")
34
Rohan Kanade05749152015-01-30 17:15:18 +053035 @classmethod
36 def resource_setup(cls):
37 super(VolumesBackupsV2Test, cls).resource_setup()
38
Giulio Fidente74b08ad2014-01-18 04:02:51 +010039 cls.volume = cls.create_volume()
40
41 @test.attr(type='smoke')
Chris Hoge7579c1a2015-02-26 14:12:15 -080042 @test.idempotent_id('a66eb488-8ee1-47d4-8e9f-575a095728c6')
raiesmh08f04da342014-02-28 17:14:43 +053043 def test_volume_backup_create_get_detailed_list_restore_delete(self):
44 # Create backup
Giulio Fidente74b08ad2014-01-18 04:02:51 +010045 backup_name = data_utils.rand_name('Backup')
46 create_backup = self.backups_adm_client.create_backup
Joseph Lanoux6809bab2014-12-18 14:57:18 +000047 backup = create_backup(self.volume['id'],
48 name=backup_name)
Giulio Fidente74b08ad2014-01-18 04:02:51 +010049 self.addCleanup(self.backups_adm_client.delete_backup,
50 backup['id'])
raiesmh08f04da342014-02-28 17:14:43 +053051 self.assertEqual(backup_name, backup['name'])
Chandan Kumaree3f4bd2014-10-29 23:09:29 +053052 self.admin_volume_client.wait_for_volume_status(
53 self.volume['id'], 'available')
Giulio Fidente74b08ad2014-01-18 04:02:51 +010054 self.backups_adm_client.wait_for_backup_status(backup['id'],
55 'available')
56
raiesmh08f04da342014-02-28 17:14:43 +053057 # Get a given backup
Joseph Lanoux6809bab2014-12-18 14:57:18 +000058 backup = self.backups_adm_client.get_backup(backup['id'])
raiesmh08f04da342014-02-28 17:14:43 +053059 self.assertEqual(backup_name, backup['name'])
Giulio Fidente74b08ad2014-01-18 04:02:51 +010060
raiesmh08f04da342014-02-28 17:14:43 +053061 # Get all backups with detail
Joseph Lanoux6809bab2014-12-18 14:57:18 +000062 backups = self.backups_adm_client.list_backups_with_detail()
raiesmh08f04da342014-02-28 17:14:43 +053063 self.assertIn((backup['name'], backup['id']),
64 [(m['name'], m['id']) for m in backups])
65
66 # Restore backup
Joseph Lanoux6809bab2014-12-18 14:57:18 +000067 restore = self.backups_adm_client.restore_backup(backup['id'])
raiesmh08f04da342014-02-28 17:14:43 +053068
69 # Delete backup
Chandan Kumaree3f4bd2014-10-29 23:09:29 +053070 self.addCleanup(self.admin_volume_client.delete_volume,
Giulio Fidente74b08ad2014-01-18 04:02:51 +010071 restore['volume_id'])
raiesmh08f04da342014-02-28 17:14:43 +053072 self.assertEqual(backup['id'], restore['backup_id'])
Giulio Fidente74b08ad2014-01-18 04:02:51 +010073 self.backups_adm_client.wait_for_backup_status(backup['id'],
74 'available')
Chandan Kumaree3f4bd2014-10-29 23:09:29 +053075 self.admin_volume_client.wait_for_volume_status(
76 restore['volume_id'], 'available')
jun xieebc3da32014-11-18 14:34:56 +080077
78
79class VolumesBackupsV1Test(VolumesBackupsV2Test):
80 _api_version = 1