ZhiQiang Fan | 39f9722 | 2013-09-20 04:49:44 +0800 | [diff] [blame] | 1 | # Copyright 2012 OpenStack Foundation |
Jay Pipes | 051075a | 2012-04-28 17:39:37 -0400 | [diff] [blame] | 2 | # All Rights Reserved. |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 5 | # not use this file except in compliance with the License. You may obtain |
| 6 | # a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 12 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 13 | # License for the specific language governing permissions and limitations |
| 14 | # under the License. |
| 15 | |
Doug Hellmann | 583ce2c | 2015-03-11 14:55:46 +0000 | [diff] [blame] | 16 | from oslo_log import log as logging |
armando-migliaccio | 9e5eac0 | 2014-03-24 10:55:31 -0700 | [diff] [blame] | 17 | import testtools |
| 18 | |
Ken'ichi Ohmichi | 0eb153c | 2015-07-13 02:18:25 +0000 | [diff] [blame] | 19 | from tempest.common import waiters |
Matthew Treinish | 6c07229 | 2014-01-29 19:15:52 +0000 | [diff] [blame] | 20 | from tempest import config |
Sean Dague | 6dbc6da | 2013-05-08 17:49:46 -0400 | [diff] [blame] | 21 | from tempest.scenario import manager |
Masayuki Igawa | 4ded9f0 | 2014-02-17 15:05:59 +0900 | [diff] [blame] | 22 | from tempest import test |
Jay Pipes | 051075a | 2012-04-28 17:39:37 -0400 | [diff] [blame] | 23 | |
Matthew Treinish | 6c07229 | 2014-01-29 19:15:52 +0000 | [diff] [blame] | 24 | CONF = config.CONF |
| 25 | |
Jay Pipes | 051075a | 2012-04-28 17:39:37 -0400 | [diff] [blame] | 26 | LOG = logging.getLogger(__name__) |
| 27 | |
| 28 | |
Ghanshyam | aadf036 | 2014-08-27 16:51:26 +0900 | [diff] [blame] | 29 | class TestServerAdvancedOps(manager.ScenarioTest): |
Jay Pipes | 051075a | 2012-04-28 17:39:37 -0400 | [diff] [blame] | 30 | |
Ken'ichi Ohmichi | c4e4f1c | 2015-11-17 08:16:12 +0000 | [diff] [blame] | 31 | """The test suite for server advanced operations |
Jay Pipes | 051075a | 2012-04-28 17:39:37 -0400 | [diff] [blame] | 32 | |
Ken'ichi Ohmichi | c4e4f1c | 2015-11-17 08:16:12 +0000 | [diff] [blame] | 33 | This test case stresses some advanced server instance operations: |
Matt Riedemann | 6506f90 | 2016-05-10 20:37:15 -0400 | [diff] [blame] | 34 | * Resizing a volume-backed instance |
Tatyana Leontovich | 58ab531 | 2013-04-22 16:48:33 +0300 | [diff] [blame] | 35 | * Sequence suspend resume |
Jay Pipes | 051075a | 2012-04-28 17:39:37 -0400 | [diff] [blame] | 36 | """ |
| 37 | |
| 38 | @classmethod |
Emily Hugenbruch | 5e2d2a2 | 2015-02-25 21:35:45 +0000 | [diff] [blame] | 39 | def skip_checks(cls): |
| 40 | super(TestServerAdvancedOps, cls).skip_checks() |
armando-migliaccio | 9e5eac0 | 2014-03-24 10:55:31 -0700 | [diff] [blame] | 41 | if CONF.compute.flavor_ref_alt == CONF.compute.flavor_ref: |
Jay Pipes | 051075a | 2012-04-28 17:39:37 -0400 | [diff] [blame] | 42 | msg = "Skipping test - flavor_ref and flavor_ref_alt are identical" |
ivan-zhu | 1feeb38 | 2013-01-24 10:14:39 +0800 | [diff] [blame] | 43 | raise cls.skipException(msg) |
Emily Hugenbruch | 5e2d2a2 | 2015-02-25 21:35:45 +0000 | [diff] [blame] | 44 | |
| 45 | @classmethod |
| 46 | def setup_credentials(cls): |
Masayuki Igawa | 60ea6c5 | 2014-10-15 17:32:14 +0900 | [diff] [blame] | 47 | cls.set_network_resources() |
Emily Hugenbruch | 5e2d2a2 | 2015-02-25 21:35:45 +0000 | [diff] [blame] | 48 | super(TestServerAdvancedOps, cls).setup_credentials() |
Jay Pipes | 051075a | 2012-04-28 17:39:37 -0400 | [diff] [blame] | 49 | |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 50 | @test.idempotent_id('e6c28180-7454-4b59-b188-0257af08a63b') |
armando-migliaccio | 9e5eac0 | 2014-03-24 10:55:31 -0700 | [diff] [blame] | 51 | @testtools.skipUnless(CONF.compute_feature_enabled.resize, |
| 52 | 'Resize is not available.') |
Matt Riedemann | 6506f90 | 2016-05-10 20:37:15 -0400 | [diff] [blame] | 53 | @test.services('compute', 'volume') |
| 54 | def test_resize_volume_backed_server_confirm(self): |
Jay Pipes | 051075a | 2012-04-28 17:39:37 -0400 | [diff] [blame] | 55 | # We create an instance for use in this test |
Matt Riedemann | 6506f90 | 2016-05-10 20:37:15 -0400 | [diff] [blame] | 56 | instance = self.create_server(wait_until='ACTIVE', volume_backed=True) |
Ghanshyam | aadf036 | 2014-08-27 16:51:26 +0900 | [diff] [blame] | 57 | instance_id = instance['id'] |
Matthew Treinish | 6c07229 | 2014-01-29 19:15:52 +0000 | [diff] [blame] | 58 | resize_flavor = CONF.compute.flavor_ref_alt |
Jay Pipes | 051075a | 2012-04-28 17:39:37 -0400 | [diff] [blame] | 59 | LOG.debug("Resizing instance %s from flavor %s to flavor %s", |
Ghanshyam | aadf036 | 2014-08-27 16:51:26 +0900 | [diff] [blame] | 60 | instance['id'], instance['flavor']['id'], resize_flavor) |
Ken'ichi Ohmichi | 5271b0f | 2015-08-10 07:53:27 +0000 | [diff] [blame] | 61 | self.servers_client.resize_server(instance_id, resize_flavor) |
Ken'ichi Ohmichi | 0eb153c | 2015-07-13 02:18:25 +0000 | [diff] [blame] | 62 | waiters.wait_for_server_status(self.servers_client, instance_id, |
| 63 | 'VERIFY_RESIZE') |
Jay Pipes | 051075a | 2012-04-28 17:39:37 -0400 | [diff] [blame] | 64 | |
| 65 | LOG.debug("Confirming resize of instance %s", instance_id) |
Ken'ichi Ohmichi | b263108 | 2015-08-27 01:31:00 +0000 | [diff] [blame] | 66 | self.servers_client.confirm_resize_server(instance_id) |
Tatyana Leontovich | 58ab531 | 2013-04-22 16:48:33 +0300 | [diff] [blame] | 67 | |
Ken'ichi Ohmichi | 0eb153c | 2015-07-13 02:18:25 +0000 | [diff] [blame] | 68 | waiters.wait_for_server_status(self.servers_client, instance_id, |
| 69 | 'ACTIVE') |
Tatyana Leontovich | 58ab531 | 2013-04-22 16:48:33 +0300 | [diff] [blame] | 70 | |
Chris Hoge | 7579c1a | 2015-02-26 14:12:15 -0800 | [diff] [blame] | 71 | @test.idempotent_id('949da7d5-72c8-4808-8802-e3d70df98e2c') |
armando-migliaccio | 9e5eac0 | 2014-03-24 10:55:31 -0700 | [diff] [blame] | 72 | @testtools.skipUnless(CONF.compute_feature_enabled.suspend, |
| 73 | 'Suspend is not available.') |
Masayuki Igawa | 4ded9f0 | 2014-02-17 15:05:59 +0900 | [diff] [blame] | 74 | @test.services('compute') |
Tatyana Leontovich | 58ab531 | 2013-04-22 16:48:33 +0300 | [diff] [blame] | 75 | def test_server_sequence_suspend_resume(self): |
| 76 | # We create an instance for use in this test |
lanoux | 5fc1452 | 2015-09-21 08:17:35 +0000 | [diff] [blame] | 77 | instance = self.create_server(wait_until='ACTIVE') |
Ghanshyam | aadf036 | 2014-08-27 16:51:26 +0900 | [diff] [blame] | 78 | instance_id = instance['id'] |
Tatyana Leontovich | 58ab531 | 2013-04-22 16:48:33 +0300 | [diff] [blame] | 79 | LOG.debug("Suspending instance %s. Current status: %s", |
Ghanshyam | aadf036 | 2014-08-27 16:51:26 +0900 | [diff] [blame] | 80 | instance_id, instance['status']) |
| 81 | self.servers_client.suspend_server(instance_id) |
Ken'ichi Ohmichi | 0eb153c | 2015-07-13 02:18:25 +0000 | [diff] [blame] | 82 | waiters.wait_for_server_status(self.servers_client, instance_id, |
| 83 | 'SUSPENDED') |
ghanshyam | 0f82525 | 2015-08-25 16:02:50 +0900 | [diff] [blame] | 84 | fetched_instance = (self.servers_client.show_server(instance_id) |
| 85 | ['server']) |
Tatyana Leontovich | 58ab531 | 2013-04-22 16:48:33 +0300 | [diff] [blame] | 86 | LOG.debug("Resuming instance %s. Current status: %s", |
Ghanshyam | aadf036 | 2014-08-27 16:51:26 +0900 | [diff] [blame] | 87 | instance_id, fetched_instance['status']) |
| 88 | self.servers_client.resume_server(instance_id) |
Ken'ichi Ohmichi | 0eb153c | 2015-07-13 02:18:25 +0000 | [diff] [blame] | 89 | waiters.wait_for_server_status(self.servers_client, instance_id, |
| 90 | 'ACTIVE') |
ghanshyam | 0f82525 | 2015-08-25 16:02:50 +0900 | [diff] [blame] | 91 | fetched_instance = (self.servers_client.show_server(instance_id) |
| 92 | ['server']) |
Tatyana Leontovich | 58ab531 | 2013-04-22 16:48:33 +0300 | [diff] [blame] | 93 | LOG.debug("Suspending instance %s. Current status: %s", |
Ghanshyam | aadf036 | 2014-08-27 16:51:26 +0900 | [diff] [blame] | 94 | instance_id, fetched_instance['status']) |
| 95 | self.servers_client.suspend_server(instance_id) |
Ken'ichi Ohmichi | 0eb153c | 2015-07-13 02:18:25 +0000 | [diff] [blame] | 96 | waiters.wait_for_server_status(self.servers_client, instance_id, |
| 97 | 'SUSPENDED') |
ghanshyam | 0f82525 | 2015-08-25 16:02:50 +0900 | [diff] [blame] | 98 | fetched_instance = (self.servers_client.show_server(instance_id) |
| 99 | ['server']) |
Tatyana Leontovich | 58ab531 | 2013-04-22 16:48:33 +0300 | [diff] [blame] | 100 | LOG.debug("Resuming instance %s. Current status: %s", |
Ghanshyam | aadf036 | 2014-08-27 16:51:26 +0900 | [diff] [blame] | 101 | instance_id, fetched_instance['status']) |
| 102 | self.servers_client.resume_server(instance_id) |
Ken'ichi Ohmichi | 0eb153c | 2015-07-13 02:18:25 +0000 | [diff] [blame] | 103 | waiters.wait_for_server_status(self.servers_client, instance_id, |
| 104 | 'ACTIVE') |