blob: 112c8a2b07780c3709145ff22a593445b2d17042 [file] [log] [blame]
Jay Pipes051075a2012-04-28 17:39:37 -04001# vim: tabstop=4 shiftwidth=4 softtabstop=4
2
ZhiQiang Fan39f97222013-09-20 04:49:44 +08003# Copyright 2012 OpenStack Foundation
Jay Pipes051075a2012-04-28 17:39:37 -04004# All Rights Reserved.
5#
6# Licensed under the Apache License, Version 2.0 (the "License"); you may
7# not use this file except in compliance with the License. You may obtain
8# a copy of the License at
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15# License for the specific language governing permissions and limitations
16# under the License.
17
Matthew Treinishf4a9b0f2013-07-26 16:58:26 -040018from tempest.openstack.common import log as logging
Sean Dague6dbc6da2013-05-08 17:49:46 -040019from tempest.scenario import manager
Matthew Treinish2153ec02013-09-09 20:57:30 +000020from tempest.test import services
Jay Pipes051075a2012-04-28 17:39:37 -040021
22LOG = logging.getLogger(__name__)
23
24
Sean Dague6dbc6da2013-05-08 17:49:46 -040025class TestServerAdvancedOps(manager.OfficialClientTest):
Jay Pipes051075a2012-04-28 17:39:37 -040026
27 """
28 This test case stresses some advanced server instance operations:
29
30 * Resizing an instance
Tatyana Leontovich58ab5312013-04-22 16:48:33 +030031 * Sequence suspend resume
Jay Pipes051075a2012-04-28 17:39:37 -040032 """
33
34 @classmethod
35 def setUpClass(cls):
36 super(TestServerAdvancedOps, cls).setUpClass()
37
Matthew Treinishd5c96022013-10-17 21:51:23 +000038 if not cls.config.compute_feature_enabled.resize:
Jay Pipes051075a2012-04-28 17:39:37 -040039 msg = "Skipping test - resize not available on this host"
ivan-zhu1feeb382013-01-24 10:14:39 +080040 raise cls.skipException(msg)
Jay Pipes051075a2012-04-28 17:39:37 -040041
42 resize_flavor = cls.config.compute.flavor_ref_alt
43
44 if resize_flavor == cls.config.compute.flavor_ref:
45 msg = "Skipping test - flavor_ref and flavor_ref_alt are identical"
ivan-zhu1feeb382013-01-24 10:14:39 +080046 raise cls.skipException(msg)
Jay Pipes051075a2012-04-28 17:39:37 -040047
Matthew Treinish2153ec02013-09-09 20:57:30 +000048 @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()
Jay Pipes051075a2012-04-28 17:39:37 -040052 instance_id = instance.id
53 resize_flavor = self.config.compute.flavor_ref_alt
Jay Pipes051075a2012-04-28 17:39:37 -040054 LOG.debug("Resizing instance %s from flavor %s to flavor %s",
55 instance.id, instance.flavor, resize_flavor)
56 instance.resize(resize_flavor)
Sean Dague35a7caf2013-05-10 10:38:22 -040057 self.status_timeout(self.compute_client.servers, instance_id,
Maru Newbydec13ec2012-08-30 11:19:17 -070058 'VERIFY_RESIZE')
Jay Pipes051075a2012-04-28 17:39:37 -040059
60 LOG.debug("Confirming resize of instance %s", instance_id)
61 instance.confirm_resize()
Tatyana Leontovich58ab5312013-04-22 16:48:33 +030062
Sean Dague35a7caf2013-05-10 10:38:22 -040063 self.status_timeout(
64 self.compute_client.servers, instance_id, 'ACTIVE')
Tatyana Leontovich58ab5312013-04-22 16:48:33 +030065
Matthew Treinish2153ec02013-09-09 20:57:30 +000066 @services('compute')
Tatyana Leontovich58ab5312013-04-22 16:48:33 +030067 def test_server_sequence_suspend_resume(self):
68 # We create an instance for use in this test
Giulio Fidente61cadca2013-09-24 18:33:37 +020069 instance = self.create_server()
Tatyana Leontovich58ab5312013-04-22 16:48:33 +030070 instance_id = instance.id
71 LOG.debug("Suspending instance %s. Current status: %s",
72 instance_id, instance.status)
73 instance.suspend()
74 self.status_timeout(self.compute_client.servers, instance_id,
75 'SUSPENDED')
76 LOG.debug("Resuming instance %s. Current status: %s",
77 instance_id, instance.status)
78 instance.resume()
79 self.status_timeout(self.compute_client.servers, instance_id,
80 'ACTIVE')
81 LOG.debug("Suspending instance %s. Current status: %s",
82 instance_id, instance.status)
83 instance.suspend()
84 self.status_timeout(self.compute_client.servers, instance_id,
85 'SUSPENDED')
86 LOG.debug("Resuming instance %s. Current status: %s",
87 instance_id, instance.status)
88 instance.resume()
89 self.status_timeout(self.compute_client.servers, instance_id,
90 'ACTIVE')