ZhiQiang Fan | 39f9722 | 2013-09-20 04:49:44 +0800 | [diff] [blame] | 1 | # Copyright 2012 OpenStack Foundation |
Jay Pipes | 13b479b | 2012-06-11 14:52:27 -0400 | [diff] [blame] | 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 | |
Sean Dague | 1937d09 | 2013-05-17 16:36:38 -0400 | [diff] [blame] | 15 | from tempest.api.compute import base |
Fei Long Wang | d39431f | 2015-05-14 11:30:48 +1200 | [diff] [blame] | 16 | from tempest.common.utils import data_utils |
Joe H. Rahme | 66793a3 | 2015-10-09 18:36:26 +0200 | [diff] [blame^] | 17 | from tempest.common import waiters |
Matthew Treinish | b0a78fc | 2014-01-29 16:49:12 +0000 | [diff] [blame] | 18 | from tempest import config |
ivan-zhu | ed80f17 | 2014-02-10 12:50:59 +0800 | [diff] [blame] | 19 | from tempest import test |
Jay Pipes | 7f75763 | 2011-12-02 15:53:32 -0500 | [diff] [blame] | 20 | |
Matthew Treinish | b0a78fc | 2014-01-29 16:49:12 +0000 | [diff] [blame] | 21 | CONF = config.CONF |
| 22 | |
Daryl Walleck | 73a9e7a | 2011-11-15 17:43:31 -0600 | [diff] [blame] | 23 | |
ivan-zhu | f2b0050 | 2013-10-18 10:06:52 +0800 | [diff] [blame] | 24 | class ImagesTestJSON(base.BaseV2ComputeTest): |
Attila Fazekas | 19044d5 | 2013-02-16 07:35:06 +0100 | [diff] [blame] | 25 | |
| 26 | @classmethod |
Rohan Kanade | 60b7309 | 2015-02-04 17:58:19 +0530 | [diff] [blame] | 27 | def skip_checks(cls): |
| 28 | super(ImagesTestJSON, cls).skip_checks() |
Matthew Treinish | b0a78fc | 2014-01-29 16:49:12 +0000 | [diff] [blame] | 29 | if not CONF.service_available.glance: |
Matthew Treinish | 853ae44 | 2013-07-19 16:36:07 -0400 | [diff] [blame] | 30 | skip_msg = ("%s skipped as glance is not available" % cls.__name__) |
| 31 | raise cls.skipException(skip_msg) |
Adam Gandelman | fbc95ac | 2014-06-19 17:33:43 -0700 | [diff] [blame] | 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 | |
Rohan Kanade | 60b7309 | 2015-02-04 17:58:19 +0530 | [diff] [blame] | 37 | @classmethod |
| 38 | def setup_clients(cls): |
| 39 | super(ImagesTestJSON, cls).setup_clients() |
Attila Fazekas | 19044d5 | 2013-02-16 07:35:06 +0100 | [diff] [blame] | 40 | cls.client = cls.images_client |
| 41 | cls.servers_client = cls.servers_client |
| 42 | |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 43 | @test.idempotent_id('aa06b52b-2db5-4807-b218-9441f75d74e3') |
Liu, Zhi Kun | 3fb3695 | 2013-07-18 00:05:05 +0800 | [diff] [blame] | 44 | def test_delete_saving_image(self): |
Ken'ichi Ohmichi | 4937f56 | 2015-03-23 00:15:01 +0000 | [diff] [blame] | 45 | snapshot_name = data_utils.rand_name('test-snap') |
David Kranz | 0fb1429 | 2015-02-11 15:55:20 -0500 | [diff] [blame] | 46 | server = self.create_test_server(wait_until='ACTIVE') |
Liu, Zhi Kun | 3fb3695 | 2013-07-18 00:05:05 +0800 | [diff] [blame] | 47 | self.addCleanup(self.servers_client.delete_server, server['id']) |
David Kranz | a5299eb | 2015-01-15 17:24:05 -0500 | [diff] [blame] | 48 | image = self.create_image_from_server(server['id'], |
| 49 | name=snapshot_name, |
| 50 | wait_until='SAVING') |
| 51 | self.client.delete_image(image['id']) |
Joe H. Rahme | 66793a3 | 2015-10-09 18:36:26 +0200 | [diff] [blame^] | 52 | |
| 53 | @test.idempotent_id('aaacd1d0-55a2-4ce8-818a-b5439df8adc9') |
| 54 | def test_create_image_from_stopped_server(self): |
| 55 | server = self.create_test_server(wait_until='ACTIVE') |
| 56 | self.servers_client.stop_server(server['id']) |
| 57 | waiters.wait_for_server_status(self.servers_client, |
| 58 | server['id'], 'SHUTOFF') |
| 59 | self.addCleanup(self.servers_client.delete_server, server['id']) |
| 60 | snapshot_name = data_utils.rand_name('test-snap') |
| 61 | image = self.create_image_from_server(server['id'], |
| 62 | name=snapshot_name, |
| 63 | wait_until='ACTIVE', |
| 64 | wait_for_server=False) |
| 65 | self.addCleanup(self.client.delete_image, image['id']) |
| 66 | self.assertEqual(snapshot_name, image['name']) |