blob: 504d72b34f3f095bfa65465fca53debf9ddfa2aa [file] [log] [blame]
ZhiQiang Fan39f97222013-09-20 04:49:44 +08001# Copyright 2012 OpenStack Foundation
Jay Pipes051075a2012-04-28 17:39:37 -04002# 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 Hellmann583ce2c2015-03-11 14:55:46 +000016from oslo_log import log as logging
armando-migliaccio9e5eac02014-03-24 10:55:31 -070017import testtools
18
Ken'ichi Ohmichi0eb153c2015-07-13 02:18:25 +000019from tempest.common import waiters
Matthew Treinish6c072292014-01-29 19:15:52 +000020from tempest import config
Sean Dague6dbc6da2013-05-08 17:49:46 -040021from tempest.scenario import manager
Masayuki Igawa4ded9f02014-02-17 15:05:59 +090022from tempest import test
Jay Pipes051075a2012-04-28 17:39:37 -040023
Matthew Treinish6c072292014-01-29 19:15:52 +000024CONF = config.CONF
25
Jay Pipes051075a2012-04-28 17:39:37 -040026LOG = logging.getLogger(__name__)
27
28
Ghanshyamaadf0362014-08-27 16:51:26 +090029class TestServerAdvancedOps(manager.ScenarioTest):
Jay Pipes051075a2012-04-28 17:39:37 -040030
Ken'ichi Ohmichic4e4f1c2015-11-17 08:16:12 +000031 """The test suite for server advanced operations
Jay Pipes051075a2012-04-28 17:39:37 -040032
Ken'ichi Ohmichic4e4f1c2015-11-17 08:16:12 +000033 This test case stresses some advanced server instance operations:
Matt Riedemann6506f902016-05-10 20:37:15 -040034 * Resizing a volume-backed instance
Tatyana Leontovich58ab5312013-04-22 16:48:33 +030035 * Sequence suspend resume
Jay Pipes051075a2012-04-28 17:39:37 -040036 """
37
38 @classmethod
Emily Hugenbruch5e2d2a22015-02-25 21:35:45 +000039 def skip_checks(cls):
40 super(TestServerAdvancedOps, cls).skip_checks()
armando-migliaccio9e5eac02014-03-24 10:55:31 -070041 if CONF.compute.flavor_ref_alt == CONF.compute.flavor_ref:
Jay Pipes051075a2012-04-28 17:39:37 -040042 msg = "Skipping test - flavor_ref and flavor_ref_alt are identical"
ivan-zhu1feeb382013-01-24 10:14:39 +080043 raise cls.skipException(msg)
Emily Hugenbruch5e2d2a22015-02-25 21:35:45 +000044
45 @classmethod
46 def setup_credentials(cls):
Masayuki Igawa60ea6c52014-10-15 17:32:14 +090047 cls.set_network_resources()
Emily Hugenbruch5e2d2a22015-02-25 21:35:45 +000048 super(TestServerAdvancedOps, cls).setup_credentials()
Jay Pipes051075a2012-04-28 17:39:37 -040049
Chris Hoge7579c1a2015-02-26 14:12:15 -080050 @test.idempotent_id('e6c28180-7454-4b59-b188-0257af08a63b')
armando-migliaccio9e5eac02014-03-24 10:55:31 -070051 @testtools.skipUnless(CONF.compute_feature_enabled.resize,
52 'Resize is not available.')
Matt Riedemann6506f902016-05-10 20:37:15 -040053 @test.services('compute', 'volume')
54 def test_resize_volume_backed_server_confirm(self):
Jay Pipes051075a2012-04-28 17:39:37 -040055 # We create an instance for use in this test
Matt Riedemann6506f902016-05-10 20:37:15 -040056 instance = self.create_server(wait_until='ACTIVE', volume_backed=True)
Ghanshyamaadf0362014-08-27 16:51:26 +090057 instance_id = instance['id']
Matthew Treinish6c072292014-01-29 19:15:52 +000058 resize_flavor = CONF.compute.flavor_ref_alt
Jay Pipes051075a2012-04-28 17:39:37 -040059 LOG.debug("Resizing instance %s from flavor %s to flavor %s",
Ghanshyamaadf0362014-08-27 16:51:26 +090060 instance['id'], instance['flavor']['id'], resize_flavor)
Ken'ichi Ohmichi5271b0f2015-08-10 07:53:27 +000061 self.servers_client.resize_server(instance_id, resize_flavor)
Ken'ichi Ohmichi0eb153c2015-07-13 02:18:25 +000062 waiters.wait_for_server_status(self.servers_client, instance_id,
63 'VERIFY_RESIZE')
Jay Pipes051075a2012-04-28 17:39:37 -040064
65 LOG.debug("Confirming resize of instance %s", instance_id)
Ken'ichi Ohmichib2631082015-08-27 01:31:00 +000066 self.servers_client.confirm_resize_server(instance_id)
Tatyana Leontovich58ab5312013-04-22 16:48:33 +030067
Ken'ichi Ohmichi0eb153c2015-07-13 02:18:25 +000068 waiters.wait_for_server_status(self.servers_client, instance_id,
69 'ACTIVE')
Tatyana Leontovich58ab5312013-04-22 16:48:33 +030070
Chris Hoge7579c1a2015-02-26 14:12:15 -080071 @test.idempotent_id('949da7d5-72c8-4808-8802-e3d70df98e2c')
armando-migliaccio9e5eac02014-03-24 10:55:31 -070072 @testtools.skipUnless(CONF.compute_feature_enabled.suspend,
73 'Suspend is not available.')
Masayuki Igawa4ded9f02014-02-17 15:05:59 +090074 @test.services('compute')
Tatyana Leontovich58ab5312013-04-22 16:48:33 +030075 def test_server_sequence_suspend_resume(self):
76 # We create an instance for use in this test
lanoux5fc14522015-09-21 08:17:35 +000077 instance = self.create_server(wait_until='ACTIVE')
Ghanshyamaadf0362014-08-27 16:51:26 +090078 instance_id = instance['id']
Tatyana Leontovich58ab5312013-04-22 16:48:33 +030079 LOG.debug("Suspending instance %s. Current status: %s",
Ghanshyamaadf0362014-08-27 16:51:26 +090080 instance_id, instance['status'])
81 self.servers_client.suspend_server(instance_id)
Ken'ichi Ohmichi0eb153c2015-07-13 02:18:25 +000082 waiters.wait_for_server_status(self.servers_client, instance_id,
83 'SUSPENDED')
ghanshyam0f825252015-08-25 16:02:50 +090084 fetched_instance = (self.servers_client.show_server(instance_id)
85 ['server'])
Tatyana Leontovich58ab5312013-04-22 16:48:33 +030086 LOG.debug("Resuming instance %s. Current status: %s",
Ghanshyamaadf0362014-08-27 16:51:26 +090087 instance_id, fetched_instance['status'])
88 self.servers_client.resume_server(instance_id)
Ken'ichi Ohmichi0eb153c2015-07-13 02:18:25 +000089 waiters.wait_for_server_status(self.servers_client, instance_id,
90 'ACTIVE')
ghanshyam0f825252015-08-25 16:02:50 +090091 fetched_instance = (self.servers_client.show_server(instance_id)
92 ['server'])
Tatyana Leontovich58ab5312013-04-22 16:48:33 +030093 LOG.debug("Suspending instance %s. Current status: %s",
Ghanshyamaadf0362014-08-27 16:51:26 +090094 instance_id, fetched_instance['status'])
95 self.servers_client.suspend_server(instance_id)
Ken'ichi Ohmichi0eb153c2015-07-13 02:18:25 +000096 waiters.wait_for_server_status(self.servers_client, instance_id,
97 'SUSPENDED')
ghanshyam0f825252015-08-25 16:02:50 +090098 fetched_instance = (self.servers_client.show_server(instance_id)
99 ['server'])
Tatyana Leontovich58ab5312013-04-22 16:48:33 +0300100 LOG.debug("Resuming instance %s. Current status: %s",
Ghanshyamaadf0362014-08-27 16:51:26 +0900101 instance_id, fetched_instance['status'])
102 self.servers_client.resume_server(instance_id)
Ken'ichi Ohmichi0eb153c2015-07-13 02:18:25 +0000103 waiters.wait_for_server_status(self.servers_client, instance_id,
104 'ACTIVE')