blob: 1c2246ddaaa785e78a887694759b77bca87dc4a7 [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 -070017
Andrea Frittolicd368412017-08-14 21:37:56 +010018from tempest.common import utils
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
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:
Tatyana Leontovich58ab5312013-04-22 16:48:33 +030034 * Sequence suspend resume
Jay Pipes051075a2012-04-28 17:39:37 -040035 """
36
37 @classmethod
Ghanshyam Mannfd90dac2023-08-03 16:26:44 -070038 def skip_checks(cls):
39 super(TestServerAdvancedOps, cls).skip_checks()
40 if not CONF.service_available.nova:
41 skip_msg = ("%s skipped as Nova is not available" % cls.__name__)
42 raise cls.skipException(skip_msg)
43 if not CONF.compute_feature_enabled.suspend:
44 raise cls.skipException("Suspend is not available.")
45
46 @classmethod
Emily Hugenbruch5e2d2a22015-02-25 21:35:45 +000047 def setup_credentials(cls):
Ghanshyam Mannf5aef7b2021-02-08 16:58:07 -060048 cls.set_network_resources(network=True, subnet=True)
Emily Hugenbruch5e2d2a22015-02-25 21:35:45 +000049 super(TestServerAdvancedOps, cls).setup_credentials()
Jay Pipes051075a2012-04-28 17:39:37 -040050
Jordan Pittier3b46d272017-04-12 16:17:28 +020051 @decorators.attr(type='slow')
Ken'ichi Ohmichic85a9512017-01-27 18:34:24 -080052 @decorators.idempotent_id('949da7d5-72c8-4808-8802-e3d70df98e2c')
Andrea Frittolicd368412017-08-14 21:37:56 +010053 @utils.services('compute')
Tatyana Leontovich58ab5312013-04-22 16:48:33 +030054 def test_server_sequence_suspend_resume(self):
55 # We create an instance for use in this test
zhufl96daca72017-02-22 17:59:56 +080056 instance_id = self.create_server()['id']
57
58 for _ in range(2):
59 LOG.debug("Suspending instance %s", instance_id)
60 self.servers_client.suspend_server(instance_id)
61 waiters.wait_for_server_status(self.servers_client, instance_id,
62 'SUSPENDED')
63
64 LOG.debug("Resuming instance %s", instance_id)
65 self.servers_client.resume_server(instance_id)
66 waiters.wait_for_server_status(self.servers_client, instance_id,
67 'ACTIVE')