Giulio Fidente | 74b08ad | 2014-01-18 04:02:51 +0100 | [diff] [blame] | 1 | # 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 | |
| 16 | from tempest.api.volume.base import BaseVolumeV1AdminTest |
| 17 | from tempest.common.utils import data_utils |
| 18 | from tempest import config |
| 19 | from tempest.openstack.common import log as logging |
| 20 | from tempest import test |
| 21 | |
| 22 | CONF = config.CONF |
| 23 | LOG = logging.getLogger(__name__) |
| 24 | |
| 25 | |
| 26 | class VolumesBackupsTest(BaseVolumeV1AdminTest): |
| 27 | _interface = "json" |
| 28 | |
| 29 | @classmethod |
| 30 | def setUpClass(cls): |
| 31 | super(VolumesBackupsTest, cls).setUpClass() |
| 32 | |
| 33 | if not CONF.volume_feature_enabled.backup: |
| 34 | raise cls.skipException("Cinder backup feature disabled") |
| 35 | |
| 36 | cls.volumes_adm_client = cls.os_adm.volumes_client |
| 37 | cls.backups_adm_client = cls.os_adm.backups_client |
| 38 | cls.volume = cls.create_volume() |
| 39 | |
| 40 | @test.attr(type='smoke') |
| 41 | def test_volume_backup_create_get_restore_delete(self): |
| 42 | backup_name = data_utils.rand_name('Backup') |
| 43 | create_backup = self.backups_adm_client.create_backup |
| 44 | resp, backup = create_backup(self.volume['id'], |
| 45 | name=backup_name) |
| 46 | self.assertEqual(202, resp.status) |
| 47 | self.addCleanup(self.backups_adm_client.delete_backup, |
| 48 | backup['id']) |
| 49 | self.assertEqual(backup['name'], backup_name) |
| 50 | self.volumes_adm_client.wait_for_volume_status(self.volume['id'], |
| 51 | 'available') |
| 52 | self.backups_adm_client.wait_for_backup_status(backup['id'], |
| 53 | 'available') |
| 54 | |
| 55 | resp, backup = self.backups_adm_client.get_backup(backup['id']) |
| 56 | self.assertEqual(200, resp.status) |
| 57 | self.assertEqual(backup['name'], backup_name) |
| 58 | |
| 59 | resp, restore = self.backups_adm_client.restore_backup(backup['id']) |
| 60 | self.assertEqual(202, resp.status) |
| 61 | self.addCleanup(self.volumes_adm_client.delete_volume, |
| 62 | restore['volume_id']) |
| 63 | self.assertEqual(restore['backup_id'], backup['id']) |
| 64 | self.backups_adm_client.wait_for_backup_status(backup['id'], |
| 65 | 'available') |
| 66 | self.volumes_adm_client.wait_for_volume_status(restore['volume_id'], |
| 67 | 'available') |