Attila Fazekas | a23f500 | 2012-10-23 19:32:45 +0200 | [diff] [blame] | 1 | # vim: tabstop=4 shiftwidth=4 softtabstop=4 |
| 2 | |
| 3 | # Copyright 2012 OpenStack, LLC |
| 4 | # All Rights Reserved. |
| 5 | # |
| 6 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 7 | # not use this file except in compliance with the License. You may obtain |
| 8 | # a copy of the License at |
| 9 | # |
| 10 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | # |
| 12 | # Unless required by applicable law or agreed to in writing, software |
| 13 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 14 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 15 | # License for the specific language governing permissions and limitations |
| 16 | # under the License. |
| 17 | |
Matthew Treinish | 481466b | 2012-12-20 17:16:01 -0500 | [diff] [blame] | 18 | from tempest import clients |
Matthew Treinish | f4a9b0f | 2013-07-26 16:58:26 -0400 | [diff] [blame] | 19 | from tempest.openstack.common import log as logging |
Chris Yeoh | 01cb279 | 2013-02-09 22:25:37 +1030 | [diff] [blame] | 20 | from tempest.test import attr |
Sean Dague | 09761f6 | 2013-05-13 15:20:40 -0400 | [diff] [blame] | 21 | from tempest.thirdparty.boto.test import BotoTestCase |
Matthew Treinish | a83a16e | 2012-12-07 13:44:02 -0500 | [diff] [blame] | 22 | |
Attila Fazekas | a23f500 | 2012-10-23 19:32:45 +0200 | [diff] [blame] | 23 | LOG = logging.getLogger(__name__) |
| 24 | |
| 25 | |
| 26 | def compare_volumes(a, b): |
| 27 | return (a.id == b.id and |
| 28 | a.size == b.size) |
| 29 | |
| 30 | |
Attila Fazekas | a23f500 | 2012-10-23 19:32:45 +0200 | [diff] [blame] | 31 | class EC2VolumesTest(BotoTestCase): |
| 32 | |
| 33 | @classmethod |
| 34 | def setUpClass(cls): |
| 35 | super(EC2VolumesTest, cls).setUpClass() |
Matthew Treinish | 481466b | 2012-12-20 17:16:01 -0500 | [diff] [blame] | 36 | cls.os = clients.Manager() |
Attila Fazekas | a23f500 | 2012-10-23 19:32:45 +0200 | [diff] [blame] | 37 | cls.client = cls.os.ec2api_client |
| 38 | cls.zone = cls.client.get_good_zone() |
| 39 | |
Attila Fazekas | a23f500 | 2012-10-23 19:32:45 +0200 | [diff] [blame] | 40 | @attr(type='smoke') |
| 41 | def test_create_get_delete(self): |
Sean Dague | 64ef48d | 2013-01-03 17:54:36 -0500 | [diff] [blame] | 42 | # EC2 Create, get, delete Volume |
Attila Fazekas | a23f500 | 2012-10-23 19:32:45 +0200 | [diff] [blame] | 43 | volume = self.client.create_volume(1, self.zone) |
| 44 | cuk = self.addResourceCleanUp(self.client.delete_volume, volume.id) |
| 45 | self.assertIn(volume.status, self.valid_volume_status) |
| 46 | retrieved = self.client.get_all_volumes((volume.id,)) |
| 47 | self.assertEqual(1, len(retrieved)) |
| 48 | self.assertTrue(compare_volumes(volume, retrieved[0])) |
Attila Fazekas | 40aa361 | 2013-01-19 22:16:38 +0100 | [diff] [blame] | 49 | self.assertVolumeStatusWait(volume, "available") |
Attila Fazekas | a23f500 | 2012-10-23 19:32:45 +0200 | [diff] [blame] | 50 | self.client.delete_volume(volume.id) |
| 51 | self.cancelResourceCleanUp(cuk) |
| 52 | |
Attila Fazekas | ec6d20f | 2012-12-06 19:47:11 +0100 | [diff] [blame] | 53 | @attr(type='smoke') |
Ashish Chandra | 0f7a30a | 2013-01-23 01:38:51 -0800 | [diff] [blame] | 54 | def test_create_volume_from_snapshot(self): |
Sean Dague | 64ef48d | 2013-01-03 17:54:36 -0500 | [diff] [blame] | 55 | # EC2 Create volume from snapshot |
Attila Fazekas | a23f500 | 2012-10-23 19:32:45 +0200 | [diff] [blame] | 56 | volume = self.client.create_volume(1, self.zone) |
| 57 | self.addResourceCleanUp(self.client.delete_volume, volume.id) |
Attila Fazekas | 40aa361 | 2013-01-19 22:16:38 +0100 | [diff] [blame] | 58 | self.assertVolumeStatusWait(volume, "available") |
Attila Fazekas | a23f500 | 2012-10-23 19:32:45 +0200 | [diff] [blame] | 59 | snap = self.client.create_snapshot(volume.id) |
| 60 | self.addResourceCleanUp(self.destroy_snapshot_wait, snap) |
Attila Fazekas | 40aa361 | 2013-01-19 22:16:38 +0100 | [diff] [blame] | 61 | self.assertSnapshotStatusWait(snap, "completed") |
Attila Fazekas | a23f500 | 2012-10-23 19:32:45 +0200 | [diff] [blame] | 62 | |
| 63 | svol = self.client.create_volume(1, self.zone, snapshot=snap) |
| 64 | cuk = self.addResourceCleanUp(svol.delete) |
Attila Fazekas | 40aa361 | 2013-01-19 22:16:38 +0100 | [diff] [blame] | 65 | self.assertVolumeStatusWait(svol, "available") |
Attila Fazekas | a23f500 | 2012-10-23 19:32:45 +0200 | [diff] [blame] | 66 | svol.delete() |
| 67 | self.cancelResourceCleanUp(cuk) |