How to use _test_rebuild_server method in tempest

Best Python code snippet using tempest_python

test_server_actions.py

Source:test_server_actions.py Github

copy

Full Screen

...170 msg = ('Server was not rebuilt to the original image. '171 'The original image: {0}. The current image: {1}'172 .format(image_ref, rebuilt_server['image']['id']))173 self.assertEqual(image_ref, rebuilt_server['image']['id'], msg)174 def _test_rebuild_server(self):175 # Get the IPs the server has before rebuilding it176 original_addresses = (self.client.show_server(self.server_id)['server']177 ['addresses'])178 # The server should be rebuilt using the provided image and data179 meta = {'rebuild': 'server'}180 new_name = data_utils.rand_name(self.__class__.__name__ + '-server')181 password = 'rebuildPassw0rd'182 rebuilt_server = self.client.rebuild_server(183 self.server_id,184 self.image_ref_alt,185 name=new_name,186 metadata=meta,187 adminPass=password)['server']188 # If the server was rebuilt on a different image, restore it to the189 # original image once the test ends190 if self.image_ref_alt != self.image_ref:191 self.addCleanup(self._rebuild_server_and_check, self.image_ref,192 rebuilt_server)193 # Verify the properties in the initial response are correct194 self.assertEqual(self.server_id, rebuilt_server['id'])195 rebuilt_image_id = rebuilt_server['image']['id']196 self.assertTrue(self.image_ref_alt.endswith(rebuilt_image_id))197 self.assert_flavor_equal(self.flavor_ref, rebuilt_server['flavor'])198 # Verify the server properties after the rebuild completes199 waiters.wait_for_server_status(self.client,200 rebuilt_server['id'], 'ACTIVE')201 server = self.client.show_server(rebuilt_server['id'])['server']202 rebuilt_image_id = server['image']['id']203 self.assertTrue(self.image_ref_alt.endswith(rebuilt_image_id))204 self.assertEqual(new_name, server['name'])205 self.assertEqual(original_addresses, server['addresses'])206 if CONF.validation.run_validation:207 # Authentication is attempted in the following order of priority:208 # 1.The key passed in, if one was passed in.209 # 2.Any key we can find through an SSH agent (if allowed).210 # 3.Any "id_rsa", "id_dsa" or "id_ecdsa" key discoverable in211 # ~/.ssh/ (if allowed).212 # 4.Plain username/password auth, if a password was given.213 linux_client = remote_client.RemoteClient(214 self.get_server_ip(rebuilt_server, self.validation_resources),215 self.ssh_alt_user,216 password,217 self.validation_resources['keypair']['private_key'],218 server=rebuilt_server,219 servers_client=self.client)220 linux_client.validate_authentication()221 @decorators.idempotent_id('aaa6cdf3-55a7-461a-add9-1c8596b9a07c')222 def test_rebuild_server(self):223 """Test rebuilding server224 The server should be rebuilt using the provided image and data.225 """226 self._test_rebuild_server()227 @decorators.idempotent_id('30449a88-5aff-4f9b-9866-6ee9b17f906d')228 def test_rebuild_server_in_stop_state(self):229 """Test rebuilding server in stop state230 The server in stop state should be rebuilt using the provided231 image and remain in SHUTOFF state.232 """233 server = self.client.show_server(self.server_id)['server']234 old_image = server['image']['id']235 new_image = (self.image_ref_alt236 if old_image == self.image_ref else self.image_ref)237 self.client.stop_server(self.server_id)238 waiters.wait_for_server_status(self.client, self.server_id, 'SHUTOFF')239 rebuilt_server = (self.client.rebuild_server(self.server_id, new_image)240 ['server'])241 # If the server was rebuilt on a different image, restore it to the242 # original image once the test ends243 if self.image_ref_alt != self.image_ref:244 self.addCleanup(self._rebuild_server_and_check, old_image, server)245 # Verify the properties in the initial response are correct246 self.assertEqual(self.server_id, rebuilt_server['id'])247 rebuilt_image_id = rebuilt_server['image']['id']248 self.assertEqual(new_image, rebuilt_image_id)249 self.assert_flavor_equal(self.flavor_ref, rebuilt_server['flavor'])250 # Verify the server properties after the rebuild completes251 waiters.wait_for_server_status(self.client,252 rebuilt_server['id'], 'SHUTOFF')253 server = self.client.show_server(rebuilt_server['id'])['server']254 rebuilt_image_id = server['image']['id']255 self.assertEqual(new_image, rebuilt_image_id)256 self.client.start_server(self.server_id)257 # NOTE(mriedem): Marked as slow because while rebuild and volume-backed is258 # common, we don't actually change the image (you can't with volume-backed259 # rebuild) so this isn't testing much outside normal rebuild260 # (and it's slow).261 @decorators.attr(type='slow')262 @decorators.idempotent_id('b68bd8d6-855d-4212-b59b-2e704044dace')263 @utils.services('volume')264 def test_rebuild_server_with_volume_attached(self):265 """Test rebuilding server with volume attached266 The volume should be attached to the instance after rebuild.267 """268 # create a new volume and attach it to the server269 volume = self.create_volume()270 server = self.client.show_server(self.server_id)['server']271 self.attach_volume(server, volume)272 # run general rebuild test273 self._test_rebuild_server()274 # make sure the volume is attached to the instance after rebuild275 vol_after_rebuild = self.volumes_client.show_volume(volume['id'])276 vol_after_rebuild = vol_after_rebuild['volume']277 self.assertEqual('in-use', vol_after_rebuild['status'])278 self.assertEqual(self.server_id,279 vol_after_rebuild['attachments'][0]['server_id'])280 if CONF.validation.run_validation:281 linux_client = remote_client.RemoteClient(282 self.get_server_ip(server, self.validation_resources),283 self.ssh_alt_user,284 password=None,285 pkey=self.validation_resources['keypair']['private_key'],286 server=server,287 servers_client=self.client)...

Full Screen

Full Screen

test_servers_client.py

Source:test_servers_client.py Github

copy

Full Screen

...314 server_id=self.server_id,315 type='fake-reboot-type'316 )317 def test_rebuild_server_with_str_body(self):318 self._test_rebuild_server()319 def test_rebuild_server_with_bytes_body(self):320 self._test_rebuild_server(True)321 def _test_rebuild_server(self, bytes_body=False):322 self.check_service_client_function(323 self.client.rebuild_server,324 'tempest.lib.common.rest_client.RestClient.post',325 self.FAKE_REBUILD_SERVER,326 status=202,327 server_id=self.server_id,328 image_ref='fake-image-ref'329 )330 def test_resize_server_with_str_body(self):331 self._test_resize_server()332 def test_resize_server_with_bytes_body(self):333 self._test_resize_server(True)334 def _test_resize_server(self, bytes_body=False):335 self.check_service_client_function(...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run tempest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful