blob: bbb887f7095caed3e366eebb8ace7fb92014829a [file] [log] [blame]
ZhiQiang Fan39f97222013-09-20 04:49:44 +08001# Copyright 2012 OpenStack Foundation
Jay Pipes13b479b2012-06-11 14:52:27 -04002#
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
Sean Dague1937d092013-05-17 16:36:38 -040015from tempest.api.compute import base
Masayuki Igawa259c1132013-10-31 17:48:44 +090016from tempest.common.utils import data_utils
Matthew Treinishb0a78fc2014-01-29 16:49:12 +000017from tempest import config
ivan-zhued80f172014-02-10 12:50:59 +080018from tempest import test
Jay Pipes7f757632011-12-02 15:53:32 -050019
Matthew Treinishb0a78fc2014-01-29 16:49:12 +000020CONF = config.CONF
21
Daryl Walleck73a9e7a2011-11-15 17:43:31 -060022
ivan-zhuf2b00502013-10-18 10:06:52 +080023class ImagesTestJSON(base.BaseV2ComputeTest):
Attila Fazekas19044d52013-02-16 07:35:06 +010024
25 @classmethod
26 def setUpClass(cls):
27 super(ImagesTestJSON, cls).setUpClass()
Matthew Treinishb0a78fc2014-01-29 16:49:12 +000028 if not CONF.service_available.glance:
Matthew Treinish853ae442013-07-19 16:36:07 -040029 skip_msg = ("%s skipped as glance is not available" % cls.__name__)
30 raise cls.skipException(skip_msg)
Adam Gandelmanfbc95ac2014-06-19 17:33:43 -070031
32 if not CONF.compute_feature_enabled.snapshot:
33 skip_msg = ("%s skipped as instance snapshotting is not supported"
34 % cls.__name__)
35 raise cls.skipException(skip_msg)
36
Attila Fazekas19044d52013-02-16 07:35:06 +010037 cls.client = cls.images_client
38 cls.servers_client = cls.servers_client
39
ivan-zhued80f172014-02-10 12:50:59 +080040 @test.attr(type='gate')
Liu, Zhi Kun3fb36952013-07-18 00:05:05 +080041 def test_delete_saving_image(self):
Masayuki Igawa259c1132013-10-31 17:48:44 +090042 snapshot_name = data_utils.rand_name('test-snap-')
Ken'ichi Ohmichicfc052e2013-10-23 11:50:04 +090043 resp, server = self.create_test_server(wait_until='ACTIVE')
Liu, Zhi Kun3fb36952013-07-18 00:05:05 +080044 self.addCleanup(self.servers_client.delete_server, server['id'])
45 resp, image = self.create_image_from_server(server['id'],
46 name=snapshot_name,
47 wait_until='SAVING')
48 resp, body = self.client.delete_image(image['id'])
49 self.assertEqual('204', resp['status'])
50
Dan Smithe7316bb2012-08-14 12:35:34 -070051
Attila Fazekas19044d52013-02-16 07:35:06 +010052class ImagesTestXML(ImagesTestJSON):
53 _interface = 'xml'