blob: ba8ba6cc075f369fc6809ceb65a5eb7735658a66 [file] [log] [blame]
Attila Fazekas36b1fcf2013-01-31 16:41:04 +01001# 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 Fidente3a465e32013-05-07 13:38:18 +020015import logging
16
Giulio Fidente73332932013-05-03 18:04:09 +020017from tempest.test import attr
Attila Fazekas36b1fcf2013-01-31 16:41:04 +010018from tempest.tests.volume import base
19
Giulio Fidente3a465e32013-05-07 13:38:18 +020020LOG = logging.getLogger(__name__)
21
Attila Fazekas36b1fcf2013-01-31 16:41:04 +010022
Attila Fazekas3dcdae12013-02-14 12:50:04 +010023class VolumesSnapshotTest(base.BaseVolumeTest):
24 _interface = "json"
Attila Fazekas36b1fcf2013-01-31 16:41:04 +010025
Giulio Fidente73332932013-05-03 18:04:09 +020026 @classmethod
27 def setUpClass(cls):
28 super(VolumesSnapshotTest, cls).setUpClass()
29 try:
30 cls.volume_origin = cls.create_volume()
31 except Exception:
Giulio Fidente3a465e32013-05-07 13:38:18 +020032 LOG.exception("setup failed")
Giulio Fidente73332932013-05-03 18:04:09 +020033 cls.tearDownClass()
34 raise
35
36 @classmethod
37 def tearDownClass(cls):
38 super(VolumesSnapshotTest, cls).tearDownClass()
Giulio Fidente73332932013-05-03 18:04:09 +020039
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 Fazekas36b1fcf2013-01-31 16:41:04 +010052 self.snapshots_client.delete_snapshot(snapshot['id'])
Attila Fazekas36b1fcf2013-01-31 16:41:04 +010053 self.snapshots_client.wait_for_resource_deletion(snapshot['id'])
Giulio Fidente73332932013-05-03 18:04:09 +020054
55 def test_volume_from_snapshot(self):
Giulio Fidente3a465e32013-05-07 13:38:18 +020056 # Create a temporary snap using wrapper method from base, then
57 # create a snap based volume, check resp code and deletes it
Giulio Fidente73332932013-05-03 18:04:09 +020058 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 Fazekas36b1fcf2013-01-31 16:41:04 +010068
69
Attila Fazekas3dcdae12013-02-14 12:50:04 +010070class VolumesSnapshotTestXML(VolumesSnapshotTest):
71 _interface = "xml"