ZhiQiang Fan | 39f9722 | 2013-09-20 04:49:44 +0800 | [diff] [blame] | 1 | # Copyright 2012 OpenStack Foundation |
Attila Fazekas | a23f500 | 2012-10-23 19:32:45 +0200 | [diff] [blame] | 2 | # 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 | |
Attila Fazekas | 234d3e8 | 2013-02-22 16:39:49 +0100 | [diff] [blame] | 16 | from boto import exception |
Matthew Treinish | a83a16e | 2012-12-07 13:44:02 -0500 | [diff] [blame] | 17 | |
Masayuki Igawa | 259c113 | 2013-10-31 17:48:44 +0900 | [diff] [blame] | 18 | from tempest.common.utils import data_utils |
Matthew Treinish | a83a16e | 2012-12-07 13:44:02 -0500 | [diff] [blame] | 19 | from tempest.common.utils.linux.remote_client import RemoteClient |
Matthew Treinish | 88f49ef | 2014-01-29 18:36:27 +0000 | [diff] [blame] | 20 | from tempest import config |
Attila Fazekas | 234d3e8 | 2013-02-22 16:39:49 +0100 | [diff] [blame] | 21 | from tempest import exceptions |
Matthew Treinish | f4a9b0f | 2013-07-26 16:58:26 -0400 | [diff] [blame] | 22 | from tempest.openstack.common import log as logging |
Chris Yeoh | 01cb279 | 2013-02-09 22:25:37 +1030 | [diff] [blame] | 23 | from tempest.test import attr |
Giulio Fidente | 83181a9 | 2013-10-01 06:02:24 +0200 | [diff] [blame] | 24 | from tempest.test import skip_because |
Sean Dague | 09761f6 | 2013-05-13 15:20:40 -0400 | [diff] [blame] | 25 | from tempest.thirdparty.boto.test import BotoTestCase |
| 26 | from tempest.thirdparty.boto.utils.s3 import s3_upload_dir |
| 27 | from tempest.thirdparty.boto.utils.wait import re_search_wait |
| 28 | from tempest.thirdparty.boto.utils.wait import state_wait |
Attila Fazekas | a23f500 | 2012-10-23 19:32:45 +0200 | [diff] [blame] | 29 | |
Matthew Treinish | 88f49ef | 2014-01-29 18:36:27 +0000 | [diff] [blame] | 30 | CONF = config.CONF |
| 31 | |
Attila Fazekas | a23f500 | 2012-10-23 19:32:45 +0200 | [diff] [blame] | 32 | LOG = logging.getLogger(__name__) |
| 33 | |
| 34 | |
Attila Fazekas | a23f500 | 2012-10-23 19:32:45 +0200 | [diff] [blame] | 35 | class InstanceRunTest(BotoTestCase): |
| 36 | |
| 37 | @classmethod |
| 38 | def setUpClass(cls): |
| 39 | super(InstanceRunTest, cls).setUpClass() |
Attila Fazekas | 234d3e8 | 2013-02-22 16:39:49 +0100 | [diff] [blame] | 40 | if not cls.conclusion['A_I_IMAGES_READY']: |
ivan-zhu | 1feeb38 | 2013-01-24 10:14:39 +0800 | [diff] [blame] | 41 | raise cls.skipException("".join(("EC2 ", cls.__name__, |
| 42 | ": requires ami/aki/ari manifest"))) |
Attila Fazekas | a23f500 | 2012-10-23 19:32:45 +0200 | [diff] [blame] | 43 | cls.s3_client = cls.os.s3_client |
| 44 | cls.ec2_client = cls.os.ec2api_client |
Attila Fazekas | a23f500 | 2012-10-23 19:32:45 +0200 | [diff] [blame] | 45 | cls.zone = cls.ec2_client.get_good_zone() |
Matthew Treinish | 88f49ef | 2014-01-29 18:36:27 +0000 | [diff] [blame] | 46 | cls.materials_path = CONF.boto.s3_materials_path |
| 47 | ami_manifest = CONF.boto.ami_manifest |
| 48 | aki_manifest = CONF.boto.aki_manifest |
| 49 | ari_manifest = CONF.boto.ari_manifest |
| 50 | cls.instance_type = CONF.boto.instance_type |
Masayuki Igawa | 259c113 | 2013-10-31 17:48:44 +0900 | [diff] [blame] | 51 | cls.bucket_name = data_utils.rand_name("s3bucket-") |
| 52 | cls.keypair_name = data_utils.rand_name("keypair-") |
Attila Fazekas | a23f500 | 2012-10-23 19:32:45 +0200 | [diff] [blame] | 53 | cls.keypair = cls.ec2_client.create_key_pair(cls.keypair_name) |
| 54 | cls.addResourceCleanUp(cls.ec2_client.delete_key_pair, |
| 55 | cls.keypair_name) |
| 56 | bucket = cls.s3_client.create_bucket(cls.bucket_name) |
| 57 | cls.addResourceCleanUp(cls.destroy_bucket, |
| 58 | cls.s3_client.connection_data, |
| 59 | cls.bucket_name) |
| 60 | s3_upload_dir(bucket, cls.materials_path) |
| 61 | cls.images = {"ami": |
Masayuki Igawa | 259c113 | 2013-10-31 17:48:44 +0900 | [diff] [blame] | 62 | {"name": data_utils.rand_name("ami-name-"), |
Attila Fazekas | a23f500 | 2012-10-23 19:32:45 +0200 | [diff] [blame] | 63 | "location": cls.bucket_name + "/" + ami_manifest}, |
| 64 | "aki": |
Masayuki Igawa | 259c113 | 2013-10-31 17:48:44 +0900 | [diff] [blame] | 65 | {"name": data_utils.rand_name("aki-name-"), |
Attila Fazekas | a23f500 | 2012-10-23 19:32:45 +0200 | [diff] [blame] | 66 | "location": cls.bucket_name + "/" + aki_manifest}, |
| 67 | "ari": |
Masayuki Igawa | 259c113 | 2013-10-31 17:48:44 +0900 | [diff] [blame] | 68 | {"name": data_utils.rand_name("ari-name-"), |
Attila Fazekas | a23f500 | 2012-10-23 19:32:45 +0200 | [diff] [blame] | 69 | "location": cls.bucket_name + "/" + ari_manifest}} |
| 70 | for image in cls.images.itervalues(): |
| 71 | image["image_id"] = cls.ec2_client.register_image( |
Sean Dague | 14c6818 | 2013-04-14 15:34:30 -0400 | [diff] [blame] | 72 | name=image["name"], |
| 73 | image_location=image["location"]) |
Attila Fazekas | a23f500 | 2012-10-23 19:32:45 +0200 | [diff] [blame] | 74 | cls.addResourceCleanUp(cls.ec2_client.deregister_image, |
| 75 | image["image_id"]) |
| 76 | |
| 77 | for image in cls.images.itervalues(): |
| 78 | def _state(): |
| 79 | retr = cls.ec2_client.get_image(image["image_id"]) |
| 80 | return retr.state |
| 81 | state = state_wait(_state, "available") |
| 82 | if state != "available": |
| 83 | for _image in cls.images.itervalues(): |
Attila Fazekas | fa756cb | 2013-02-12 10:52:42 +0100 | [diff] [blame] | 84 | cls.ec2_client.deregister_image(_image["image_id"]) |
Attila Fazekas | 234d3e8 | 2013-02-22 16:39:49 +0100 | [diff] [blame] | 85 | raise exceptions.EC2RegisterImageException(image_id= |
| 86 | image["image_id"]) |
Attila Fazekas | a23f500 | 2012-10-23 19:32:45 +0200 | [diff] [blame] | 87 | |
| 88 | @attr(type='smoke') |
Burt Holzman | f70f222 | 2013-07-18 23:36:31 -0500 | [diff] [blame] | 89 | def test_run_idempotent_instances(self): |
| 90 | # EC2 run instances idempotently |
| 91 | |
| 92 | def _run_instance(client_token): |
| 93 | reservation = self.ec2_client.run_instances( |
| 94 | image_id=self.images["ami"]["image_id"], |
| 95 | kernel_id=self.images["aki"]["image_id"], |
| 96 | ramdisk_id=self.images["ari"]["image_id"], |
| 97 | instance_type=self.instance_type, |
| 98 | client_token=client_token) |
| 99 | rcuk = self.addResourceCleanUp(self.destroy_reservation, |
| 100 | reservation) |
| 101 | return (reservation, rcuk) |
| 102 | |
| 103 | def _terminate_reservation(reservation, rcuk): |
| 104 | for instance in reservation.instances: |
| 105 | instance.terminate() |
| 106 | self.cancelResourceCleanUp(rcuk) |
| 107 | |
| 108 | reservation_1, rcuk_1 = _run_instance('token_1') |
| 109 | reservation_2, rcuk_2 = _run_instance('token_2') |
| 110 | reservation_1a, rcuk_1a = _run_instance('token_1') |
| 111 | |
| 112 | self.assertIsNotNone(reservation_1) |
| 113 | self.assertIsNotNone(reservation_2) |
| 114 | self.assertIsNotNone(reservation_1a) |
| 115 | |
| 116 | # same reservation for token_1 |
| 117 | self.assertEqual(reservation_1.id, reservation_1a.id) |
| 118 | |
| 119 | # Cancel cleanup -- since it's a duplicate, it's |
| 120 | # handled by rcuk1 |
| 121 | self.cancelResourceCleanUp(rcuk_1a) |
| 122 | |
| 123 | _terminate_reservation(reservation_1, rcuk_1) |
| 124 | _terminate_reservation(reservation_2, rcuk_2) |
| 125 | |
| 126 | reservation_3, rcuk_3 = _run_instance('token_1') |
| 127 | self.assertIsNotNone(reservation_3) |
| 128 | |
| 129 | # make sure we don't get the old reservation back |
| 130 | self.assertNotEqual(reservation_1.id, reservation_3.id) |
| 131 | |
| 132 | # clean up |
| 133 | _terminate_reservation(reservation_3, rcuk_3) |
| 134 | |
| 135 | @attr(type='smoke') |
Attila Fazekas | a23f500 | 2012-10-23 19:32:45 +0200 | [diff] [blame] | 136 | def test_run_stop_terminate_instance(self): |
Sean Dague | 64ef48d | 2013-01-03 17:54:36 -0500 | [diff] [blame] | 137 | # EC2 run, stop and terminate instance |
Attila Fazekas | a23f500 | 2012-10-23 19:32:45 +0200 | [diff] [blame] | 138 | image_ami = self.ec2_client.get_image(self.images["ami"] |
| 139 | ["image_id"]) |
| 140 | reservation = image_ami.run(kernel_id=self.images["aki"]["image_id"], |
| 141 | ramdisk_id=self.images["ari"]["image_id"], |
| 142 | instance_type=self.instance_type) |
| 143 | rcuk = self.addResourceCleanUp(self.destroy_reservation, reservation) |
| 144 | |
Attila Fazekas | a23f500 | 2012-10-23 19:32:45 +0200 | [diff] [blame] | 145 | for instance in reservation.instances: |
| 146 | LOG.info("state: %s", instance.state) |
| 147 | if instance.state != "running": |
Attila Fazekas | 40aa361 | 2013-01-19 22:16:38 +0100 | [diff] [blame] | 148 | self.assertInstanceStateWait(instance, "running") |
Attila Fazekas | a23f500 | 2012-10-23 19:32:45 +0200 | [diff] [blame] | 149 | |
| 150 | for instance in reservation.instances: |
| 151 | instance.stop() |
| 152 | LOG.info("state: %s", instance.state) |
| 153 | if instance.state != "stopped": |
Attila Fazekas | 40aa361 | 2013-01-19 22:16:38 +0100 | [diff] [blame] | 154 | self.assertInstanceStateWait(instance, "stopped") |
Attila Fazekas | a23f500 | 2012-10-23 19:32:45 +0200 | [diff] [blame] | 155 | |
| 156 | for instance in reservation.instances: |
| 157 | instance.terminate() |
| 158 | self.cancelResourceCleanUp(rcuk) |
| 159 | |
| 160 | @attr(type='smoke') |
Burt Holzman | bb575e1 | 2013-07-14 00:23:30 -0500 | [diff] [blame] | 161 | def test_run_stop_terminate_instance_with_tags(self): |
| 162 | # EC2 run, stop and terminate instance with tags |
| 163 | image_ami = self.ec2_client.get_image(self.images["ami"] |
| 164 | ["image_id"]) |
| 165 | reservation = image_ami.run(kernel_id=self.images["aki"]["image_id"], |
| 166 | ramdisk_id=self.images["ari"]["image_id"], |
| 167 | instance_type=self.instance_type) |
| 168 | rcuk = self.addResourceCleanUp(self.destroy_reservation, reservation) |
| 169 | |
| 170 | for instance in reservation.instances: |
| 171 | LOG.info("state: %s", instance.state) |
| 172 | if instance.state != "running": |
| 173 | self.assertInstanceStateWait(instance, "running") |
| 174 | instance.add_tag('key1', value='value1') |
| 175 | |
| 176 | tags = self.ec2_client.get_all_tags() |
Chang Bo Guo | fc77e93 | 2013-09-16 17:38:26 -0700 | [diff] [blame] | 177 | self.assertEqual(tags[0].name, 'key1') |
| 178 | self.assertEqual(tags[0].value, 'value1') |
Burt Holzman | bb575e1 | 2013-07-14 00:23:30 -0500 | [diff] [blame] | 179 | |
| 180 | tags = self.ec2_client.get_all_tags(filters={'key': 'key1'}) |
Chang Bo Guo | fc77e93 | 2013-09-16 17:38:26 -0700 | [diff] [blame] | 181 | self.assertEqual(tags[0].name, 'key1') |
| 182 | self.assertEqual(tags[0].value, 'value1') |
Burt Holzman | bb575e1 | 2013-07-14 00:23:30 -0500 | [diff] [blame] | 183 | |
| 184 | tags = self.ec2_client.get_all_tags(filters={'value': 'value1'}) |
Chang Bo Guo | fc77e93 | 2013-09-16 17:38:26 -0700 | [diff] [blame] | 185 | self.assertEqual(tags[0].name, 'key1') |
| 186 | self.assertEqual(tags[0].value, 'value1') |
Burt Holzman | bb575e1 | 2013-07-14 00:23:30 -0500 | [diff] [blame] | 187 | |
| 188 | tags = self.ec2_client.get_all_tags(filters={'key': 'value2'}) |
Attila Fazekas | 849708e | 2013-09-25 17:33:56 +0200 | [diff] [blame] | 189 | self.assertEqual(len(tags), 0, str(tags)) |
Burt Holzman | bb575e1 | 2013-07-14 00:23:30 -0500 | [diff] [blame] | 190 | |
| 191 | for instance in reservation.instances: |
| 192 | instance.remove_tag('key1', value='value1') |
| 193 | |
| 194 | tags = self.ec2_client.get_all_tags() |
Attila Fazekas | 849708e | 2013-09-25 17:33:56 +0200 | [diff] [blame] | 195 | self.assertEqual(len(tags), 0, str(tags)) |
Burt Holzman | bb575e1 | 2013-07-14 00:23:30 -0500 | [diff] [blame] | 196 | |
| 197 | for instance in reservation.instances: |
| 198 | instance.stop() |
| 199 | LOG.info("state: %s", instance.state) |
| 200 | if instance.state != "stopped": |
| 201 | self.assertInstanceStateWait(instance, "stopped") |
| 202 | |
| 203 | for instance in reservation.instances: |
| 204 | instance.terminate() |
| 205 | self.cancelResourceCleanUp(rcuk) |
| 206 | |
Giulio Fidente | 83181a9 | 2013-10-01 06:02:24 +0200 | [diff] [blame] | 207 | @skip_because(bug="1098891") |
Burt Holzman | bb575e1 | 2013-07-14 00:23:30 -0500 | [diff] [blame] | 208 | @attr(type='smoke') |
Attila Fazekas | a23f500 | 2012-10-23 19:32:45 +0200 | [diff] [blame] | 209 | def test_run_terminate_instance(self): |
Sean Dague | 64ef48d | 2013-01-03 17:54:36 -0500 | [diff] [blame] | 210 | # EC2 run, terminate immediately |
Attila Fazekas | a23f500 | 2012-10-23 19:32:45 +0200 | [diff] [blame] | 211 | image_ami = self.ec2_client.get_image(self.images["ami"] |
| 212 | ["image_id"]) |
| 213 | reservation = image_ami.run(kernel_id=self.images["aki"]["image_id"], |
| 214 | ramdisk_id=self.images["ari"]["image_id"], |
| 215 | instance_type=self.instance_type) |
| 216 | |
| 217 | for instance in reservation.instances: |
| 218 | instance.terminate() |
Attila Fazekas | 37f8304 | 2013-01-12 16:13:03 +0100 | [diff] [blame] | 219 | try: |
| 220 | instance.update(validate=True) |
| 221 | except ValueError: |
| 222 | pass |
Attila Fazekas | 234d3e8 | 2013-02-22 16:39:49 +0100 | [diff] [blame] | 223 | except exception.EC2ResponseError as exc: |
Attila Fazekas | 37f8304 | 2013-01-12 16:13:03 +0100 | [diff] [blame] | 224 | if self.ec2_error_code.\ |
| 225 | client.InvalidInstanceID.NotFound.match(exc): |
| 226 | pass |
| 227 | else: |
| 228 | raise |
| 229 | else: |
| 230 | self.assertNotEqual(instance.state, "running") |
Attila Fazekas | a23f500 | 2012-10-23 19:32:45 +0200 | [diff] [blame] | 231 | |
Attila Fazekas | 3e381f7 | 2013-08-01 16:52:23 +0200 | [diff] [blame] | 232 | # NOTE(afazekas): doctored test case, |
Attila Fazekas | a23f500 | 2012-10-23 19:32:45 +0200 | [diff] [blame] | 233 | # with normal validation it would fail |
Giulio Fidente | 83181a9 | 2013-10-01 06:02:24 +0200 | [diff] [blame] | 234 | @skip_because(bug="1182679") |
Giampaolo Lauria | cb9209d | 2013-05-17 13:39:25 -0400 | [diff] [blame] | 235 | @attr(type='smoke') |
Attila Fazekas | a23f500 | 2012-10-23 19:32:45 +0200 | [diff] [blame] | 236 | def test_integration_1(self): |
Sean Dague | 64ef48d | 2013-01-03 17:54:36 -0500 | [diff] [blame] | 237 | # EC2 1. integration test (not strict) |
Attila Fazekas | a23f500 | 2012-10-23 19:32:45 +0200 | [diff] [blame] | 238 | image_ami = self.ec2_client.get_image(self.images["ami"]["image_id"]) |
Masayuki Igawa | 259c113 | 2013-10-31 17:48:44 +0900 | [diff] [blame] | 239 | sec_group_name = data_utils.rand_name("securitygroup-") |
Attila Fazekas | a23f500 | 2012-10-23 19:32:45 +0200 | [diff] [blame] | 240 | group_desc = sec_group_name + " security group description " |
| 241 | security_group = self.ec2_client.create_security_group(sec_group_name, |
| 242 | group_desc) |
| 243 | self.addResourceCleanUp(self.destroy_security_group_wait, |
| 244 | security_group) |
Sean Dague | 14c6818 | 2013-04-14 15:34:30 -0400 | [diff] [blame] | 245 | self.assertTrue( |
| 246 | self.ec2_client.authorize_security_group( |
Chris Yeoh | 86732f9 | 2013-02-27 20:52:06 +1030 | [diff] [blame] | 247 | sec_group_name, |
| 248 | ip_protocol="icmp", |
| 249 | cidr_ip="0.0.0.0/0", |
| 250 | from_port=-1, |
| 251 | to_port=-1)) |
Sean Dague | 14c6818 | 2013-04-14 15:34:30 -0400 | [diff] [blame] | 252 | self.assertTrue( |
| 253 | self.ec2_client.authorize_security_group( |
Chris Yeoh | 86732f9 | 2013-02-27 20:52:06 +1030 | [diff] [blame] | 254 | sec_group_name, |
| 255 | ip_protocol="tcp", |
| 256 | cidr_ip="0.0.0.0/0", |
| 257 | from_port=22, |
| 258 | to_port=22)) |
Attila Fazekas | a23f500 | 2012-10-23 19:32:45 +0200 | [diff] [blame] | 259 | reservation = image_ami.run(kernel_id=self.images["aki"]["image_id"], |
| 260 | ramdisk_id=self.images["ari"]["image_id"], |
| 261 | instance_type=self.instance_type, |
| 262 | key_name=self.keypair_name, |
| 263 | security_groups=(sec_group_name,)) |
| 264 | self.addResourceCleanUp(self.destroy_reservation, |
| 265 | reservation) |
| 266 | volume = self.ec2_client.create_volume(1, self.zone) |
| 267 | self.addResourceCleanUp(self.destroy_volume_wait, volume) |
| 268 | instance = reservation.instances[0] |
Attila Fazekas | a23f500 | 2012-10-23 19:32:45 +0200 | [diff] [blame] | 269 | LOG.info("state: %s", instance.state) |
| 270 | if instance.state != "running": |
Attila Fazekas | 40aa361 | 2013-01-19 22:16:38 +0100 | [diff] [blame] | 271 | self.assertInstanceStateWait(instance, "running") |
Attila Fazekas | a23f500 | 2012-10-23 19:32:45 +0200 | [diff] [blame] | 272 | |
| 273 | address = self.ec2_client.allocate_address() |
| 274 | rcuk_a = self.addResourceCleanUp(address.delete) |
Chris Yeoh | 86732f9 | 2013-02-27 20:52:06 +1030 | [diff] [blame] | 275 | self.assertTrue(address.associate(instance.id)) |
Attila Fazekas | a23f500 | 2012-10-23 19:32:45 +0200 | [diff] [blame] | 276 | |
| 277 | rcuk_da = self.addResourceCleanUp(address.disassociate) |
Attila Fazekas | 3e381f7 | 2013-08-01 16:52:23 +0200 | [diff] [blame] | 278 | # TODO(afazekas): ping test. dependecy/permission ? |
Attila Fazekas | a23f500 | 2012-10-23 19:32:45 +0200 | [diff] [blame] | 279 | |
Attila Fazekas | 40aa361 | 2013-01-19 22:16:38 +0100 | [diff] [blame] | 280 | self.assertVolumeStatusWait(volume, "available") |
Marc Solanas | b15d8b6 | 2014-02-07 00:04:15 -0800 | [diff] [blame] | 281 | # NOTE(afazekas): it may be reports available before it is available |
Attila Fazekas | a23f500 | 2012-10-23 19:32:45 +0200 | [diff] [blame] | 282 | |
| 283 | ssh = RemoteClient(address.public_ip, |
Matthew Treinish | 88f49ef | 2014-01-29 18:36:27 +0000 | [diff] [blame] | 284 | CONF.compute.ssh_user, |
Attila Fazekas | a23f500 | 2012-10-23 19:32:45 +0200 | [diff] [blame] | 285 | pkey=self.keypair.material) |
Masayuki Igawa | 259c113 | 2013-10-31 17:48:44 +0900 | [diff] [blame] | 286 | text = data_utils.rand_name("Pattern text for console output -") |
Attila Fazekas | a23f500 | 2012-10-23 19:32:45 +0200 | [diff] [blame] | 287 | resp = ssh.write_to_console(text) |
| 288 | self.assertFalse(resp) |
| 289 | |
| 290 | def _output(): |
| 291 | output = instance.get_console_output() |
| 292 | return output.output |
| 293 | |
| 294 | re_search_wait(_output, text) |
| 295 | part_lines = ssh.get_partitions().split('\n') |
Attila Fazekas | a23f500 | 2012-10-23 19:32:45 +0200 | [diff] [blame] | 296 | volume.attach(instance.id, "/dev/vdh") |
| 297 | |
Attila Fazekas | 40aa361 | 2013-01-19 22:16:38 +0100 | [diff] [blame] | 298 | def _volume_state(): |
| 299 | volume.update(validate=True) |
| 300 | return volume.status |
| 301 | |
Chris Yeoh | f2a5e82 | 2013-05-08 21:33:00 +0930 | [diff] [blame] | 302 | self.assertVolumeStatusWait(_volume_state, "in-use") |
Attila Fazekas | a23f500 | 2012-10-23 19:32:45 +0200 | [diff] [blame] | 303 | re_search_wait(_volume_state, "in-use") |
| 304 | |
Attila Fazekas | 3e381f7 | 2013-08-01 16:52:23 +0200 | [diff] [blame] | 305 | # NOTE(afazekas): Different Hypervisor backends names |
Attila Fazekas | a23f500 | 2012-10-23 19:32:45 +0200 | [diff] [blame] | 306 | # differently the devices, |
| 307 | # now we just test is the partition number increased/decrised |
| 308 | |
| 309 | def _part_state(): |
| 310 | current = ssh.get_partitions().split('\n') |
| 311 | if current > part_lines: |
| 312 | return 'INCREASE' |
| 313 | if current < part_lines: |
| 314 | return 'DECREASE' |
| 315 | return 'EQUAL' |
| 316 | |
| 317 | state_wait(_part_state, 'INCREASE') |
| 318 | part_lines = ssh.get_partitions().split('\n') |
| 319 | |
Attila Fazekas | 3e381f7 | 2013-08-01 16:52:23 +0200 | [diff] [blame] | 320 | # TODO(afazekas): Resource compare to the flavor settings |
Attila Fazekas | a23f500 | 2012-10-23 19:32:45 +0200 | [diff] [blame] | 321 | |
Chris Yeoh | f2a5e82 | 2013-05-08 21:33:00 +0930 | [diff] [blame] | 322 | volume.detach() |
Attila Fazekas | a23f500 | 2012-10-23 19:32:45 +0200 | [diff] [blame] | 323 | |
Chris Yeoh | f2a5e82 | 2013-05-08 21:33:00 +0930 | [diff] [blame] | 324 | self.assertVolumeStatusWait(_volume_state, "available") |
Attila Fazekas | a23f500 | 2012-10-23 19:32:45 +0200 | [diff] [blame] | 325 | re_search_wait(_volume_state, "available") |
| 326 | LOG.info("Volume %s state: %s", volume.id, volume.status) |
| 327 | |
| 328 | state_wait(_part_state, 'DECREASE') |
| 329 | |
| 330 | instance.stop() |
| 331 | address.disassociate() |
| 332 | self.assertAddressDissasociatedWait(address) |
| 333 | self.cancelResourceCleanUp(rcuk_da) |
| 334 | address.release() |
| 335 | self.assertAddressReleasedWait(address) |
| 336 | self.cancelResourceCleanUp(rcuk_a) |
| 337 | |
| 338 | LOG.info("state: %s", instance.state) |
| 339 | if instance.state != "stopped": |
Attila Fazekas | 40aa361 | 2013-01-19 22:16:38 +0100 | [diff] [blame] | 340 | self.assertInstanceStateWait(instance, "stopped") |
Attila Fazekas | 3e381f7 | 2013-08-01 16:52:23 +0200 | [diff] [blame] | 341 | # TODO(afazekas): move steps from teardown to the test case |
Attila Fazekas | a23f500 | 2012-10-23 19:32:45 +0200 | [diff] [blame] | 342 | |
| 343 | |
Attila Fazekas | 3e381f7 | 2013-08-01 16:52:23 +0200 | [diff] [blame] | 344 | # TODO(afazekas): Snapshot/volume read/write test case |