blob: bb81626c5d7095d40ea983c8055e8cb6704d5670 [file] [log] [blame]
ivan-zhu09111942013-08-01 08:09:16 +08001# Copyright 2012 OpenStack Foundation
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
ivan-zhu09111942013-08-01 08:09:16 +080015from 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
ivan-zhu09111942013-08-01 08:09:16 +080019
Matthew Treinishb0a78fc2014-01-29 16:49:12 +000020CONF = config.CONF
21
ivan-zhu09111942013-08-01 08:09:16 +080022
Ken'ichi Ohmichi7f508ed2014-01-30 22:35:20 +090023class ImagesV3Test(base.BaseV3ComputeTest):
ivan-zhu09111942013-08-01 08:09:16 +080024
25 @classmethod
26 def setUpClass(cls):
Ken'ichi Ohmichi7f508ed2014-01-30 22:35:20 +090027 super(ImagesV3Test, cls).setUpClass()
Matthew Treinishb0a78fc2014-01-29 16:49:12 +000028 if not CONF.service_available.glance:
ivan-zhu09111942013-08-01 08:09:16 +080029 skip_msg = ("%s skipped as glance is not available" % cls.__name__)
30 raise cls.skipException(skip_msg)
31 cls.client = cls.images_client
ivan-zhu09111942013-08-01 08:09:16 +080032
Yuiko Takada5381f542014-02-21 18:17:19 +000033 @test.attr(type='gate')
ivan-zhu09111942013-08-01 08:09:16 +080034 def test_create_image_from_stopped_server(self):
Ken'ichi Ohmichicfc052e2013-10-23 11:50:04 +090035 resp, server = self.create_test_server(wait_until='ACTIVE')
ivan-zhu09111942013-08-01 08:09:16 +080036 self.servers_client.stop(server['id'])
37 self.servers_client.wait_for_server_status(server['id'],
38 'SHUTOFF')
39 self.addCleanup(self.servers_client.delete_server, server['id'])
Masayuki Igawa259c1132013-10-31 17:48:44 +090040 snapshot_name = data_utils.rand_name('test-snap-')
ivan-zhu09111942013-08-01 08:09:16 +080041 resp, image = self.create_image_from_server(server['id'],
42 name=snapshot_name,
ivan-zhu8f992be2013-07-31 14:56:58 +080043 wait_until='active')
ivan-zhu09111942013-08-01 08:09:16 +080044 self.addCleanup(self.client.delete_image, image['id'])
45 self.assertEqual(snapshot_name, image['name'])
46
ivan-zhued80f172014-02-10 12:50:59 +080047 @test.attr(type='gate')
ivan-zhu8f992be2013-07-31 14:56:58 +080048 def test_delete_queued_image(self):
Masayuki Igawa259c1132013-10-31 17:48:44 +090049 snapshot_name = data_utils.rand_name('test-snap-')
Ken'ichi Ohmichicfc052e2013-10-23 11:50:04 +090050 resp, server = self.create_test_server(wait_until='ACTIVE')
ivan-zhu09111942013-08-01 08:09:16 +080051 self.addCleanup(self.servers_client.delete_server, server['id'])
52 resp, image = self.create_image_from_server(server['id'],
53 name=snapshot_name,
ivan-zhu8f992be2013-07-31 14:56:58 +080054 wait_until='queued')
ivan-zhu09111942013-08-01 08:09:16 +080055 resp, body = self.client.delete_image(image['id'])
ivan-zhu8f992be2013-07-31 14:56:58 +080056 self.assertEqual('200', resp['status'])