ZhiQiang Fan | 39f9722 | 2013-09-20 04:49:44 +0800 | [diff] [blame] | 1 | # Copyright 2012 OpenStack Foundation |
Jay Pipes | 13b479b | 2012-06-11 14:52:27 -0400 | [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 | |
Rohit Karajgi | dc300b2 | 2012-05-04 08:11:00 -0700 | [diff] [blame] | 16 | import sys |
Jay Pipes | 13b479b | 2012-06-11 14:52:27 -0400 | [diff] [blame] | 17 | |
Eric Windisch | b553807 | 2014-03-09 23:47:35 -0400 | [diff] [blame] | 18 | import testtools |
| 19 | |
Sean Dague | 1937d09 | 2013-05-17 16:36:38 -0400 | [diff] [blame] | 20 | from tempest.api.compute import base |
ghanshyam | 017b5fe | 2016-04-15 18:49:26 +0900 | [diff] [blame] | 21 | from tempest.common import compute |
Andrea Frittoli | cd36841 | 2017-08-14 21:37:56 +0100 | [diff] [blame] | 22 | from tempest.common import utils |
Ken'ichi Ohmichi | 0eb153c | 2015-07-13 02:18:25 +0000 | [diff] [blame] | 23 | from tempest.common import waiters |
Matthew Treinish | b0a78fc | 2014-01-29 16:49:12 +0000 | [diff] [blame] | 24 | from tempest import config |
Ken'ichi Ohmichi | 757833a | 2017-03-10 10:30:30 -0800 | [diff] [blame] | 25 | from tempest.lib.common.utils import data_utils |
Ken'ichi Ohmichi | 14b0ae1 | 2017-01-27 17:18:52 -0800 | [diff] [blame] | 26 | from tempest.lib import decorators |
Andrea Frittoli (andreaf) | db9672e | 2016-02-23 14:07:24 -0500 | [diff] [blame] | 27 | from tempest.lib import exceptions as lib_exc |
Daryl Walleck | adea1fa | 2011-11-15 18:36:39 -0600 | [diff] [blame] | 28 | |
Matthew Treinish | b0a78fc | 2014-01-29 16:49:12 +0000 | [diff] [blame] | 29 | CONF = config.CONF |
| 30 | |
Daryl Walleck | adea1fa | 2011-11-15 18:36:39 -0600 | [diff] [blame] | 31 | |
ivan-zhu | f2b0050 | 2013-10-18 10:06:52 +0800 | [diff] [blame] | 32 | class ServersNegativeTestJSON(base.BaseV2ComputeTest): |
zhufl | b5603bc | 2020-05-27 09:18:24 +0800 | [diff] [blame] | 33 | """Negative tests of servers""" |
| 34 | |
Eric Fried | bfaa50f | 2020-01-09 12:04:54 -0600 | [diff] [blame] | 35 | create_default_network = True |
Daryl Walleck | adea1fa | 2011-11-15 18:36:39 -0600 | [diff] [blame] | 36 | |
Ken'ichi Ohmichi | da30650 | 2013-10-08 23:44:55 +0900 | [diff] [blame] | 37 | def setUp(self): |
| 38 | super(ServersNegativeTestJSON, self).setUp() |
| 39 | try: |
Ken'ichi Ohmichi | 0eb153c | 2015-07-13 02:18:25 +0000 | [diff] [blame] | 40 | waiters.wait_for_server_status(self.client, self.server_id, |
| 41 | 'ACTIVE') |
Ken'ichi Ohmichi | da30650 | 2013-10-08 23:44:55 +0900 | [diff] [blame] | 42 | except Exception: |
zhufl | ba0e553 | 2017-09-13 10:51:07 +0800 | [diff] [blame] | 43 | self.__class__.server_id = self.recreate_server(self.server_id) |
Ken'ichi Ohmichi | da30650 | 2013-10-08 23:44:55 +0900 | [diff] [blame] | 44 | |
Attila Fazekas | 305e65b | 2013-10-29 13:23:07 +0100 | [diff] [blame] | 45 | def tearDown(self): |
Attila Fazekas | 305e65b | 2013-10-29 13:23:07 +0100 | [diff] [blame] | 46 | super(ServersNegativeTestJSON, self).tearDown() |
zhufl | e913e46 | 2018-07-25 17:16:10 +0800 | [diff] [blame] | 47 | # NOTE(zhufl): Because server_check_teardown will raise Exception |
| 48 | # which will prevent other cleanup steps from being executed, so |
| 49 | # server_check_teardown should be called after super's tearDown. |
| 50 | self.server_check_teardown() |
Attila Fazekas | 305e65b | 2013-10-29 13:23:07 +0100 | [diff] [blame] | 51 | |
Daryl Walleck | adea1fa | 2011-11-15 18:36:39 -0600 | [diff] [blame] | 52 | @classmethod |
Rohan Kanade | 60b7309 | 2015-02-04 17:58:19 +0530 | [diff] [blame] | 53 | def setup_clients(cls): |
| 54 | super(ServersNegativeTestJSON, cls).setup_clients() |
| 55 | cls.client = cls.servers_client |
Rohan Kanade | 60b7309 | 2015-02-04 17:58:19 +0530 | [diff] [blame] | 56 | |
| 57 | @classmethod |
Andrea Frittoli | 50bb80d | 2014-09-15 12:34:27 +0100 | [diff] [blame] | 58 | def resource_setup(cls): |
| 59 | super(ServersNegativeTestJSON, cls).resource_setup() |
David Kranz | 0fb1429 | 2015-02-11 15:55:20 -0500 | [diff] [blame] | 60 | server = cls.create_test_server(wait_until='ACTIVE') |
Ken'ichi Ohmichi | da30650 | 2013-10-08 23:44:55 +0900 | [diff] [blame] | 61 | cls.server_id = server['id'] |
Daryl Walleck | adea1fa | 2011-11-15 18:36:39 -0600 | [diff] [blame] | 62 | |
zhufl | 406e913 | 2017-05-09 16:21:54 +0800 | [diff] [blame] | 63 | server = cls.create_test_server() |
| 64 | cls.client.delete_server(server['id']) |
| 65 | waiters.wait_for_server_termination(cls.client, server['id']) |
| 66 | cls.deleted_server_id = server['id'] |
| 67 | |
Jordan Pittier | 3b46d27 | 2017-04-12 16:17:28 +0200 | [diff] [blame] | 68 | @decorators.attr(type=['negative']) |
Ken'ichi Ohmichi | 14b0ae1 | 2017-01-27 17:18:52 -0800 | [diff] [blame] | 69 | @decorators.idempotent_id('dbbfd247-c40c-449e-8f6c-d2aa7c7da7cf') |
Daryl Walleck | adea1fa | 2011-11-15 18:36:39 -0600 | [diff] [blame] | 70 | def test_server_name_blank(self): |
zhufl | b5603bc | 2020-05-27 09:18:24 +0800 | [diff] [blame] | 71 | """Creating a server with name parameter empty should fail""" |
Masayuki Igawa | 4b29e47 | 2015-02-16 10:41:54 +0900 | [diff] [blame] | 72 | self.assertRaises(lib_exc.BadRequest, |
Ken'ichi Ohmichi | cfc052e | 2013-10-23 11:50:04 +0900 | [diff] [blame] | 73 | self.create_test_server, |
Sean Dague | 22897e1 | 2013-02-25 17:54:09 -0500 | [diff] [blame] | 74 | name='') |
Daryl Walleck | adea1fa | 2011-11-15 18:36:39 -0600 | [diff] [blame] | 75 | |
Jordan Pittier | 3b46d27 | 2017-04-12 16:17:28 +0200 | [diff] [blame] | 76 | @decorators.attr(type=['negative']) |
Ken'ichi Ohmichi | 14b0ae1 | 2017-01-27 17:18:52 -0800 | [diff] [blame] | 77 | @decorators.idempotent_id('b8a7235e-5246-4a8f-a08e-b34877c6586f') |
Takeaki Matsumoto | d7e04b2 | 2015-09-04 15:13:38 +0900 | [diff] [blame] | 78 | @testtools.skipUnless(CONF.compute_feature_enabled.personality, |
| 79 | 'Nova personality feature disabled') |
Daryl Walleck | adea1fa | 2011-11-15 18:36:39 -0600 | [diff] [blame] | 80 | def test_personality_file_contents_not_encoded(self): |
zhufl | b5603bc | 2020-05-27 09:18:24 +0800 | [diff] [blame] | 81 | """Using an unencoded injected file to create server should fail""" |
Daryl Walleck | adea1fa | 2011-11-15 18:36:39 -0600 | [diff] [blame] | 82 | file_contents = 'This is a test file.' |
Sean Dague | 9b669e3 | 2012-12-13 18:40:08 -0500 | [diff] [blame] | 83 | person = [{'path': '/etc/testfile.txt', |
| 84 | 'contents': file_contents}] |
Daryl Walleck | adea1fa | 2011-11-15 18:36:39 -0600 | [diff] [blame] | 85 | |
Masayuki Igawa | 4b29e47 | 2015-02-16 10:41:54 +0900 | [diff] [blame] | 86 | self.assertRaises(lib_exc.BadRequest, |
Ken'ichi Ohmichi | cfc052e | 2013-10-23 11:50:04 +0900 | [diff] [blame] | 87 | self.create_test_server, |
donald-ngo | 18edb81 | 2013-02-22 11:37:15 -0800 | [diff] [blame] | 88 | personality=person) |
Daryl Walleck | adea1fa | 2011-11-15 18:36:39 -0600 | [diff] [blame] | 89 | |
Jordan Pittier | 3b46d27 | 2017-04-12 16:17:28 +0200 | [diff] [blame] | 90 | @decorators.attr(type=['negative']) |
Ken'ichi Ohmichi | 14b0ae1 | 2017-01-27 17:18:52 -0800 | [diff] [blame] | 91 | @decorators.idempotent_id('fcba1052-0a50-4cf3-b1ac-fae241edf02f') |
Daryl Walleck | adea1fa | 2011-11-15 18:36:39 -0600 | [diff] [blame] | 92 | def test_create_with_invalid_image(self): |
zhufl | b5603bc | 2020-05-27 09:18:24 +0800 | [diff] [blame] | 93 | """Creating a server with an unknown image should fail""" |
Masayuki Igawa | 4b29e47 | 2015-02-16 10:41:54 +0900 | [diff] [blame] | 94 | self.assertRaises(lib_exc.BadRequest, |
Ken'ichi Ohmichi | cfc052e | 2013-10-23 11:50:04 +0900 | [diff] [blame] | 95 | self.create_test_server, |
Sean Dague | 22897e1 | 2013-02-25 17:54:09 -0500 | [diff] [blame] | 96 | image_id=-1) |
Daryl Walleck | adea1fa | 2011-11-15 18:36:39 -0600 | [diff] [blame] | 97 | |
Jordan Pittier | 3b46d27 | 2017-04-12 16:17:28 +0200 | [diff] [blame] | 98 | @decorators.attr(type=['negative']) |
Ken'ichi Ohmichi | 14b0ae1 | 2017-01-27 17:18:52 -0800 | [diff] [blame] | 99 | @decorators.idempotent_id('18f5227f-d155-4429-807c-ccb103887537') |
Daryl Walleck | adea1fa | 2011-11-15 18:36:39 -0600 | [diff] [blame] | 100 | def test_create_with_invalid_flavor(self): |
zhufl | b5603bc | 2020-05-27 09:18:24 +0800 | [diff] [blame] | 101 | """Creating a server with an unknown flavor should fail""" |
Masayuki Igawa | 4b29e47 | 2015-02-16 10:41:54 +0900 | [diff] [blame] | 102 | self.assertRaises(lib_exc.BadRequest, |
Ken'ichi Ohmichi | cfc052e | 2013-10-23 11:50:04 +0900 | [diff] [blame] | 103 | self.create_test_server, |
Sean Dague | 22897e1 | 2013-02-25 17:54:09 -0500 | [diff] [blame] | 104 | flavor=-1,) |
Daryl Walleck | adea1fa | 2011-11-15 18:36:39 -0600 | [diff] [blame] | 105 | |
Jordan Pittier | 3b46d27 | 2017-04-12 16:17:28 +0200 | [diff] [blame] | 106 | @decorators.attr(type=['negative']) |
Ken'ichi Ohmichi | 14b0ae1 | 2017-01-27 17:18:52 -0800 | [diff] [blame] | 107 | @decorators.idempotent_id('7f70a4d1-608f-4794-9e56-cb182765972c') |
Daryl Walleck | adea1fa | 2011-11-15 18:36:39 -0600 | [diff] [blame] | 108 | def test_invalid_access_ip_v4_address(self): |
zhufl | b5603bc | 2020-05-27 09:18:24 +0800 | [diff] [blame] | 109 | """Creating a server with invalid ipv4 ip address should fail |
donald-ngo | 18edb81 | 2013-02-22 11:37:15 -0800 | [diff] [blame] | 110 | |
zhufl | b5603bc | 2020-05-27 09:18:24 +0800 | [diff] [blame] | 111 | An access IPv4 address must match a valid address pattern |
| 112 | """ |
Sean Dague | 9b669e3 | 2012-12-13 18:40:08 -0500 | [diff] [blame] | 113 | IPv4 = '1.1.1.1.1.1' |
Masayuki Igawa | 4b29e47 | 2015-02-16 10:41:54 +0900 | [diff] [blame] | 114 | self.assertRaises(lib_exc.BadRequest, |
Ken'ichi Ohmichi | cfc052e | 2013-10-23 11:50:04 +0900 | [diff] [blame] | 115 | self.create_test_server, accessIPv4=IPv4) |
Daryl Walleck | adea1fa | 2011-11-15 18:36:39 -0600 | [diff] [blame] | 116 | |
Jordan Pittier | 3b46d27 | 2017-04-12 16:17:28 +0200 | [diff] [blame] | 117 | @decorators.attr(type=['negative']) |
Ken'ichi Ohmichi | 14b0ae1 | 2017-01-27 17:18:52 -0800 | [diff] [blame] | 118 | @decorators.idempotent_id('5226dd80-1e9c-4d8a-b5f9-b26ca4763fd0') |
Daryl Walleck | adea1fa | 2011-11-15 18:36:39 -0600 | [diff] [blame] | 119 | def test_invalid_ip_v6_address(self): |
zhufl | b5603bc | 2020-05-27 09:18:24 +0800 | [diff] [blame] | 120 | """Creating a server with invalid ipv6 ip address should fail |
donald-ngo | 18edb81 | 2013-02-22 11:37:15 -0800 | [diff] [blame] | 121 | |
zhufl | b5603bc | 2020-05-27 09:18:24 +0800 | [diff] [blame] | 122 | An access IPv6 address must match a valid address pattern |
| 123 | """ |
Sean Dague | 9b669e3 | 2012-12-13 18:40:08 -0500 | [diff] [blame] | 124 | IPv6 = 'notvalid' |
donald-ngo | 18edb81 | 2013-02-22 11:37:15 -0800 | [diff] [blame] | 125 | |
Masayuki Igawa | 4b29e47 | 2015-02-16 10:41:54 +0900 | [diff] [blame] | 126 | self.assertRaises(lib_exc.BadRequest, |
Ken'ichi Ohmichi | cfc052e | 2013-10-23 11:50:04 +0900 | [diff] [blame] | 127 | self.create_test_server, accessIPv6=IPv6) |
ravikumar-venkatesan | 36892e1 | 2012-05-11 18:01:41 +0000 | [diff] [blame] | 128 | |
Ken'ichi Ohmichi | 14b0ae1 | 2017-01-27 17:18:52 -0800 | [diff] [blame] | 129 | @decorators.idempotent_id('7ea45b3e-e770-46fa-bfcc-9daaf6d987c0') |
Joseph Lanoux | b3d956f | 2014-06-25 14:45:24 +0000 | [diff] [blame] | 130 | @testtools.skipUnless(CONF.compute_feature_enabled.resize, |
| 131 | 'Resize not available.') |
Jordan Pittier | 3b46d27 | 2017-04-12 16:17:28 +0200 | [diff] [blame] | 132 | @decorators.attr(type=['negative']) |
Hoisaleshwara Madan V S | f49bf18 | 2013-10-21 10:19:43 +0530 | [diff] [blame] | 133 | def test_resize_nonexistent_server(self): |
zhufl | b5603bc | 2020-05-27 09:18:24 +0800 | [diff] [blame] | 134 | """Resizing a non-existent server should fail""" |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 135 | nonexistent_server = data_utils.rand_uuid() |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 136 | self.assertRaises(lib_exc.NotFound, |
Ken'ichi Ohmichi | 5271b0f | 2015-08-10 07:53:27 +0000 | [diff] [blame] | 137 | self.client.resize_server, |
Hoisaleshwara Madan V S | f49bf18 | 2013-10-21 10:19:43 +0530 | [diff] [blame] | 138 | nonexistent_server, self.flavor_ref) |
| 139 | |
Ken'ichi Ohmichi | 14b0ae1 | 2017-01-27 17:18:52 -0800 | [diff] [blame] | 140 | @decorators.idempotent_id('ced1a1d7-2ab6-45c9-b90f-b27d87b30efd') |
Joseph Lanoux | b3d956f | 2014-06-25 14:45:24 +0000 | [diff] [blame] | 141 | @testtools.skipUnless(CONF.compute_feature_enabled.resize, |
| 142 | 'Resize not available.') |
Jordan Pittier | 3b46d27 | 2017-04-12 16:17:28 +0200 | [diff] [blame] | 143 | @decorators.attr(type=['negative']) |
Ken'ichi Ohmichi | d90c010 | 2013-10-13 23:55:31 +0900 | [diff] [blame] | 144 | def test_resize_server_with_non_existent_flavor(self): |
zhufl | b5603bc | 2020-05-27 09:18:24 +0800 | [diff] [blame] | 145 | """Resizing a server with non existent flavor should fail""" |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 146 | nonexistent_flavor = data_utils.rand_uuid() |
Ken'ichi Ohmichi | 5271b0f | 2015-08-10 07:53:27 +0000 | [diff] [blame] | 147 | self.assertRaises(lib_exc.BadRequest, self.client.resize_server, |
Ken'ichi Ohmichi | d90c010 | 2013-10-13 23:55:31 +0900 | [diff] [blame] | 148 | self.server_id, flavor_ref=nonexistent_flavor) |
| 149 | |
Ken'ichi Ohmichi | 14b0ae1 | 2017-01-27 17:18:52 -0800 | [diff] [blame] | 150 | @decorators.idempotent_id('45436a7d-a388-4a35-a9d8-3adc5d0d940b') |
Joseph Lanoux | b3d956f | 2014-06-25 14:45:24 +0000 | [diff] [blame] | 151 | @testtools.skipUnless(CONF.compute_feature_enabled.resize, |
| 152 | 'Resize not available.') |
Jordan Pittier | 3b46d27 | 2017-04-12 16:17:28 +0200 | [diff] [blame] | 153 | @decorators.attr(type=['negative']) |
Ken'ichi Ohmichi | d90c010 | 2013-10-13 23:55:31 +0900 | [diff] [blame] | 154 | def test_resize_server_with_null_flavor(self): |
zhufl | b5603bc | 2020-05-27 09:18:24 +0800 | [diff] [blame] | 155 | """Resizing a server with null flavor should fail""" |
Ken'ichi Ohmichi | 5271b0f | 2015-08-10 07:53:27 +0000 | [diff] [blame] | 156 | self.assertRaises(lib_exc.BadRequest, self.client.resize_server, |
Ken'ichi Ohmichi | d90c010 | 2013-10-13 23:55:31 +0900 | [diff] [blame] | 157 | self.server_id, flavor_ref="") |
| 158 | |
Jordan Pittier | 3b46d27 | 2017-04-12 16:17:28 +0200 | [diff] [blame] | 159 | @decorators.attr(type=['negative']) |
Ken'ichi Ohmichi | 14b0ae1 | 2017-01-27 17:18:52 -0800 | [diff] [blame] | 160 | @decorators.idempotent_id('d4c023a0-9c55-4747-9dd5-413b820143c7') |
Ken'ichi Ohmichi | d90c010 | 2013-10-13 23:55:31 +0900 | [diff] [blame] | 161 | def test_reboot_non_existent_server(self): |
zhufl | b5603bc | 2020-05-27 09:18:24 +0800 | [diff] [blame] | 162 | """Rebooting a non existent server should fail""" |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 163 | nonexistent_server = data_utils.rand_uuid() |
Ken'ichi Ohmichi | 5271b0f | 2015-08-10 07:53:27 +0000 | [diff] [blame] | 164 | self.assertRaises(lib_exc.NotFound, self.client.reboot_server, |
Ken'ichi Ohmichi | 36b714c | 2015-12-09 08:12:47 +0000 | [diff] [blame] | 165 | nonexistent_server, type='SOFT') |
Ken'ichi Ohmichi | d90c010 | 2013-10-13 23:55:31 +0900 | [diff] [blame] | 166 | |
Ken'ichi Ohmichi | 14b0ae1 | 2017-01-27 17:18:52 -0800 | [diff] [blame] | 167 | @decorators.idempotent_id('d1417e7f-a509-41b5-a102-d5eed8613369') |
Matt Riedemann | 992162e | 2014-03-24 09:11:06 -0700 | [diff] [blame] | 168 | @testtools.skipUnless(CONF.compute_feature_enabled.pause, |
| 169 | 'Pause is not available.') |
Jordan Pittier | 3b46d27 | 2017-04-12 16:17:28 +0200 | [diff] [blame] | 170 | @decorators.attr(type=['negative']) |
Anju Tiwari | 8c78976 | 2013-07-22 11:02:05 +0530 | [diff] [blame] | 171 | def test_pause_paused_server(self): |
zhufl | b5603bc | 2020-05-27 09:18:24 +0800 | [diff] [blame] | 172 | """Pausing a paused server should fail""" |
Anju Tiwari | 8c78976 | 2013-07-22 11:02:05 +0530 | [diff] [blame] | 173 | self.client.pause_server(self.server_id) |
Ken'ichi Ohmichi | 0eb153c | 2015-07-13 02:18:25 +0000 | [diff] [blame] | 174 | waiters.wait_for_server_status(self.client, self.server_id, 'PAUSED') |
Masayuki Igawa | d938876 | 2015-01-20 14:56:42 +0900 | [diff] [blame] | 175 | self.assertRaises(lib_exc.Conflict, |
Anju Tiwari | 8c78976 | 2013-07-22 11:02:05 +0530 | [diff] [blame] | 176 | self.client.pause_server, |
| 177 | self.server_id) |
Attila Fazekas | 305e65b | 2013-10-29 13:23:07 +0100 | [diff] [blame] | 178 | self.client.unpause_server(self.server_id) |
Anju Tiwari | 8c78976 | 2013-07-22 11:02:05 +0530 | [diff] [blame] | 179 | |
Jordan Pittier | 3b46d27 | 2017-04-12 16:17:28 +0200 | [diff] [blame] | 180 | @decorators.attr(type=['negative']) |
Ken'ichi Ohmichi | 14b0ae1 | 2017-01-27 17:18:52 -0800 | [diff] [blame] | 181 | @decorators.idempotent_id('98fa0458-1485-440f-873b-fe7f0d714930') |
Joe H. Rahme | b2e01ab | 2015-10-27 17:30:53 +0100 | [diff] [blame] | 182 | def test_rebuild_deleted_server(self): |
zhufl | b5603bc | 2020-05-27 09:18:24 +0800 | [diff] [blame] | 183 | """Rebuilding a deleted server should fail""" |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 184 | self.assertRaises(lib_exc.NotFound, |
Ken'ichi Ohmichi | 5271b0f | 2015-08-10 07:53:27 +0000 | [diff] [blame] | 185 | self.client.rebuild_server, |
zhufl | 406e913 | 2017-05-09 16:21:54 +0800 | [diff] [blame] | 186 | self.deleted_server_id, self.image_ref) |
Joe H. Rahme | b2e01ab | 2015-10-27 17:30:53 +0100 | [diff] [blame] | 187 | |
Jordan Pittier | c5665a6 | 2017-04-12 16:42:53 +0200 | [diff] [blame] | 188 | @decorators.related_bug('1660878', status_code=409) |
Jordan Pittier | 3b46d27 | 2017-04-12 16:17:28 +0200 | [diff] [blame] | 189 | @decorators.attr(type=['negative']) |
Ken'ichi Ohmichi | 14b0ae1 | 2017-01-27 17:18:52 -0800 | [diff] [blame] | 190 | @decorators.idempotent_id('581a397d-5eab-486f-9cf9-1014bbd4c984') |
Joe H. Rahme | b2e01ab | 2015-10-27 17:30:53 +0100 | [diff] [blame] | 191 | def test_reboot_deleted_server(self): |
zhufl | b5603bc | 2020-05-27 09:18:24 +0800 | [diff] [blame] | 192 | """Rebooting a deleted server should fail""" |
Ken'ichi Ohmichi | 5271b0f | 2015-08-10 07:53:27 +0000 | [diff] [blame] | 193 | self.assertRaises(lib_exc.NotFound, self.client.reboot_server, |
zhufl | 406e913 | 2017-05-09 16:21:54 +0800 | [diff] [blame] | 194 | self.deleted_server_id, type='SOFT') |
Rohit Karajgi | dc300b2 | 2012-05-04 08:11:00 -0700 | [diff] [blame] | 195 | |
Jordan Pittier | 3b46d27 | 2017-04-12 16:17:28 +0200 | [diff] [blame] | 196 | @decorators.attr(type=['negative']) |
Ken'ichi Ohmichi | 14b0ae1 | 2017-01-27 17:18:52 -0800 | [diff] [blame] | 197 | @decorators.idempotent_id('d86141a7-906e-4731-b187-d64a2ea61422') |
Ken'ichi Ohmichi | d90c010 | 2013-10-13 23:55:31 +0900 | [diff] [blame] | 198 | def test_rebuild_non_existent_server(self): |
zhufl | b5603bc | 2020-05-27 09:18:24 +0800 | [diff] [blame] | 199 | """Rebuilding a non existent server should fail""" |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 200 | nonexistent_server = data_utils.rand_uuid() |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 201 | self.assertRaises(lib_exc.NotFound, |
Ken'ichi Ohmichi | 5271b0f | 2015-08-10 07:53:27 +0000 | [diff] [blame] | 202 | self.client.rebuild_server, |
Ken'ichi Ohmichi | d90c010 | 2013-10-13 23:55:31 +0900 | [diff] [blame] | 203 | nonexistent_server, |
Emily Hugenbruch | 589028a | 2017-02-13 11:26:22 -0500 | [diff] [blame] | 204 | self.image_ref) |
Ken'ichi Ohmichi | d90c010 | 2013-10-13 23:55:31 +0900 | [diff] [blame] | 205 | |
Jordan Pittier | 3b46d27 | 2017-04-12 16:17:28 +0200 | [diff] [blame] | 206 | @decorators.attr(type=['negative']) |
Ken'ichi Ohmichi | 14b0ae1 | 2017-01-27 17:18:52 -0800 | [diff] [blame] | 207 | @decorators.idempotent_id('fd57f159-68d6-4c2a-902b-03070828a87e') |
Rohit Karajgi | dc300b2 | 2012-05-04 08:11:00 -0700 | [diff] [blame] | 208 | def test_create_numeric_server_name(self): |
zhufl | b5603bc | 2020-05-27 09:18:24 +0800 | [diff] [blame] | 209 | """Creating a server with numeric server name should fail""" |
Rohit Karajgi | dc300b2 | 2012-05-04 08:11:00 -0700 | [diff] [blame] | 210 | server_name = 12345 |
Masayuki Igawa | 4b29e47 | 2015-02-16 10:41:54 +0900 | [diff] [blame] | 211 | self.assertRaises(lib_exc.BadRequest, |
Ken'ichi Ohmichi | cfc052e | 2013-10-23 11:50:04 +0900 | [diff] [blame] | 212 | self.create_test_server, |
Sean Dague | 22897e1 | 2013-02-25 17:54:09 -0500 | [diff] [blame] | 213 | name=server_name) |
Rohit Karajgi | dc300b2 | 2012-05-04 08:11:00 -0700 | [diff] [blame] | 214 | |
Jordan Pittier | 3b46d27 | 2017-04-12 16:17:28 +0200 | [diff] [blame] | 215 | @decorators.attr(type=['negative']) |
Ken'ichi Ohmichi | 14b0ae1 | 2017-01-27 17:18:52 -0800 | [diff] [blame] | 216 | @decorators.idempotent_id('c3e0fb12-07fc-4d76-a22e-37409887afe8') |
Rohit Karajgi | dc300b2 | 2012-05-04 08:11:00 -0700 | [diff] [blame] | 217 | def test_create_server_name_length_exceeds_256(self): |
zhufl | b5603bc | 2020-05-27 09:18:24 +0800 | [diff] [blame] | 218 | """Creating a server with name length exceeding limit should fail |
Rohit Karajgi | dc300b2 | 2012-05-04 08:11:00 -0700 | [diff] [blame] | 219 | |
zhufl | b5603bc | 2020-05-27 09:18:24 +0800 | [diff] [blame] | 220 | Create a server with name length exceeding 255 characters, an error is |
| 221 | returned. |
| 222 | """ |
Rohit Karajgi | dc300b2 | 2012-05-04 08:11:00 -0700 | [diff] [blame] | 223 | server_name = 'a' * 256 |
Masayuki Igawa | 4b29e47 | 2015-02-16 10:41:54 +0900 | [diff] [blame] | 224 | self.assertRaises(lib_exc.BadRequest, |
Ken'ichi Ohmichi | cfc052e | 2013-10-23 11:50:04 +0900 | [diff] [blame] | 225 | self.create_test_server, |
Sean Dague | 22897e1 | 2013-02-25 17:54:09 -0500 | [diff] [blame] | 226 | name=server_name) |
Rohit Karajgi | dc300b2 | 2012-05-04 08:11:00 -0700 | [diff] [blame] | 227 | |
Jordan Pittier | 3b46d27 | 2017-04-12 16:17:28 +0200 | [diff] [blame] | 228 | @decorators.attr(type=['negative']) |
Jordan Pittier | c5665a6 | 2017-04-12 16:42:53 +0200 | [diff] [blame] | 229 | @decorators.related_bug('1651064', status_code=500) |
Andrea Frittoli | cd36841 | 2017-08-14 21:37:56 +0100 | [diff] [blame] | 230 | @utils.services('volume') |
Ken'ichi Ohmichi | 14b0ae1 | 2017-01-27 17:18:52 -0800 | [diff] [blame] | 231 | @decorators.idempotent_id('12146ac1-d7df-4928-ad25-b1f99e5286cd') |
Ken'ichi Ohmichi | 8ee59f8 | 2016-12-26 17:06:00 -0800 | [diff] [blame] | 232 | def test_create_server_invalid_bdm_in_2nd_dict(self): |
zhufl | b5603bc | 2020-05-27 09:18:24 +0800 | [diff] [blame] | 233 | """Creating a server with invalid block_device_mapping_v2 should fail |
| 234 | |
| 235 | Create a server with invalid block_device_mapping_v2, an error is |
| 236 | returned. |
| 237 | """ |
Ken'ichi Ohmichi | 8ee59f8 | 2016-12-26 17:06:00 -0800 | [diff] [blame] | 238 | volume = self.create_volume() |
| 239 | bdm_1st = {"source_type": "image", |
| 240 | "delete_on_termination": True, |
| 241 | "boot_index": 0, |
| 242 | "uuid": self.image_ref, |
| 243 | "destination_type": "local"} |
| 244 | bdm_2nd = {"source_type": "volume", |
| 245 | "uuid": volume["id"], |
| 246 | "destination_type": "invalid"} |
| 247 | bdm = [bdm_1st, bdm_2nd] |
| 248 | |
| 249 | self.assertRaises(lib_exc.BadRequest, |
| 250 | self.create_test_server, |
| 251 | image_id=self.image_ref, |
| 252 | block_device_mapping_v2=bdm) |
| 253 | |
Jordan Pittier | 3b46d27 | 2017-04-12 16:17:28 +0200 | [diff] [blame] | 254 | @decorators.attr(type=['negative']) |
Ken'ichi Ohmichi | 14b0ae1 | 2017-01-27 17:18:52 -0800 | [diff] [blame] | 255 | @decorators.idempotent_id('4e72dc2d-44c5-4336-9667-f7972e95c402') |
Rohit Karajgi | dc300b2 | 2012-05-04 08:11:00 -0700 | [diff] [blame] | 256 | def test_create_with_invalid_network_uuid(self): |
zhufl | b5603bc | 2020-05-27 09:18:24 +0800 | [diff] [blame] | 257 | """Creating a server with invalid network uuid should fail""" |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 258 | # Pass invalid network uuid while creating a server |
Chris Yeoh | fc9e333 | 2013-01-21 09:28:13 +1030 | [diff] [blame] | 259 | networks = [{'fixed_ip': '10.0.1.1', 'uuid': 'a-b-c-d-e-f-g-h-i-j'}] |
Masayuki Igawa | 4b29e47 | 2015-02-16 10:41:54 +0900 | [diff] [blame] | 260 | self.assertRaises(lib_exc.BadRequest, |
Ken'ichi Ohmichi | cfc052e | 2013-10-23 11:50:04 +0900 | [diff] [blame] | 261 | self.create_test_server, |
Zhongyue Luo | 79d8d36 | 2012-09-25 13:49:27 +0800 | [diff] [blame] | 262 | networks=networks) |
Rohit Karajgi | dc300b2 | 2012-05-04 08:11:00 -0700 | [diff] [blame] | 263 | |
Jordan Pittier | 3b46d27 | 2017-04-12 16:17:28 +0200 | [diff] [blame] | 264 | @decorators.attr(type=['negative']) |
Ken'ichi Ohmichi | 14b0ae1 | 2017-01-27 17:18:52 -0800 | [diff] [blame] | 265 | @decorators.idempotent_id('7a2efc39-530c-47de-b875-2dd01c8d39bd') |
nayna-patel | 179077c | 2014-01-15 12:27:16 +0000 | [diff] [blame] | 266 | def test_create_with_non_existent_keypair(self): |
zhufl | b5603bc | 2020-05-27 09:18:24 +0800 | [diff] [blame] | 267 | """Creating a server with non-existent keypair should fail""" |
Chang Bo Guo | f099f80 | 2013-09-13 19:01:46 -0700 | [diff] [blame] | 268 | # Pass a non-existent keypair while creating a server |
Masayuki Igawa | 259c113 | 2013-10-31 17:48:44 +0900 | [diff] [blame] | 269 | key_name = data_utils.rand_name('key') |
Masayuki Igawa | 4b29e47 | 2015-02-16 10:41:54 +0900 | [diff] [blame] | 270 | self.assertRaises(lib_exc.BadRequest, |
Ken'ichi Ohmichi | cfc052e | 2013-10-23 11:50:04 +0900 | [diff] [blame] | 271 | self.create_test_server, |
Zhongyue Luo | 79d8d36 | 2012-09-25 13:49:27 +0800 | [diff] [blame] | 272 | key_name=key_name) |
Rohit Karajgi | dc300b2 | 2012-05-04 08:11:00 -0700 | [diff] [blame] | 273 | |
Jordan Pittier | 3b46d27 | 2017-04-12 16:17:28 +0200 | [diff] [blame] | 274 | @decorators.attr(type=['negative']) |
Ken'ichi Ohmichi | 14b0ae1 | 2017-01-27 17:18:52 -0800 | [diff] [blame] | 275 | @decorators.idempotent_id('7fc74810-0bd2-4cd7-8244-4f33a9db865a') |
Rohit Karajgi | dc300b2 | 2012-05-04 08:11:00 -0700 | [diff] [blame] | 276 | def test_create_server_metadata_exceeds_length_limit(self): |
zhufl | b5603bc | 2020-05-27 09:18:24 +0800 | [diff] [blame] | 277 | """Creating a server with metadata longer than limit should fail """ |
Sean Dague | 4dd2c0b | 2013-01-03 17:50:28 -0500 | [diff] [blame] | 278 | # Pass really long metadata while creating a server |
Rohit Karajgi | dc300b2 | 2012-05-04 08:11:00 -0700 | [diff] [blame] | 279 | metadata = {'a': 'b' * 260} |
Masayuki Igawa | 4b29e47 | 2015-02-16 10:41:54 +0900 | [diff] [blame] | 280 | self.assertRaises((lib_exc.BadRequest, lib_exc.OverLimit), |
Ken'ichi Ohmichi | cfc052e | 2013-10-23 11:50:04 +0900 | [diff] [blame] | 281 | self.create_test_server, |
Ken'ichi Ohmichi | f2d436e | 2015-09-03 01:13:16 +0000 | [diff] [blame] | 282 | metadata=metadata) |
Rohit Karajgi | dc300b2 | 2012-05-04 08:11:00 -0700 | [diff] [blame] | 283 | |
Jordan Pittier | 3b46d27 | 2017-04-12 16:17:28 +0200 | [diff] [blame] | 284 | @decorators.attr(type=['negative']) |
Ken'ichi Ohmichi | 14b0ae1 | 2017-01-27 17:18:52 -0800 | [diff] [blame] | 285 | @decorators.idempotent_id('aa8eed43-e2cb-4ebf-930b-da14f6a21d81') |
Rohit Karajgi | dc300b2 | 2012-05-04 08:11:00 -0700 | [diff] [blame] | 286 | def test_update_name_of_non_existent_server(self): |
zhufl | b5603bc | 2020-05-27 09:18:24 +0800 | [diff] [blame] | 287 | """Updating name of a non-existent server should fail""" |
Shuquan Huang | 74b0346 | 2015-08-27 04:06:50 +0000 | [diff] [blame] | 288 | nonexistent_server = data_utils.rand_uuid() |
zhufl | c6ce539 | 2016-08-17 14:34:37 +0800 | [diff] [blame] | 289 | new_name = data_utils.rand_name( |
| 290 | self.__class__.__name__ + '-server') + '_updated' |
Rohit Karajgi | dc300b2 | 2012-05-04 08:11:00 -0700 | [diff] [blame] | 291 | |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 292 | self.assertRaises(lib_exc.NotFound, self.client.update_server, |
Shuquan Huang | 74b0346 | 2015-08-27 04:06:50 +0000 | [diff] [blame] | 293 | nonexistent_server, name=new_name) |
Rohit Karajgi | dc300b2 | 2012-05-04 08:11:00 -0700 | [diff] [blame] | 294 | |
Jordan Pittier | 3b46d27 | 2017-04-12 16:17:28 +0200 | [diff] [blame] | 295 | @decorators.attr(type=['negative']) |
Ken'ichi Ohmichi | 14b0ae1 | 2017-01-27 17:18:52 -0800 | [diff] [blame] | 296 | @decorators.idempotent_id('38204696-17c6-44da-9590-40f87fb5a899') |
Rohit Karajgi | dc300b2 | 2012-05-04 08:11:00 -0700 | [diff] [blame] | 297 | def test_update_server_set_empty_name(self): |
zhufl | b5603bc | 2020-05-27 09:18:24 +0800 | [diff] [blame] | 298 | """Updating name of the server to an empty string should fail""" |
Rohit Karajgi | dc300b2 | 2012-05-04 08:11:00 -0700 | [diff] [blame] | 299 | new_name = '' |
Masayuki Igawa | 4b29e47 | 2015-02-16 10:41:54 +0900 | [diff] [blame] | 300 | self.assertRaises(lib_exc.BadRequest, self.client.update_server, |
Shuquan Huang | 74b0346 | 2015-08-27 04:06:50 +0000 | [diff] [blame] | 301 | self.server_id, name=new_name) |
Rohit Karajgi | dc300b2 | 2012-05-04 08:11:00 -0700 | [diff] [blame] | 302 | |
Jordan Pittier | 3b46d27 | 2017-04-12 16:17:28 +0200 | [diff] [blame] | 303 | @decorators.attr(type=['negative']) |
Ken'ichi Ohmichi | 14b0ae1 | 2017-01-27 17:18:52 -0800 | [diff] [blame] | 304 | @decorators.idempotent_id('5c8e244c-dada-4590-9944-749c455b431f') |
Rohit Karajgi | dc300b2 | 2012-05-04 08:11:00 -0700 | [diff] [blame] | 305 | def test_update_server_name_length_exceeds_256(self): |
zhufl | b5603bc | 2020-05-27 09:18:24 +0800 | [diff] [blame] | 306 | """Updating name of server exceeding the name length limit should fail |
Rohit Karajgi | dc300b2 | 2012-05-04 08:11:00 -0700 | [diff] [blame] | 307 | |
zhufl | b5603bc | 2020-05-27 09:18:24 +0800 | [diff] [blame] | 308 | Update name of server exceeding the name length limit, an error is |
| 309 | returned. |
| 310 | """ |
Rohit Karajgi | dc300b2 | 2012-05-04 08:11:00 -0700 | [diff] [blame] | 311 | new_name = 'a' * 256 |
Masayuki Igawa | 4b29e47 | 2015-02-16 10:41:54 +0900 | [diff] [blame] | 312 | self.assertRaises(lib_exc.BadRequest, |
Zhongyue Luo | 79d8d36 | 2012-09-25 13:49:27 +0800 | [diff] [blame] | 313 | self.client.update_server, |
Ken'ichi Ohmichi | da30650 | 2013-10-08 23:44:55 +0900 | [diff] [blame] | 314 | self.server_id, |
Zhongyue Luo | 79d8d36 | 2012-09-25 13:49:27 +0800 | [diff] [blame] | 315 | name=new_name) |
Rohit Karajgi | dc300b2 | 2012-05-04 08:11:00 -0700 | [diff] [blame] | 316 | |
Jordan Pittier | 3b46d27 | 2017-04-12 16:17:28 +0200 | [diff] [blame] | 317 | @decorators.attr(type=['negative']) |
Ken'ichi Ohmichi | 14b0ae1 | 2017-01-27 17:18:52 -0800 | [diff] [blame] | 318 | @decorators.idempotent_id('1041b4e6-514b-4855-96a5-e974b60870a3') |
Rohit Karajgi | dc300b2 | 2012-05-04 08:11:00 -0700 | [diff] [blame] | 319 | def test_delete_non_existent_server(self): |
zhufl | b5603bc | 2020-05-27 09:18:24 +0800 | [diff] [blame] | 320 | """Deleting a non existent server should fail""" |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 321 | nonexistent_server = data_utils.rand_uuid() |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 322 | self.assertRaises(lib_exc.NotFound, self.client.delete_server, |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 323 | nonexistent_server) |
Rohit Karajgi | dc300b2 | 2012-05-04 08:11:00 -0700 | [diff] [blame] | 324 | |
Jordan Pittier | 3b46d27 | 2017-04-12 16:17:28 +0200 | [diff] [blame] | 325 | @decorators.attr(type=['negative']) |
Ken'ichi Ohmichi | 14b0ae1 | 2017-01-27 17:18:52 -0800 | [diff] [blame] | 326 | @decorators.idempotent_id('75f79124-277c-45e6-a373-a1d6803f4cc4') |
Rohit Karajgi | dc300b2 | 2012-05-04 08:11:00 -0700 | [diff] [blame] | 327 | def test_delete_server_pass_negative_id(self): |
zhufl | b5603bc | 2020-05-27 09:18:24 +0800 | [diff] [blame] | 328 | """Passing an invalid string parameter to delete server should fail""" |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 329 | self.assertRaises(lib_exc.NotFound, self.client.delete_server, -1) |
Rohit Karajgi | dc300b2 | 2012-05-04 08:11:00 -0700 | [diff] [blame] | 330 | |
Jordan Pittier | 3b46d27 | 2017-04-12 16:17:28 +0200 | [diff] [blame] | 331 | @decorators.attr(type=['negative']) |
Ken'ichi Ohmichi | 14b0ae1 | 2017-01-27 17:18:52 -0800 | [diff] [blame] | 332 | @decorators.idempotent_id('f4d7279b-5fd2-4bf2-9ba4-ae35df0d18c5') |
Rohit Karajgi | dc300b2 | 2012-05-04 08:11:00 -0700 | [diff] [blame] | 333 | def test_delete_server_pass_id_exceeding_length_limit(self): |
zhufl | b5603bc | 2020-05-27 09:18:24 +0800 | [diff] [blame] | 334 | """Deleting server with a server ID exceeding length limit should fail |
Rohit Karajgi | dc300b2 | 2012-05-04 08:11:00 -0700 | [diff] [blame] | 335 | |
zhufl | b5603bc | 2020-05-27 09:18:24 +0800 | [diff] [blame] | 336 | Pass a server ID that exceeds length limit to delete server, an error |
| 337 | is returned. |
| 338 | """ |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 339 | self.assertRaises(lib_exc.NotFound, self.client.delete_server, |
Sirushti Murugesan | 12dc973 | 2016-07-13 22:49:17 +0530 | [diff] [blame] | 340 | sys.maxsize + 1) |
donald-ngo | 78bd7f5 | 2013-02-08 14:35:16 -0800 | [diff] [blame] | 341 | |
Jordan Pittier | 3b46d27 | 2017-04-12 16:17:28 +0200 | [diff] [blame] | 342 | @decorators.attr(type=['negative']) |
Ken'ichi Ohmichi | 14b0ae1 | 2017-01-27 17:18:52 -0800 | [diff] [blame] | 343 | @decorators.idempotent_id('c5fa6041-80cd-483b-aa6d-4e45f19d093c') |
donald-ngo | 78bd7f5 | 2013-02-08 14:35:16 -0800 | [diff] [blame] | 344 | def test_create_with_nonexistent_security_group(self): |
zhufl | b5603bc | 2020-05-27 09:18:24 +0800 | [diff] [blame] | 345 | """Creating a server with a nonexistent security group should fail""" |
donald-ngo | 18edb81 | 2013-02-22 11:37:15 -0800 | [diff] [blame] | 346 | security_groups = [{'name': 'does_not_exist'}] |
Masayuki Igawa | 4b29e47 | 2015-02-16 10:41:54 +0900 | [diff] [blame] | 347 | self.assertRaises(lib_exc.BadRequest, |
Ken'ichi Ohmichi | cfc052e | 2013-10-23 11:50:04 +0900 | [diff] [blame] | 348 | self.create_test_server, |
donald-ngo | 18edb81 | 2013-02-22 11:37:15 -0800 | [diff] [blame] | 349 | security_groups=security_groups) |
hi2suresh | 063acbc | 2013-02-20 09:32:03 +0000 | [diff] [blame] | 350 | |
Jordan Pittier | 3b46d27 | 2017-04-12 16:17:28 +0200 | [diff] [blame] | 351 | @decorators.attr(type=['negative']) |
Ken'ichi Ohmichi | 14b0ae1 | 2017-01-27 17:18:52 -0800 | [diff] [blame] | 352 | @decorators.idempotent_id('3436b02f-1b1e-4f03-881e-c6a602327439') |
hi2suresh | 063acbc | 2013-02-20 09:32:03 +0000 | [diff] [blame] | 353 | def test_get_non_existent_server(self): |
zhufl | b5603bc | 2020-05-27 09:18:24 +0800 | [diff] [blame] | 354 | """Getting a non existent server details should fail""" |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 355 | nonexistent_server = data_utils.rand_uuid() |
Ken'ichi Ohmichi | 7680024 | 2015-07-03 05:12:31 +0000 | [diff] [blame] | 356 | self.assertRaises(lib_exc.NotFound, self.client.show_server, |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 357 | nonexistent_server) |
Sean Dague | e623f75 | 2013-02-27 14:52:15 -0500 | [diff] [blame] | 358 | |
Jordan Pittier | 3b46d27 | 2017-04-12 16:17:28 +0200 | [diff] [blame] | 359 | @decorators.attr(type=['negative']) |
Ken'ichi Ohmichi | 14b0ae1 | 2017-01-27 17:18:52 -0800 | [diff] [blame] | 360 | @decorators.idempotent_id('a31460a9-49e1-42aa-82ee-06e0bb7c2d03') |
Anju Tiwari | 6c33616 | 2013-08-08 12:21:02 +0530 | [diff] [blame] | 361 | def test_stop_non_existent_server(self): |
zhufl | b5603bc | 2020-05-27 09:18:24 +0800 | [diff] [blame] | 362 | """Stopping a non existent server should fail""" |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 363 | nonexistent_server = data_utils.rand_uuid() |
Ken'ichi Ohmichi | b263108 | 2015-08-27 01:31:00 +0000 | [diff] [blame] | 364 | self.assertRaises(lib_exc.NotFound, self.servers_client.stop_server, |
Ken'ichi Ohmichi | d90c010 | 2013-10-13 23:55:31 +0900 | [diff] [blame] | 365 | nonexistent_server) |
Anju Tiwari | 6c33616 | 2013-08-08 12:21:02 +0530 | [diff] [blame] | 366 | |
Ken'ichi Ohmichi | 14b0ae1 | 2017-01-27 17:18:52 -0800 | [diff] [blame] | 367 | @decorators.idempotent_id('6a8dc0c6-6cd4-4c0a-9f32-413881828091') |
Matt Riedemann | 992162e | 2014-03-24 09:11:06 -0700 | [diff] [blame] | 368 | @testtools.skipUnless(CONF.compute_feature_enabled.pause, |
| 369 | 'Pause is not available.') |
Jordan Pittier | 3b46d27 | 2017-04-12 16:17:28 +0200 | [diff] [blame] | 370 | @decorators.attr(type=['negative']) |
Anju Tiwari | 6c33616 | 2013-08-08 12:21:02 +0530 | [diff] [blame] | 371 | def test_pause_non_existent_server(self): |
zhufl | b5603bc | 2020-05-27 09:18:24 +0800 | [diff] [blame] | 372 | """Pausing a non existent server should fail""" |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 373 | nonexistent_server = data_utils.rand_uuid() |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 374 | self.assertRaises(lib_exc.NotFound, self.client.pause_server, |
Ken'ichi Ohmichi | d90c010 | 2013-10-13 23:55:31 +0900 | [diff] [blame] | 375 | nonexistent_server) |
LingxianKong | b2ca96f | 2013-09-28 23:09:30 +0800 | [diff] [blame] | 376 | |
Ken'ichi Ohmichi | 14b0ae1 | 2017-01-27 17:18:52 -0800 | [diff] [blame] | 377 | @decorators.idempotent_id('705b8e3a-e8a7-477c-a19b-6868fc24ac75') |
Matt Riedemann | 992162e | 2014-03-24 09:11:06 -0700 | [diff] [blame] | 378 | @testtools.skipUnless(CONF.compute_feature_enabled.pause, |
| 379 | 'Pause is not available.') |
Jordan Pittier | 3b46d27 | 2017-04-12 16:17:28 +0200 | [diff] [blame] | 380 | @decorators.attr(type=['negative']) |
LingxianKong | b2ca96f | 2013-09-28 23:09:30 +0800 | [diff] [blame] | 381 | def test_unpause_non_existent_server(self): |
zhufl | b5603bc | 2020-05-27 09:18:24 +0800 | [diff] [blame] | 382 | """Unpausing a non existent server should fail""" |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 383 | nonexistent_server = data_utils.rand_uuid() |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 384 | self.assertRaises(lib_exc.NotFound, self.client.unpause_server, |
Ken'ichi Ohmichi | d90c010 | 2013-10-13 23:55:31 +0900 | [diff] [blame] | 385 | nonexistent_server) |
LingxianKong | b2ca96f | 2013-09-28 23:09:30 +0800 | [diff] [blame] | 386 | |
Ken'ichi Ohmichi | 14b0ae1 | 2017-01-27 17:18:52 -0800 | [diff] [blame] | 387 | @decorators.idempotent_id('c8e639a7-ece8-42dd-a2e0-49615917ba4f') |
Matt Riedemann | 992162e | 2014-03-24 09:11:06 -0700 | [diff] [blame] | 388 | @testtools.skipUnless(CONF.compute_feature_enabled.pause, |
| 389 | 'Pause is not available.') |
Jordan Pittier | 3b46d27 | 2017-04-12 16:17:28 +0200 | [diff] [blame] | 390 | @decorators.attr(type=['negative']) |
LingxianKong | b2ca96f | 2013-09-28 23:09:30 +0800 | [diff] [blame] | 391 | def test_unpause_server_invalid_state(self): |
zhufl | b5603bc | 2020-05-27 09:18:24 +0800 | [diff] [blame] | 392 | """Unpausing an active server should fail""" |
Masayuki Igawa | d938876 | 2015-01-20 14:56:42 +0900 | [diff] [blame] | 393 | self.assertRaises(lib_exc.Conflict, |
LingxianKong | b2ca96f | 2013-09-28 23:09:30 +0800 | [diff] [blame] | 394 | self.client.unpause_server, |
Ken'ichi Ohmichi | da30650 | 2013-10-08 23:44:55 +0900 | [diff] [blame] | 395 | self.server_id) |
Anju Tiwari | 6c33616 | 2013-08-08 12:21:02 +0530 | [diff] [blame] | 396 | |
Ken'ichi Ohmichi | 14b0ae1 | 2017-01-27 17:18:52 -0800 | [diff] [blame] | 397 | @decorators.idempotent_id('d1f032d5-7b6e-48aa-b252-d5f16dd994ca') |
Matt Riedemann | f0cf695 | 2014-03-24 09:08:52 -0700 | [diff] [blame] | 398 | @testtools.skipUnless(CONF.compute_feature_enabled.suspend, |
| 399 | 'Suspend is not available.') |
Jordan Pittier | 3b46d27 | 2017-04-12 16:17:28 +0200 | [diff] [blame] | 400 | @decorators.attr(type=['negative']) |
LingxianKong | 691a570 | 2013-09-29 11:43:45 +0800 | [diff] [blame] | 401 | def test_suspend_non_existent_server(self): |
zhufl | b5603bc | 2020-05-27 09:18:24 +0800 | [diff] [blame] | 402 | """Suspending a non existent server should fail""" |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 403 | nonexistent_server = data_utils.rand_uuid() |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 404 | self.assertRaises(lib_exc.NotFound, self.client.suspend_server, |
Ken'ichi Ohmichi | d90c010 | 2013-10-13 23:55:31 +0900 | [diff] [blame] | 405 | nonexistent_server) |
LingxianKong | 691a570 | 2013-09-29 11:43:45 +0800 | [diff] [blame] | 406 | |
Ken'ichi Ohmichi | 14b0ae1 | 2017-01-27 17:18:52 -0800 | [diff] [blame] | 407 | @decorators.idempotent_id('7f323206-05a9-4bf8-996b-dd5b2036501b') |
Matt Riedemann | f0cf695 | 2014-03-24 09:08:52 -0700 | [diff] [blame] | 408 | @testtools.skipUnless(CONF.compute_feature_enabled.suspend, |
| 409 | 'Suspend is not available.') |
Jordan Pittier | 3b46d27 | 2017-04-12 16:17:28 +0200 | [diff] [blame] | 410 | @decorators.attr(type=['negative']) |
LingxianKong | 691a570 | 2013-09-29 11:43:45 +0800 | [diff] [blame] | 411 | def test_suspend_server_invalid_state(self): |
zhufl | b5603bc | 2020-05-27 09:18:24 +0800 | [diff] [blame] | 412 | """Suspending a suspended server should fail""" |
David Kranz | ae99b9a | 2015-02-16 13:37:01 -0500 | [diff] [blame] | 413 | self.client.suspend_server(self.server_id) |
Ken'ichi Ohmichi | 0eb153c | 2015-07-13 02:18:25 +0000 | [diff] [blame] | 414 | waiters.wait_for_server_status(self.client, self.server_id, |
| 415 | 'SUSPENDED') |
Masayuki Igawa | d938876 | 2015-01-20 14:56:42 +0900 | [diff] [blame] | 416 | self.assertRaises(lib_exc.Conflict, |
LingxianKong | 691a570 | 2013-09-29 11:43:45 +0800 | [diff] [blame] | 417 | self.client.suspend_server, |
Ken'ichi Ohmichi | da30650 | 2013-10-08 23:44:55 +0900 | [diff] [blame] | 418 | self.server_id) |
Attila Fazekas | 305e65b | 2013-10-29 13:23:07 +0100 | [diff] [blame] | 419 | self.client.resume_server(self.server_id) |
LingxianKong | 691a570 | 2013-09-29 11:43:45 +0800 | [diff] [blame] | 420 | |
Ken'ichi Ohmichi | 14b0ae1 | 2017-01-27 17:18:52 -0800 | [diff] [blame] | 421 | @decorators.idempotent_id('221cd282-bddb-4837-a683-89c2487389b6') |
Matt Riedemann | f0cf695 | 2014-03-24 09:08:52 -0700 | [diff] [blame] | 422 | @testtools.skipUnless(CONF.compute_feature_enabled.suspend, |
| 423 | 'Suspend is not available.') |
Jordan Pittier | 3b46d27 | 2017-04-12 16:17:28 +0200 | [diff] [blame] | 424 | @decorators.attr(type=['negative']) |
LingxianKong | 691a570 | 2013-09-29 11:43:45 +0800 | [diff] [blame] | 425 | def test_resume_non_existent_server(self): |
zhufl | b5603bc | 2020-05-27 09:18:24 +0800 | [diff] [blame] | 426 | """Resuming a non existent server should fail""" |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 427 | nonexistent_server = data_utils.rand_uuid() |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 428 | self.assertRaises(lib_exc.NotFound, self.client.resume_server, |
Ken'ichi Ohmichi | d90c010 | 2013-10-13 23:55:31 +0900 | [diff] [blame] | 429 | nonexistent_server) |
LingxianKong | 691a570 | 2013-09-29 11:43:45 +0800 | [diff] [blame] | 430 | |
Ken'ichi Ohmichi | 14b0ae1 | 2017-01-27 17:18:52 -0800 | [diff] [blame] | 431 | @decorators.idempotent_id('ccb6294d-c4c9-498f-8a43-554c098bfadb') |
Matt Riedemann | f0cf695 | 2014-03-24 09:08:52 -0700 | [diff] [blame] | 432 | @testtools.skipUnless(CONF.compute_feature_enabled.suspend, |
| 433 | 'Suspend is not available.') |
Jordan Pittier | 3b46d27 | 2017-04-12 16:17:28 +0200 | [diff] [blame] | 434 | @decorators.attr(type=['negative']) |
LingxianKong | 691a570 | 2013-09-29 11:43:45 +0800 | [diff] [blame] | 435 | def test_resume_server_invalid_state(self): |
zhufl | b5603bc | 2020-05-27 09:18:24 +0800 | [diff] [blame] | 436 | """Resuming an active server should fail""" |
Masayuki Igawa | d938876 | 2015-01-20 14:56:42 +0900 | [diff] [blame] | 437 | self.assertRaises(lib_exc.Conflict, |
LingxianKong | 691a570 | 2013-09-29 11:43:45 +0800 | [diff] [blame] | 438 | self.client.resume_server, |
Ken'ichi Ohmichi | da30650 | 2013-10-08 23:44:55 +0900 | [diff] [blame] | 439 | self.server_id) |
LingxianKong | 691a570 | 2013-09-29 11:43:45 +0800 | [diff] [blame] | 440 | |
Jordan Pittier | 3b46d27 | 2017-04-12 16:17:28 +0200 | [diff] [blame] | 441 | @decorators.attr(type=['negative']) |
Ken'ichi Ohmichi | 14b0ae1 | 2017-01-27 17:18:52 -0800 | [diff] [blame] | 442 | @decorators.idempotent_id('7dd919e7-413f-4198-bebb-35e2a01b13e9') |
Ken'ichi Ohmichi | d90c010 | 2013-10-13 23:55:31 +0900 | [diff] [blame] | 443 | def test_get_console_output_of_non_existent_server(self): |
zhufl | b5603bc | 2020-05-27 09:18:24 +0800 | [diff] [blame] | 444 | """Getting the console output for a non existent server should fail""" |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 445 | nonexistent_server = data_utils.rand_uuid() |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 446 | self.assertRaises(lib_exc.NotFound, |
Ken'ichi Ohmichi | d90c010 | 2013-10-13 23:55:31 +0900 | [diff] [blame] | 447 | self.client.get_console_output, |
Ken'ichi Ohmichi | bf4766a | 2015-12-09 07:48:43 +0000 | [diff] [blame] | 448 | nonexistent_server, length=10) |
Ken'ichi Ohmichi | d90c010 | 2013-10-13 23:55:31 +0900 | [diff] [blame] | 449 | |
Jordan Pittier | 3b46d27 | 2017-04-12 16:17:28 +0200 | [diff] [blame] | 450 | @decorators.attr(type=['negative']) |
Ken'ichi Ohmichi | 14b0ae1 | 2017-01-27 17:18:52 -0800 | [diff] [blame] | 451 | @decorators.idempotent_id('6f47992b-5144-4250-9f8b-f00aa33950f3') |
Lingxian Kong | aecc109 | 2013-10-03 16:18:46 +0800 | [diff] [blame] | 452 | def test_force_delete_nonexistent_server_id(self): |
zhufl | b5603bc | 2020-05-27 09:18:24 +0800 | [diff] [blame] | 453 | """Force-deleting a non existent server should fail""" |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 454 | nonexistent_server = data_utils.rand_uuid() |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 455 | self.assertRaises(lib_exc.NotFound, |
Lingxian Kong | aecc109 | 2013-10-03 16:18:46 +0800 | [diff] [blame] | 456 | self.client.force_delete_server, |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 457 | nonexistent_server) |
Lingxian Kong | aecc109 | 2013-10-03 16:18:46 +0800 | [diff] [blame] | 458 | |
Jordan Pittier | 3b46d27 | 2017-04-12 16:17:28 +0200 | [diff] [blame] | 459 | @decorators.attr(type=['negative']) |
Ken'ichi Ohmichi | 14b0ae1 | 2017-01-27 17:18:52 -0800 | [diff] [blame] | 460 | @decorators.idempotent_id('9c6d38cc-fcfb-437a-85b9-7b788af8bf01') |
Lingxian Kong | aecc109 | 2013-10-03 16:18:46 +0800 | [diff] [blame] | 461 | def test_restore_nonexistent_server_id(self): |
zhufl | b5603bc | 2020-05-27 09:18:24 +0800 | [diff] [blame] | 462 | """Restore-deleting a non existent server should fail |
| 463 | |
| 464 | We can restore a soft deleted server, but can't restore a non |
| 465 | existent server. |
| 466 | """ |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 467 | nonexistent_server = data_utils.rand_uuid() |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 468 | self.assertRaises(lib_exc.NotFound, |
Lingxian Kong | aecc109 | 2013-10-03 16:18:46 +0800 | [diff] [blame] | 469 | self.client.restore_soft_deleted_server, |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 470 | nonexistent_server) |
Lingxian Kong | aecc109 | 2013-10-03 16:18:46 +0800 | [diff] [blame] | 471 | |
Jordan Pittier | 3b46d27 | 2017-04-12 16:17:28 +0200 | [diff] [blame] | 472 | @decorators.attr(type=['negative']) |
Ken'ichi Ohmichi | 14b0ae1 | 2017-01-27 17:18:52 -0800 | [diff] [blame] | 473 | @decorators.idempotent_id('7fcadfab-bd6a-4753-8db7-4a51e51aade9') |
Lingxian Kong | aecc109 | 2013-10-03 16:18:46 +0800 | [diff] [blame] | 474 | def test_restore_server_invalid_state(self): |
zhufl | b5603bc | 2020-05-27 09:18:24 +0800 | [diff] [blame] | 475 | """Restore-deleting a server not in 'soft-delete' state should fail |
| 476 | |
| 477 | We can restore a soft deleted server, but can't restore a server that |
| 478 | is not in 'soft-delete' state. |
| 479 | """ |
Masayuki Igawa | d938876 | 2015-01-20 14:56:42 +0900 | [diff] [blame] | 480 | self.assertRaises(lib_exc.Conflict, |
Lingxian Kong | aecc109 | 2013-10-03 16:18:46 +0800 | [diff] [blame] | 481 | self.client.restore_soft_deleted_server, |
| 482 | self.server_id) |
| 483 | |
Ken'ichi Ohmichi | 14b0ae1 | 2017-01-27 17:18:52 -0800 | [diff] [blame] | 484 | @decorators.idempotent_id('abca56e2-a892-48ea-b5e5-e07e69774816') |
David Shrewsbury | 25f666f | 2014-07-22 12:17:59 -0400 | [diff] [blame] | 485 | @testtools.skipUnless(CONF.compute_feature_enabled.shelve, |
| 486 | 'Shelve is not available.') |
Jordan Pittier | 3b46d27 | 2017-04-12 16:17:28 +0200 | [diff] [blame] | 487 | @decorators.attr(type=['negative']) |
Ken'ichi Ohmichi | 39437e2 | 2013-10-06 00:21:38 +0900 | [diff] [blame] | 488 | def test_shelve_non_existent_server(self): |
zhufl | b5603bc | 2020-05-27 09:18:24 +0800 | [diff] [blame] | 489 | """Shelving a non existent server should fail""" |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 490 | nonexistent_server = data_utils.rand_uuid() |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 491 | self.assertRaises(lib_exc.NotFound, self.client.shelve_server, |
Ken'ichi Ohmichi | 39437e2 | 2013-10-06 00:21:38 +0900 | [diff] [blame] | 492 | nonexistent_server) |
| 493 | |
Ken'ichi Ohmichi | 14b0ae1 | 2017-01-27 17:18:52 -0800 | [diff] [blame] | 494 | @decorators.idempotent_id('443e4f9b-e6bf-4389-b601-3a710f15fddd') |
David Shrewsbury | 25f666f | 2014-07-22 12:17:59 -0400 | [diff] [blame] | 495 | @testtools.skipUnless(CONF.compute_feature_enabled.shelve, |
| 496 | 'Shelve is not available.') |
Jordan Pittier | 3b46d27 | 2017-04-12 16:17:28 +0200 | [diff] [blame] | 497 | @decorators.attr(type=['negative']) |
Ken'ichi Ohmichi | 39437e2 | 2013-10-06 00:21:38 +0900 | [diff] [blame] | 498 | def test_shelve_shelved_server(self): |
zhufl | b5603bc | 2020-05-27 09:18:24 +0800 | [diff] [blame] | 499 | """Shelving a shelved server should fail""" |
ghanshyam | 017b5fe | 2016-04-15 18:49:26 +0900 | [diff] [blame] | 500 | compute.shelve_server(self.client, self.server_id) |
Ken'ichi Ohmichi | 39437e2 | 2013-10-06 00:21:38 +0900 | [diff] [blame] | 501 | |
zhufl | aa27003 | 2017-11-27 15:26:49 +0800 | [diff] [blame] | 502 | def _unshelve_server(): |
| 503 | server_info = self.client.show_server(self.server_id)['server'] |
| 504 | if 'SHELVED' in server_info['status']: |
| 505 | self.client.unshelve_server(self.server_id) |
zhufl | 8c9d436 | 2018-04-03 15:45:50 +0800 | [diff] [blame] | 506 | self.addCleanup(_unshelve_server) |
zhufl | aa27003 | 2017-11-27 15:26:49 +0800 | [diff] [blame] | 507 | |
ghanshyam | 0f82525 | 2015-08-25 16:02:50 +0900 | [diff] [blame] | 508 | server = self.client.show_server(self.server_id)['server'] |
Ken'ichi Ohmichi | 39437e2 | 2013-10-06 00:21:38 +0900 | [diff] [blame] | 509 | image_name = server['name'] + '-shelved' |
zhufl | 66275c2 | 2018-03-28 15:32:14 +0800 | [diff] [blame] | 510 | if CONF.image_feature_enabled.api_v1: |
| 511 | kwargs = {'name': image_name} |
| 512 | else: |
| 513 | kwargs = {'params': {'name': image_name}} |
| 514 | images = self.images_client.list_images(**kwargs)['images'] |
Ken'ichi Ohmichi | 39437e2 | 2013-10-06 00:21:38 +0900 | [diff] [blame] | 515 | self.assertEqual(1, len(images)) |
| 516 | self.assertEqual(image_name, images[0]['name']) |
| 517 | |
Masayuki Igawa | d938876 | 2015-01-20 14:56:42 +0900 | [diff] [blame] | 518 | self.assertRaises(lib_exc.Conflict, |
Ken'ichi Ohmichi | 39437e2 | 2013-10-06 00:21:38 +0900 | [diff] [blame] | 519 | self.client.shelve_server, |
| 520 | self.server_id) |
| 521 | |
Attila Fazekas | 305e65b | 2013-10-29 13:23:07 +0100 | [diff] [blame] | 522 | self.client.unshelve_server(self.server_id) |
| 523 | |
Ken'ichi Ohmichi | 14b0ae1 | 2017-01-27 17:18:52 -0800 | [diff] [blame] | 524 | @decorators.idempotent_id('23d23b37-afaf-40d7-aa5d-5726f82d8821') |
David Shrewsbury | 25f666f | 2014-07-22 12:17:59 -0400 | [diff] [blame] | 525 | @testtools.skipUnless(CONF.compute_feature_enabled.shelve, |
| 526 | 'Shelve is not available.') |
Jordan Pittier | 3b46d27 | 2017-04-12 16:17:28 +0200 | [diff] [blame] | 527 | @decorators.attr(type=['negative']) |
Ken'ichi Ohmichi | 39437e2 | 2013-10-06 00:21:38 +0900 | [diff] [blame] | 528 | def test_unshelve_non_existent_server(self): |
zhufl | b5603bc | 2020-05-27 09:18:24 +0800 | [diff] [blame] | 529 | """Unshelving a non existent server should fail""" |
Ken'ichi Ohmichi | aa702b0 | 2013-12-18 01:37:21 +0900 | [diff] [blame] | 530 | nonexistent_server = data_utils.rand_uuid() |
Masayuki Igawa | bfa0760 | 2015-01-20 18:47:17 +0900 | [diff] [blame] | 531 | self.assertRaises(lib_exc.NotFound, self.client.unshelve_server, |
Ken'ichi Ohmichi | 39437e2 | 2013-10-06 00:21:38 +0900 | [diff] [blame] | 532 | nonexistent_server) |
| 533 | |
Ken'ichi Ohmichi | 14b0ae1 | 2017-01-27 17:18:52 -0800 | [diff] [blame] | 534 | @decorators.idempotent_id('8f198ded-1cca-4228-9e65-c6b449c54880') |
David Shrewsbury | 25f666f | 2014-07-22 12:17:59 -0400 | [diff] [blame] | 535 | @testtools.skipUnless(CONF.compute_feature_enabled.shelve, |
| 536 | 'Shelve is not available.') |
Jordan Pittier | 3b46d27 | 2017-04-12 16:17:28 +0200 | [diff] [blame] | 537 | @decorators.attr(type=['negative']) |
Ken'ichi Ohmichi | 39437e2 | 2013-10-06 00:21:38 +0900 | [diff] [blame] | 538 | def test_unshelve_server_invalid_state(self): |
zhufl | b5603bc | 2020-05-27 09:18:24 +0800 | [diff] [blame] | 539 | """Unshelving an active server should fail""" |
Masayuki Igawa | d938876 | 2015-01-20 14:56:42 +0900 | [diff] [blame] | 540 | self.assertRaises(lib_exc.Conflict, |
Ken'ichi Ohmichi | 39437e2 | 2013-10-06 00:21:38 +0900 | [diff] [blame] | 541 | self.client.unshelve_server, |
| 542 | self.server_id) |
Chris Hoge | 2718b3a | 2016-02-23 16:47:14 -0500 | [diff] [blame] | 543 | |
Jordan Pittier | 3b46d27 | 2017-04-12 16:17:28 +0200 | [diff] [blame] | 544 | @decorators.attr(type=['negative']) |
Ken'ichi Ohmichi | 14b0ae1 | 2017-01-27 17:18:52 -0800 | [diff] [blame] | 545 | @decorators.idempotent_id('74085be3-a370-4ca2-bc51-2d0e10e0f573') |
Andrea Frittoli | cd36841 | 2017-08-14 21:37:56 +0100 | [diff] [blame] | 546 | @utils.services('volume', 'image') |
lkuchlan | ddc59a0 | 2016-08-15 14:56:34 +0300 | [diff] [blame] | 547 | def test_create_server_from_non_bootable_volume(self): |
zhufl | b5603bc | 2020-05-27 09:18:24 +0800 | [diff] [blame] | 548 | """Creating a server from a non bootable volume should fail""" |
lkuchlan | ddc59a0 | 2016-08-15 14:56:34 +0300 | [diff] [blame] | 549 | volume = self.create_volume() |
| 550 | |
| 551 | # Update volume bootable status to false |
| 552 | self.volumes_client.set_bootable_volume(volume['id'], |
| 553 | bootable=False) |
| 554 | |
| 555 | # Verify bootable flag was updated |
| 556 | nonbootable_vol = self.volumes_client.show_volume( |
| 557 | volume['id'])['volume'] |
| 558 | self.assertEqual('false', nonbootable_vol['bootable']) |
| 559 | |
| 560 | # Block device mapping |
| 561 | bd_map = [{'boot_index': '0', |
| 562 | 'uuid': volume['id'], |
| 563 | 'source_type': 'volume', |
| 564 | 'destination_type': 'volume', |
| 565 | 'delete_on_termination': False}] |
| 566 | |
| 567 | # Try creating a server from non-bootable volume |
| 568 | self.assertRaises(lib_exc.BadRequest, |
| 569 | self.create_test_server, |
| 570 | image_id='', |
| 571 | wait_until='ACTIVE', |
| 572 | block_device_mapping_v2=bd_map) |
| 573 | |
Chris Hoge | 2718b3a | 2016-02-23 16:47:14 -0500 | [diff] [blame] | 574 | |
| 575 | class ServersNegativeTestMultiTenantJSON(base.BaseV2ComputeTest): |
zhufl | b5603bc | 2020-05-27 09:18:24 +0800 | [diff] [blame] | 576 | """Negative tests of servers for multiple projects""" |
| 577 | |
Eric Fried | e85f029 | 2020-01-23 10:42:27 -0600 | [diff] [blame] | 578 | create_default_network = True |
Chris Hoge | 2718b3a | 2016-02-23 16:47:14 -0500 | [diff] [blame] | 579 | |
| 580 | credentials = ['primary', 'alt'] |
| 581 | |
| 582 | def setUp(self): |
| 583 | super(ServersNegativeTestMultiTenantJSON, self).setUp() |
| 584 | try: |
zhufl | 5376ab3 | 2017-05-09 15:56:50 +0800 | [diff] [blame] | 585 | waiters.wait_for_server_status(self.servers_client, self.server_id, |
Chris Hoge | 2718b3a | 2016-02-23 16:47:14 -0500 | [diff] [blame] | 586 | 'ACTIVE') |
| 587 | except Exception: |
zhufl | ba0e553 | 2017-09-13 10:51:07 +0800 | [diff] [blame] | 588 | self.__class__.server_id = self.recreate_server(self.server_id) |
Chris Hoge | 2718b3a | 2016-02-23 16:47:14 -0500 | [diff] [blame] | 589 | |
| 590 | @classmethod |
| 591 | def setup_clients(cls): |
| 592 | super(ServersNegativeTestMultiTenantJSON, cls).setup_clients() |
| 593 | cls.alt_client = cls.os_alt.servers_client |
| 594 | |
| 595 | @classmethod |
| 596 | def resource_setup(cls): |
| 597 | super(ServersNegativeTestMultiTenantJSON, cls).resource_setup() |
| 598 | server = cls.create_test_server(wait_until='ACTIVE') |
| 599 | cls.server_id = server['id'] |
| 600 | |
Jordan Pittier | 3b46d27 | 2017-04-12 16:17:28 +0200 | [diff] [blame] | 601 | @decorators.attr(type=['negative']) |
Ken'ichi Ohmichi | 14b0ae1 | 2017-01-27 17:18:52 -0800 | [diff] [blame] | 602 | @decorators.idempotent_id('543d84c1-dd2e-4c6d-8cb2-b9da0efaa384') |
Chris Hoge | 2718b3a | 2016-02-23 16:47:14 -0500 | [diff] [blame] | 603 | def test_update_server_of_another_tenant(self): |
zhufl | b5603bc | 2020-05-27 09:18:24 +0800 | [diff] [blame] | 604 | """Updating server that belongs to another project should fail |
Chris Hoge | 2718b3a | 2016-02-23 16:47:14 -0500 | [diff] [blame] | 605 | |
zhufl | b5603bc | 2020-05-27 09:18:24 +0800 | [diff] [blame] | 606 | Update name of a server that belongs to another project, an error is |
| 607 | returned. |
| 608 | """ |
Chris Hoge | 2718b3a | 2016-02-23 16:47:14 -0500 | [diff] [blame] | 609 | new_name = self.server_id + '_new' |
| 610 | self.assertRaises(lib_exc.NotFound, |
| 611 | self.alt_client.update_server, self.server_id, |
| 612 | name=new_name) |
| 613 | |
Jordan Pittier | 3b46d27 | 2017-04-12 16:17:28 +0200 | [diff] [blame] | 614 | @decorators.attr(type=['negative']) |
Ken'ichi Ohmichi | 14b0ae1 | 2017-01-27 17:18:52 -0800 | [diff] [blame] | 615 | @decorators.idempotent_id('5c75009d-3eea-423e-bea3-61b09fd25f9c') |
Chris Hoge | 2718b3a | 2016-02-23 16:47:14 -0500 | [diff] [blame] | 616 | def test_delete_a_server_of_another_tenant(self): |
zhufl | b5603bc | 2020-05-27 09:18:24 +0800 | [diff] [blame] | 617 | """Deleting a server that belongs to another project should fail""" |
Chris Hoge | 2718b3a | 2016-02-23 16:47:14 -0500 | [diff] [blame] | 618 | self.assertRaises(lib_exc.NotFound, |
| 619 | self.alt_client.delete_server, |
| 620 | self.server_id) |