blob: f45f0c9bd3a924993a3080e4bec30d4609f24a6c [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
Matthew Treinish6c072292014-01-29 19:15:52 +000019from tempest import config
Sean Dague6dbc6da2013-05-08 17:49:46 -040020from tempest.scenario import manager
Masayuki Igawa4ded9f02014-02-17 15:05:59 +090021from tempest import test
Jay Pipes051075a2012-04-28 17:39:37 -040022
Matthew Treinish6c072292014-01-29 19:15:52 +000023CONF = config.CONF
24
Jay Pipes051075a2012-04-28 17:39:37 -040025LOG = logging.getLogger(__name__)
26
27
Ghanshyamaadf0362014-08-27 16:51:26 +090028class TestServerAdvancedOps(manager.ScenarioTest):
Jay Pipes051075a2012-04-28 17:39:37 -040029
30 """
31 This test case stresses some advanced server instance operations:
32
33 * Resizing an instance
Tatyana Leontovich58ab5312013-04-22 16:48:33 +030034 * Sequence suspend resume
Jay Pipes051075a2012-04-28 17:39:37 -040035 """
36
37 @classmethod
Emily Hugenbruch5e2d2a22015-02-25 21:35:45 +000038 def skip_checks(cls):
39 super(TestServerAdvancedOps, cls).skip_checks()
armando-migliaccio9e5eac02014-03-24 10:55:31 -070040 if CONF.compute.flavor_ref_alt == CONF.compute.flavor_ref:
Jay Pipes051075a2012-04-28 17:39:37 -040041 msg = "Skipping test - flavor_ref and flavor_ref_alt are identical"
ivan-zhu1feeb382013-01-24 10:14:39 +080042 raise cls.skipException(msg)
Emily Hugenbruch5e2d2a22015-02-25 21:35:45 +000043
44 @classmethod
45 def setup_credentials(cls):
Masayuki Igawa60ea6c52014-10-15 17:32:14 +090046 cls.set_network_resources()
Emily Hugenbruch5e2d2a22015-02-25 21:35:45 +000047 super(TestServerAdvancedOps, cls).setup_credentials()
Jay Pipes051075a2012-04-28 17:39:37 -040048
Chris Hoge7579c1a2015-02-26 14:12:15 -080049 @test.idempotent_id('e6c28180-7454-4b59-b188-0257af08a63b')
armando-migliaccio9e5eac02014-03-24 10:55:31 -070050 @testtools.skipUnless(CONF.compute_feature_enabled.resize,
51 'Resize is not available.')
Masayuki Igawa4ded9f02014-02-17 15:05:59 +090052 @test.services('compute')
Jay Pipes051075a2012-04-28 17:39:37 -040053 def test_resize_server_confirm(self):
54 # We create an instance for use in this test
Giulio Fidente61cadca2013-09-24 18:33:37 +020055 instance = self.create_server()
Ghanshyamaadf0362014-08-27 16:51:26 +090056 instance_id = instance['id']
Matthew Treinish6c072292014-01-29 19:15:52 +000057 resize_flavor = CONF.compute.flavor_ref_alt
Jay Pipes051075a2012-04-28 17:39:37 -040058 LOG.debug("Resizing instance %s from flavor %s to flavor %s",
Ghanshyamaadf0362014-08-27 16:51:26 +090059 instance['id'], instance['flavor']['id'], resize_flavor)
60 self.servers_client.resize(instance_id, resize_flavor)
61 self.servers_client.wait_for_server_status(instance_id,
62 'VERIFY_RESIZE')
Jay Pipes051075a2012-04-28 17:39:37 -040063
64 LOG.debug("Confirming resize of instance %s", instance_id)
Ghanshyamaadf0362014-08-27 16:51:26 +090065 self.servers_client.confirm_resize(instance_id)
Tatyana Leontovich58ab5312013-04-22 16:48:33 +030066
Ghanshyamaadf0362014-08-27 16:51:26 +090067 self.servers_client.wait_for_server_status(instance_id,
68 'ACTIVE')
Tatyana Leontovich58ab5312013-04-22 16:48:33 +030069
Chris Hoge7579c1a2015-02-26 14:12:15 -080070 @test.idempotent_id('949da7d5-72c8-4808-8802-e3d70df98e2c')
armando-migliaccio9e5eac02014-03-24 10:55:31 -070071 @testtools.skipUnless(CONF.compute_feature_enabled.suspend,
72 'Suspend is not available.')
Masayuki Igawa4ded9f02014-02-17 15:05:59 +090073 @test.services('compute')
Tatyana Leontovich58ab5312013-04-22 16:48:33 +030074 def test_server_sequence_suspend_resume(self):
75 # We create an instance for use in this test
Giulio Fidente61cadca2013-09-24 18:33:37 +020076 instance = self.create_server()
Ghanshyamaadf0362014-08-27 16:51:26 +090077 instance_id = instance['id']
Tatyana Leontovich58ab5312013-04-22 16:48:33 +030078 LOG.debug("Suspending instance %s. Current status: %s",
Ghanshyamaadf0362014-08-27 16:51:26 +090079 instance_id, instance['status'])
80 self.servers_client.suspend_server(instance_id)
81 self.servers_client.wait_for_server_status(instance_id,
82 'SUSPENDED')
David Kranz0fb14292015-02-11 15:55:20 -050083 fetched_instance = self.servers_client.get_server(instance_id)
Tatyana Leontovich58ab5312013-04-22 16:48:33 +030084 LOG.debug("Resuming instance %s. Current status: %s",
Ghanshyamaadf0362014-08-27 16:51:26 +090085 instance_id, fetched_instance['status'])
86 self.servers_client.resume_server(instance_id)
87 self.servers_client.wait_for_server_status(instance_id,
88 'ACTIVE')
David Kranz0fb14292015-02-11 15:55:20 -050089 fetched_instance = self.servers_client.get_server(instance_id)
Tatyana Leontovich58ab5312013-04-22 16:48:33 +030090 LOG.debug("Suspending instance %s. Current status: %s",
Ghanshyamaadf0362014-08-27 16:51:26 +090091 instance_id, fetched_instance['status'])
92 self.servers_client.suspend_server(instance_id)
93 self.servers_client.wait_for_server_status(instance_id,
94 'SUSPENDED')
David Kranz0fb14292015-02-11 15:55:20 -050095 fetched_instance = self.servers_client.get_server(instance_id)
Tatyana Leontovich58ab5312013-04-22 16:48:33 +030096 LOG.debug("Resuming instance %s. Current status: %s",
Ghanshyamaadf0362014-08-27 16:51:26 +090097 instance_id, fetched_instance['status'])
98 self.servers_client.resume_server(instance_id)
99 self.servers_client.wait_for_server_status(instance_id,
100 'ACTIVE')