blob: c53e22bd1dcea9a0ee323fa3d68c648b3acfa5c0 [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
armando-migliaccio9e5eac02014-03-24 10:55:31 -070016import testtools
17
Matthew Treinish6c072292014-01-29 19:15:52 +000018from tempest import config
Matthew Treinishf4a9b0f2013-07-26 16:58:26 -040019from tempest.openstack.common import log as logging
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
Andrea Frittoliac20b5e2014-09-15 13:31:14 +010038 def resource_setup(cls):
Sylvain Afchain92064772014-01-16 02:45:57 +010039 cls.set_network_resources()
Andrea Frittoliac20b5e2014-09-15 13:31:14 +010040 super(TestServerAdvancedOps, cls).resource_setup()
Jay Pipes051075a2012-04-28 17:39:37 -040041
armando-migliaccio9e5eac02014-03-24 10:55:31 -070042 if CONF.compute.flavor_ref_alt == CONF.compute.flavor_ref:
Jay Pipes051075a2012-04-28 17:39:37 -040043 msg = "Skipping test - flavor_ref and flavor_ref_alt are identical"
ivan-zhu1feeb382013-01-24 10:14:39 +080044 raise cls.skipException(msg)
Jay Pipes051075a2012-04-28 17:39:37 -040045
armando-migliaccio9e5eac02014-03-24 10:55:31 -070046 @testtools.skipUnless(CONF.compute_feature_enabled.resize,
47 'Resize is not available.')
Masayuki Igawa4ded9f02014-02-17 15:05:59 +090048 @test.services('compute')
Jay Pipes051075a2012-04-28 17:39:37 -040049 def test_resize_server_confirm(self):
50 # We create an instance for use in this test
Giulio Fidente61cadca2013-09-24 18:33:37 +020051 instance = self.create_server()
Ghanshyamaadf0362014-08-27 16:51:26 +090052 instance_id = instance['id']
Matthew Treinish6c072292014-01-29 19:15:52 +000053 resize_flavor = CONF.compute.flavor_ref_alt
Jay Pipes051075a2012-04-28 17:39:37 -040054 LOG.debug("Resizing instance %s from flavor %s to flavor %s",
Ghanshyamaadf0362014-08-27 16:51:26 +090055 instance['id'], instance['flavor']['id'], resize_flavor)
56 self.servers_client.resize(instance_id, resize_flavor)
57 self.servers_client.wait_for_server_status(instance_id,
58 'VERIFY_RESIZE')
Jay Pipes051075a2012-04-28 17:39:37 -040059
60 LOG.debug("Confirming resize of instance %s", instance_id)
Ghanshyamaadf0362014-08-27 16:51:26 +090061 self.servers_client.confirm_resize(instance_id)
Tatyana Leontovich58ab5312013-04-22 16:48:33 +030062
Ghanshyamaadf0362014-08-27 16:51:26 +090063 self.servers_client.wait_for_server_status(instance_id,
64 'ACTIVE')
Tatyana Leontovich58ab5312013-04-22 16:48:33 +030065
armando-migliaccio9e5eac02014-03-24 10:55:31 -070066 @testtools.skipUnless(CONF.compute_feature_enabled.suspend,
67 'Suspend is not available.')
Masayuki Igawa4ded9f02014-02-17 15:05:59 +090068 @test.services('compute')
Tatyana Leontovich58ab5312013-04-22 16:48:33 +030069 def test_server_sequence_suspend_resume(self):
70 # We create an instance for use in this test
Giulio Fidente61cadca2013-09-24 18:33:37 +020071 instance = self.create_server()
Ghanshyamaadf0362014-08-27 16:51:26 +090072 instance_id = instance['id']
Tatyana Leontovich58ab5312013-04-22 16:48:33 +030073 LOG.debug("Suspending instance %s. Current status: %s",
Ghanshyamaadf0362014-08-27 16:51:26 +090074 instance_id, instance['status'])
75 self.servers_client.suspend_server(instance_id)
76 self.servers_client.wait_for_server_status(instance_id,
77 'SUSPENDED')
78 _, fetched_instance = self.servers_client.get_server(instance_id)
Tatyana Leontovich58ab5312013-04-22 16:48:33 +030079 LOG.debug("Resuming instance %s. Current status: %s",
Ghanshyamaadf0362014-08-27 16:51:26 +090080 instance_id, fetched_instance['status'])
81 self.servers_client.resume_server(instance_id)
82 self.servers_client.wait_for_server_status(instance_id,
83 'ACTIVE')
84 _, fetched_instance = self.servers_client.get_server(instance_id)
Tatyana Leontovich58ab5312013-04-22 16:48:33 +030085 LOG.debug("Suspending instance %s. Current status: %s",
Ghanshyamaadf0362014-08-27 16:51:26 +090086 instance_id, fetched_instance['status'])
87 self.servers_client.suspend_server(instance_id)
88 self.servers_client.wait_for_server_status(instance_id,
89 'SUSPENDED')
90 _, fetched_instance = self.servers_client.get_server(instance_id)
Tatyana Leontovich58ab5312013-04-22 16:48:33 +030091 LOG.debug("Resuming instance %s. Current status: %s",
Ghanshyamaadf0362014-08-27 16:51:26 +090092 instance_id, fetched_instance['status'])
93 self.servers_client.resume_server(instance_id)
94 self.servers_client.wait_for_server_status(instance_id,
95 'ACTIVE')