ivan-zhu | 0911194 | 2013-08-01 08:09:16 +0800 | [diff] [blame] | 1 | # 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-zhu | 0911194 | 2013-08-01 08:09:16 +0800 | [diff] [blame] | 15 | from tempest.api.compute import base |
Masayuki Igawa | 259c113 | 2013-10-31 17:48:44 +0900 | [diff] [blame] | 16 | from tempest.common.utils import data_utils |
Matthew Treinish | b0a78fc | 2014-01-29 16:49:12 +0000 | [diff] [blame] | 17 | from tempest import config |
ivan-zhu | ed80f17 | 2014-02-10 12:50:59 +0800 | [diff] [blame] | 18 | from tempest import test |
ivan-zhu | 0911194 | 2013-08-01 08:09:16 +0800 | [diff] [blame] | 19 | |
Matthew Treinish | b0a78fc | 2014-01-29 16:49:12 +0000 | [diff] [blame] | 20 | CONF = config.CONF |
| 21 | |
ivan-zhu | 0911194 | 2013-08-01 08:09:16 +0800 | [diff] [blame] | 22 | |
Ken'ichi Ohmichi | 7f508ed | 2014-01-30 22:35:20 +0900 | [diff] [blame] | 23 | class ImagesV3Test(base.BaseV3ComputeTest): |
ivan-zhu | 0911194 | 2013-08-01 08:09:16 +0800 | [diff] [blame] | 24 | |
| 25 | @classmethod |
| 26 | def setUpClass(cls): |
Ken'ichi Ohmichi | 7f508ed | 2014-01-30 22:35:20 +0900 | [diff] [blame] | 27 | super(ImagesV3Test, cls).setUpClass() |
Matthew Treinish | b0a78fc | 2014-01-29 16:49:12 +0000 | [diff] [blame] | 28 | if not CONF.service_available.glance: |
ivan-zhu | 0911194 | 2013-08-01 08:09:16 +0800 | [diff] [blame] | 29 | skip_msg = ("%s skipped as glance is not available" % cls.__name__) |
| 30 | raise cls.skipException(skip_msg) |
| 31 | cls.client = cls.images_client |
ivan-zhu | 0911194 | 2013-08-01 08:09:16 +0800 | [diff] [blame] | 32 | |
Yuiko Takada | 5381f54 | 2014-02-21 18:17:19 +0000 | [diff] [blame] | 33 | @test.attr(type='gate') |
ivan-zhu | 0911194 | 2013-08-01 08:09:16 +0800 | [diff] [blame] | 34 | def test_create_image_from_stopped_server(self): |
Ken'ichi Ohmichi | cfc052e | 2013-10-23 11:50:04 +0900 | [diff] [blame] | 35 | resp, server = self.create_test_server(wait_until='ACTIVE') |
ivan-zhu | 0911194 | 2013-08-01 08:09:16 +0800 | [diff] [blame] | 36 | 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 Igawa | 259c113 | 2013-10-31 17:48:44 +0900 | [diff] [blame] | 40 | snapshot_name = data_utils.rand_name('test-snap-') |
ivan-zhu | 0911194 | 2013-08-01 08:09:16 +0800 | [diff] [blame] | 41 | resp, image = self.create_image_from_server(server['id'], |
| 42 | name=snapshot_name, |
ivan-zhu | 8f992be | 2013-07-31 14:56:58 +0800 | [diff] [blame] | 43 | wait_until='active') |
ivan-zhu | 0911194 | 2013-08-01 08:09:16 +0800 | [diff] [blame] | 44 | self.addCleanup(self.client.delete_image, image['id']) |
| 45 | self.assertEqual(snapshot_name, image['name']) |
| 46 | |
ivan-zhu | ed80f17 | 2014-02-10 12:50:59 +0800 | [diff] [blame] | 47 | @test.attr(type='gate') |
ivan-zhu | 8f992be | 2013-07-31 14:56:58 +0800 | [diff] [blame] | 48 | def test_delete_queued_image(self): |
Masayuki Igawa | 259c113 | 2013-10-31 17:48:44 +0900 | [diff] [blame] | 49 | snapshot_name = data_utils.rand_name('test-snap-') |
Ken'ichi Ohmichi | cfc052e | 2013-10-23 11:50:04 +0900 | [diff] [blame] | 50 | resp, server = self.create_test_server(wait_until='ACTIVE') |
ivan-zhu | 0911194 | 2013-08-01 08:09:16 +0800 | [diff] [blame] | 51 | self.addCleanup(self.servers_client.delete_server, server['id']) |
| 52 | resp, image = self.create_image_from_server(server['id'], |
| 53 | name=snapshot_name, |
ivan-zhu | 8f992be | 2013-07-31 14:56:58 +0800 | [diff] [blame] | 54 | wait_until='queued') |
ivan-zhu | 0911194 | 2013-08-01 08:09:16 +0800 | [diff] [blame] | 55 | resp, body = self.client.delete_image(image['id']) |
ivan-zhu | 8f992be | 2013-07-31 14:56:58 +0800 | [diff] [blame] | 56 | self.assertEqual('200', resp['status']) |