blob: cc3687f1628209232f31d7775beaccaa8d2a1bda [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
Ken'ichi Ohmichic85a9512017-01-27 18:34:24 -080021from tempest.lib import decorators
Sean Dague6dbc6da2013-05-08 17:49:46 -040022from tempest.scenario import manager
Masayuki Igawa4ded9f02014-02-17 15:05:59 +090023from tempest import test
Jay Pipes051075a2012-04-28 17:39:37 -040024
Matthew Treinish6c072292014-01-29 19:15:52 +000025CONF = config.CONF
26
Jay Pipes051075a2012-04-28 17:39:37 -040027LOG = logging.getLogger(__name__)
28
29
Ghanshyamaadf0362014-08-27 16:51:26 +090030class TestServerAdvancedOps(manager.ScenarioTest):
Jay Pipes051075a2012-04-28 17:39:37 -040031
Ken'ichi Ohmichic4e4f1c2015-11-17 08:16:12 +000032 """The test suite for server advanced operations
Jay Pipes051075a2012-04-28 17:39:37 -040033
Ken'ichi Ohmichic4e4f1c2015-11-17 08:16:12 +000034 This test case stresses some advanced server instance operations:
Matt Riedemann6506f902016-05-10 20:37:15 -040035 * Resizing a volume-backed instance
Tatyana Leontovich58ab5312013-04-22 16:48:33 +030036 * Sequence suspend resume
Jay Pipes051075a2012-04-28 17:39:37 -040037 """
38
39 @classmethod
Emily Hugenbruch5e2d2a22015-02-25 21:35:45 +000040 def setup_credentials(cls):
Masayuki Igawa60ea6c52014-10-15 17:32:14 +090041 cls.set_network_resources()
Emily Hugenbruch5e2d2a22015-02-25 21:35:45 +000042 super(TestServerAdvancedOps, cls).setup_credentials()
Jay Pipes051075a2012-04-28 17:39:37 -040043
Sean Dague49505df2017-03-01 11:35:58 -050044 @test.attr(type='slow')
Ken'ichi Ohmichic85a9512017-01-27 18:34:24 -080045 @decorators.idempotent_id('e6c28180-7454-4b59-b188-0257af08a63b')
armando-migliaccio9e5eac02014-03-24 10:55:31 -070046 @testtools.skipUnless(CONF.compute_feature_enabled.resize,
47 'Resize is not available.')
zhufl7531e982017-02-23 15:45:19 +080048 @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 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
zhufl13c9c892017-02-10 12:04:07 +080056 instance = self.create_server(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
Sean Dague49505df2017-03-01 11:35:58 -050071 @test.attr(type='slow')
Ken'ichi Ohmichic85a9512017-01-27 18:34:24 -080072 @decorators.idempotent_id('949da7d5-72c8-4808-8802-e3d70df98e2c')
armando-migliaccio9e5eac02014-03-24 10:55:31 -070073 @testtools.skipUnless(CONF.compute_feature_enabled.suspend,
74 'Suspend is not available.')
Masayuki Igawa4ded9f02014-02-17 15:05:59 +090075 @test.services('compute')
Tatyana Leontovich58ab5312013-04-22 16:48:33 +030076 def test_server_sequence_suspend_resume(self):
77 # We create an instance for use in this test
zhufl96daca72017-02-22 17:59:56 +080078 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')