Attila Fazekas | 36b1fcf | 2013-01-31 16:41:04 +0100 | [diff] [blame] | 1 | # vim: tabstop=4 shiftwidth=4 softtabstop=4 |
| 2 | |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 4 | # not use this file except in compliance with the License. You may obtain |
| 5 | # a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 12 | # License for the specific language governing permissions and limitations |
| 13 | # under the License. |
| 14 | |
Giulio Fidente | 3a465e3 | 2013-05-07 13:38:18 +0200 | [diff] [blame] | 15 | import logging |
| 16 | |
Giulio Fidente | 7333293 | 2013-05-03 18:04:09 +0200 | [diff] [blame] | 17 | from tempest.test import attr |
Attila Fazekas | 36b1fcf | 2013-01-31 16:41:04 +0100 | [diff] [blame] | 18 | from tempest.tests.volume import base |
| 19 | |
Giulio Fidente | 3a465e3 | 2013-05-07 13:38:18 +0200 | [diff] [blame] | 20 | LOG = logging.getLogger(__name__) |
| 21 | |
Attila Fazekas | 36b1fcf | 2013-01-31 16:41:04 +0100 | [diff] [blame] | 22 | |
Attila Fazekas | 3dcdae1 | 2013-02-14 12:50:04 +0100 | [diff] [blame] | 23 | class VolumesSnapshotTest(base.BaseVolumeTest): |
| 24 | _interface = "json" |
Attila Fazekas | 36b1fcf | 2013-01-31 16:41:04 +0100 | [diff] [blame] | 25 | |
Giulio Fidente | 7333293 | 2013-05-03 18:04:09 +0200 | [diff] [blame] | 26 | @classmethod |
| 27 | def setUpClass(cls): |
| 28 | super(VolumesSnapshotTest, cls).setUpClass() |
| 29 | try: |
| 30 | cls.volume_origin = cls.create_volume() |
| 31 | except Exception: |
Giulio Fidente | 3a465e3 | 2013-05-07 13:38:18 +0200 | [diff] [blame] | 32 | LOG.exception("setup failed") |
Giulio Fidente | 7333293 | 2013-05-03 18:04:09 +0200 | [diff] [blame] | 33 | cls.tearDownClass() |
| 34 | raise |
| 35 | |
| 36 | @classmethod |
| 37 | def tearDownClass(cls): |
| 38 | super(VolumesSnapshotTest, cls).tearDownClass() |
Giulio Fidente | 7333293 | 2013-05-03 18:04:09 +0200 | [diff] [blame] | 39 | |
| 40 | @attr(type='smoke') |
| 41 | def test_snapshot_create_get_delete(self): |
| 42 | # Create a snapshot, get some of the details and then deletes it |
| 43 | resp, snapshot = self.snapshots_client.create_snapshot( |
| 44 | self.volume_origin['id']) |
| 45 | self.assertEqual(200, resp.status) |
| 46 | self.snapshots_client.wait_for_snapshot_status(snapshot['id'], |
| 47 | 'available') |
| 48 | errmsg = "Referred volume origin ID mismatch" |
| 49 | self.assertEqual(self.volume_origin['id'], |
| 50 | snapshot['volume_id'], |
| 51 | errmsg) |
Attila Fazekas | 36b1fcf | 2013-01-31 16:41:04 +0100 | [diff] [blame] | 52 | self.snapshots_client.delete_snapshot(snapshot['id']) |
Attila Fazekas | 36b1fcf | 2013-01-31 16:41:04 +0100 | [diff] [blame] | 53 | self.snapshots_client.wait_for_resource_deletion(snapshot['id']) |
Giulio Fidente | 7333293 | 2013-05-03 18:04:09 +0200 | [diff] [blame] | 54 | |
| 55 | def test_volume_from_snapshot(self): |
Giulio Fidente | 3a465e3 | 2013-05-07 13:38:18 +0200 | [diff] [blame] | 56 | # Create a temporary snap using wrapper method from base, then |
| 57 | # create a snap based volume, check resp code and deletes it |
Giulio Fidente | 7333293 | 2013-05-03 18:04:09 +0200 | [diff] [blame] | 58 | snapshot = self.create_snapshot(self.volume_origin['id']) |
| 59 | # NOTE: size is required also when passing snapshot_id |
| 60 | resp, volume = self.volumes_client.create_volume( |
| 61 | size=1, |
| 62 | snapshot_id=snapshot['id']) |
| 63 | self.assertEqual(200, resp.status) |
| 64 | self.volumes_client.wait_for_volume_status(volume['id'], 'available') |
| 65 | self.volumes_client.delete_volume(volume['id']) |
| 66 | self.volumes_client.wait_for_resource_deletion(volume['id']) |
| 67 | self.clear_snapshots() |
Attila Fazekas | 36b1fcf | 2013-01-31 16:41:04 +0100 | [diff] [blame] | 68 | |
| 69 | |
Attila Fazekas | 3dcdae1 | 2013-02-14 12:50:04 +0100 | [diff] [blame] | 70 | class VolumesSnapshotTestXML(VolumesSnapshotTest): |
| 71 | _interface = "xml" |