blob: c0eb6e774bea0b6a399f579e101f4adf32303bf4 [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
Matthew Treinish6c072292014-01-29 19:15:52 +000016from tempest import config
Matthew Treinishf4a9b0f2013-07-26 16:58:26 -040017from tempest.openstack.common import log as logging
Sean Dague6dbc6da2013-05-08 17:49:46 -040018from tempest.scenario import manager
Masayuki Igawa4ded9f02014-02-17 15:05:59 +090019from tempest import test
Jay Pipes051075a2012-04-28 17:39:37 -040020
Matthew Treinish6c072292014-01-29 19:15:52 +000021CONF = config.CONF
22
Jay Pipes051075a2012-04-28 17:39:37 -040023LOG = logging.getLogger(__name__)
24
25
Sean Dague6dbc6da2013-05-08 17:49:46 -040026class TestServerAdvancedOps(manager.OfficialClientTest):
Jay Pipes051075a2012-04-28 17:39:37 -040027
28 """
29 This test case stresses some advanced server instance operations:
30
31 * Resizing an instance
Tatyana Leontovich58ab5312013-04-22 16:48:33 +030032 * Sequence suspend resume
Jay Pipes051075a2012-04-28 17:39:37 -040033 """
34
35 @classmethod
36 def setUpClass(cls):
Sylvain Afchain92064772014-01-16 02:45:57 +010037 cls.set_network_resources()
Jay Pipes051075a2012-04-28 17:39:37 -040038 super(TestServerAdvancedOps, cls).setUpClass()
39
Matthew Treinish6c072292014-01-29 19:15:52 +000040 if not CONF.compute_feature_enabled.resize:
Jay Pipes051075a2012-04-28 17:39:37 -040041 msg = "Skipping test - resize not available on this host"
ivan-zhu1feeb382013-01-24 10:14:39 +080042 raise cls.skipException(msg)
Jay Pipes051075a2012-04-28 17:39:37 -040043
Matthew Treinish6c072292014-01-29 19:15:52 +000044 resize_flavor = CONF.compute.flavor_ref_alt
Jay Pipes051075a2012-04-28 17:39:37 -040045
Matthew Treinish6c072292014-01-29 19:15:52 +000046 if resize_flavor == CONF.compute.flavor_ref:
Jay Pipes051075a2012-04-28 17:39:37 -040047 msg = "Skipping test - flavor_ref and flavor_ref_alt are identical"
ivan-zhu1feeb382013-01-24 10:14:39 +080048 raise cls.skipException(msg)
Jay Pipes051075a2012-04-28 17:39:37 -040049
Masayuki Igawa4ded9f02014-02-17 15:05:59 +090050 @test.services('compute')
Jay Pipes051075a2012-04-28 17:39:37 -040051 def test_resize_server_confirm(self):
52 # We create an instance for use in this test
Giulio Fidente61cadca2013-09-24 18:33:37 +020053 instance = self.create_server()
Jay Pipes051075a2012-04-28 17:39:37 -040054 instance_id = instance.id
Matthew Treinish6c072292014-01-29 19:15:52 +000055 resize_flavor = CONF.compute.flavor_ref_alt
Jay Pipes051075a2012-04-28 17:39:37 -040056 LOG.debug("Resizing instance %s from flavor %s to flavor %s",
57 instance.id, instance.flavor, resize_flavor)
58 instance.resize(resize_flavor)
Sean Dague35a7caf2013-05-10 10:38:22 -040059 self.status_timeout(self.compute_client.servers, instance_id,
Maru Newbydec13ec2012-08-30 11:19:17 -070060 'VERIFY_RESIZE')
Jay Pipes051075a2012-04-28 17:39:37 -040061
62 LOG.debug("Confirming resize of instance %s", instance_id)
63 instance.confirm_resize()
Tatyana Leontovich58ab5312013-04-22 16:48:33 +030064
Sean Dague35a7caf2013-05-10 10:38:22 -040065 self.status_timeout(
66 self.compute_client.servers, instance_id, 'ACTIVE')
Tatyana Leontovich58ab5312013-04-22 16:48:33 +030067
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()
Tatyana Leontovich58ab5312013-04-22 16:48:33 +030072 instance_id = instance.id
73 LOG.debug("Suspending instance %s. Current status: %s",
74 instance_id, instance.status)
75 instance.suspend()
76 self.status_timeout(self.compute_client.servers, instance_id,
77 'SUSPENDED')
78 LOG.debug("Resuming instance %s. Current status: %s",
79 instance_id, instance.status)
80 instance.resume()
81 self.status_timeout(self.compute_client.servers, instance_id,
82 'ACTIVE')
83 LOG.debug("Suspending instance %s. Current status: %s",
84 instance_id, instance.status)
85 instance.suspend()
86 self.status_timeout(self.compute_client.servers, instance_id,
87 'SUSPENDED')
88 LOG.debug("Resuming instance %s. Current status: %s",
89 instance_id, instance.status)
90 instance.resume()
91 self.status_timeout(self.compute_client.servers, instance_id,
92 'ACTIVE')