blob: 6a771e5817a2e47243180138cea9010f353fb976 [file] [log] [blame]
ZhiQiang Fan39f97222013-09-20 04:49:44 +08001# Copyright 2012 OpenStack Foundation
Attila Fazekasa23f5002012-10-23 19:32:45 +02002# 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
Eric Windischba355292014-02-20 16:47:10 -080016from tempest import config
Matthew Treinishf4a9b0f2013-07-26 16:58:26 -040017from tempest.openstack.common import log as logging
Masayuki Igawa224a8272014-02-17 15:07:43 +090018from tempest import test
19from tempest.thirdparty.boto import test as boto_test
Matthew Treinisha83a16e2012-12-07 13:44:02 -050020
Eric Windischba355292014-02-20 16:47:10 -080021CONF = config.CONF
Attila Fazekasa23f5002012-10-23 19:32:45 +020022LOG = logging.getLogger(__name__)
23
24
25def compare_volumes(a, b):
26 return (a.id == b.id and
27 a.size == b.size)
28
29
Masayuki Igawa224a8272014-02-17 15:07:43 +090030class EC2VolumesTest(boto_test.BotoTestCase):
Attila Fazekasa23f5002012-10-23 19:32:45 +020031
32 @classmethod
33 def setUpClass(cls):
34 super(EC2VolumesTest, cls).setUpClass()
Eric Windischba355292014-02-20 16:47:10 -080035
36 if not CONF.service_available.cinder:
37 skip_msg = ("%s skipped as Cinder is not available" % cls.__name__)
38 raise cls.skipException(skip_msg)
39
Attila Fazekasa23f5002012-10-23 19:32:45 +020040 cls.client = cls.os.ec2api_client
41 cls.zone = cls.client.get_good_zone()
42
Masayuki Igawa224a8272014-02-17 15:07:43 +090043 @test.attr(type='smoke')
Attila Fazekasa23f5002012-10-23 19:32:45 +020044 def test_create_get_delete(self):
Sean Dague64ef48d2013-01-03 17:54:36 -050045 # EC2 Create, get, delete Volume
Attila Fazekasa23f5002012-10-23 19:32:45 +020046 volume = self.client.create_volume(1, self.zone)
47 cuk = self.addResourceCleanUp(self.client.delete_volume, volume.id)
48 self.assertIn(volume.status, self.valid_volume_status)
49 retrieved = self.client.get_all_volumes((volume.id,))
50 self.assertEqual(1, len(retrieved))
51 self.assertTrue(compare_volumes(volume, retrieved[0]))
Attila Fazekas40aa3612013-01-19 22:16:38 +010052 self.assertVolumeStatusWait(volume, "available")
Attila Fazekasa23f5002012-10-23 19:32:45 +020053 self.client.delete_volume(volume.id)
54 self.cancelResourceCleanUp(cuk)
55
Masayuki Igawa224a8272014-02-17 15:07:43 +090056 @test.attr(type='smoke')
Ashish Chandra0f7a30a2013-01-23 01:38:51 -080057 def test_create_volume_from_snapshot(self):
Sean Dague64ef48d2013-01-03 17:54:36 -050058 # EC2 Create volume from snapshot
Attila Fazekasa23f5002012-10-23 19:32:45 +020059 volume = self.client.create_volume(1, self.zone)
60 self.addResourceCleanUp(self.client.delete_volume, volume.id)
Attila Fazekas40aa3612013-01-19 22:16:38 +010061 self.assertVolumeStatusWait(volume, "available")
Attila Fazekasa23f5002012-10-23 19:32:45 +020062 snap = self.client.create_snapshot(volume.id)
63 self.addResourceCleanUp(self.destroy_snapshot_wait, snap)
Attila Fazekas40aa3612013-01-19 22:16:38 +010064 self.assertSnapshotStatusWait(snap, "completed")
Attila Fazekasa23f5002012-10-23 19:32:45 +020065
66 svol = self.client.create_volume(1, self.zone, snapshot=snap)
67 cuk = self.addResourceCleanUp(svol.delete)
Attila Fazekas40aa3612013-01-19 22:16:38 +010068 self.assertVolumeStatusWait(svol, "available")
Attila Fazekasa23f5002012-10-23 19:32:45 +020069 svol.delete()
70 self.cancelResourceCleanUp(cuk)