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 |
Ken'ichi Ohmichi | c85a951 | 2017-01-27 18:34:24 -0800 | [diff] [blame] | 21 | from tempest.lib import decorators |
Sean Dague | 6dbc6da | 2013-05-08 17:49:46 -0400 | [diff] [blame] | 22 | from tempest.scenario import manager |
Masayuki Igawa | 4ded9f0 | 2014-02-17 15:05:59 +0900 | [diff] [blame] | 23 | from tempest import test |
Jay Pipes | 051075a | 2012-04-28 17:39:37 -0400 | [diff] [blame] | 24 | |
Matthew Treinish | 6c07229 | 2014-01-29 19:15:52 +0000 | [diff] [blame] | 25 | CONF = config.CONF |
| 26 | |
Jay Pipes | 051075a | 2012-04-28 17:39:37 -0400 | [diff] [blame] | 27 | LOG = logging.getLogger(__name__) |
| 28 | |
| 29 | |
Ghanshyam | aadf036 | 2014-08-27 16:51:26 +0900 | [diff] [blame] | 30 | class TestServerAdvancedOps(manager.ScenarioTest): |
Jay Pipes | 051075a | 2012-04-28 17:39:37 -0400 | [diff] [blame] | 31 | |
Ken'ichi Ohmichi | c4e4f1c | 2015-11-17 08:16:12 +0000 | [diff] [blame] | 32 | """The test suite for server advanced operations |
Jay Pipes | 051075a | 2012-04-28 17:39:37 -0400 | [diff] [blame] | 33 | |
Ken'ichi Ohmichi | c4e4f1c | 2015-11-17 08:16:12 +0000 | [diff] [blame] | 34 | This test case stresses some advanced server instance operations: |
Matt Riedemann | 6506f90 | 2016-05-10 20:37:15 -0400 | [diff] [blame] | 35 | * Resizing a volume-backed instance |
Tatyana Leontovich | 58ab531 | 2013-04-22 16:48:33 +0300 | [diff] [blame] | 36 | * Sequence suspend resume |
Jay Pipes | 051075a | 2012-04-28 17:39:37 -0400 | [diff] [blame] | 37 | """ |
| 38 | |
| 39 | @classmethod |
Emily Hugenbruch | 5e2d2a2 | 2015-02-25 21:35:45 +0000 | [diff] [blame] | 40 | def setup_credentials(cls): |
Masayuki Igawa | 60ea6c5 | 2014-10-15 17:32:14 +0900 | [diff] [blame] | 41 | cls.set_network_resources() |
Emily Hugenbruch | 5e2d2a2 | 2015-02-25 21:35:45 +0000 | [diff] [blame] | 42 | super(TestServerAdvancedOps, cls).setup_credentials() |
Jay Pipes | 051075a | 2012-04-28 17:39:37 -0400 | [diff] [blame] | 43 | |
Sean Dague | 49505df | 2017-03-01 11:35:58 -0500 | [diff] [blame] | 44 | @test.attr(type='slow') |
Ken'ichi Ohmichi | c85a951 | 2017-01-27 18:34:24 -0800 | [diff] [blame] | 45 | @decorators.idempotent_id('e6c28180-7454-4b59-b188-0257af08a63b') |
armando-migliaccio | 9e5eac0 | 2014-03-24 10:55:31 -0700 | [diff] [blame] | 46 | @testtools.skipUnless(CONF.compute_feature_enabled.resize, |
| 47 | 'Resize is not available.') |
zhufl | 7531e98 | 2017-02-23 15:45:19 +0800 | [diff] [blame] | 48 | @testtools.skipUnless(CONF.compute.flavor_ref != |
| 49 | CONF.compute.flavor_ref_alt |
| 50 | and CONF.compute.flavor_ref_alt != "", |
| 51 | 'The flavor_ref_alt option should not be empty and ' |
| 52 | 'should not be identical with flavor_ref') |
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 |
zhufl | 13c9c89 | 2017-02-10 12:04:07 +0800 | [diff] [blame] | 56 | instance = self.create_server(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 | |
Sean Dague | 49505df | 2017-03-01 11:35:58 -0500 | [diff] [blame] | 71 | @test.attr(type='slow') |
Ken'ichi Ohmichi | c85a951 | 2017-01-27 18:34:24 -0800 | [diff] [blame] | 72 | @decorators.idempotent_id('949da7d5-72c8-4808-8802-e3d70df98e2c') |
armando-migliaccio | 9e5eac0 | 2014-03-24 10:55:31 -0700 | [diff] [blame] | 73 | @testtools.skipUnless(CONF.compute_feature_enabled.suspend, |
| 74 | 'Suspend is not available.') |
Masayuki Igawa | 4ded9f0 | 2014-02-17 15:05:59 +0900 | [diff] [blame] | 75 | @test.services('compute') |
Tatyana Leontovich | 58ab531 | 2013-04-22 16:48:33 +0300 | [diff] [blame] | 76 | def test_server_sequence_suspend_resume(self): |
| 77 | # We create an instance for use in this test |
zhufl | 96daca7 | 2017-02-22 17:59:56 +0800 | [diff] [blame] | 78 | instance_id = self.create_server()['id'] |
| 79 | |
| 80 | for _ in range(2): |
| 81 | LOG.debug("Suspending instance %s", instance_id) |
| 82 | self.servers_client.suspend_server(instance_id) |
| 83 | waiters.wait_for_server_status(self.servers_client, instance_id, |
| 84 | 'SUSPENDED') |
| 85 | |
| 86 | LOG.debug("Resuming instance %s", instance_id) |
| 87 | self.servers_client.resume_server(instance_id) |
| 88 | waiters.wait_for_server_status(self.servers_client, instance_id, |
| 89 | 'ACTIVE') |