def test_delete(self): if do_not_delete_instance(): report.log("TESTS_DO_NOT_DELETE_INSTANCE=True was specified, " "skipping delete...") raise SkipTest("TESTS_DO_NOT_DELETE_INSTANCE was specified.") global dbaas if not hasattr(instance_info, "initial_result"): raise SkipTest("Instance was never created, skipping test...") if WHITE_BOX: # Change this code to get the volume using the API. # That way we can keep it while keeping it black box. admin_context = context.get_admin_context() volumes = db.volume_get_all_by_instance(admin_context(), instance_info.local_id) instance_info.volume_id = volumes[0].id # Update the report so the logs inside the instance will be saved. report.update() dbaas.instances.delete(instance_info.id) attempts = 0 try: time.sleep(1) result = True while result is not None: attempts += 1 result = dbaas.instances.get(instance_info.id) assert_equal(200, dbaas.last_http_code) assert_equal("SHUTDOWN", result.status) except exceptions.NotFound: pass except Exception as ex: fail("A failure occured when trying to GET instance %s for the %d " "time: %s" % (str(instance_info.id), attempts, str(ex)))
def _delete_instance(self): """Deletes an instance. This call polls the REST API until NotFound is raised. The entire time it also makes sure that the API returns SHUTDOWN. """ # Update the report so the logs inside the instance will be saved. report.update() self.dbaas.instances.delete(self.id) attempts = 0 try: time.sleep(1) result = True while result is not None: time.sleep(2) attempts += 1 result = None result = self.dbaas.instances.get(self.id) assert_equal(dbaas_mapping[power_state.SHUTDOWN], result.status) except exception.NotFound: pass except NotFound404: pass except Exception as ex: fail("A failure occured when trying to GET instance %s" " for the %d time: %s" % (str(self.id), attempts, str(ex))) self._check_vifs_cleaned()
def _clean_up(): """Shuts down any services this program has started and shows results.""" from tests.util import report report.update() if MAIN_RUNNER is not None: MAIN_RUNNER.on_exit() from tests.util.services import get_running_services for service in get_running_services(): sys.stderr.write("Stopping service ") for c in service.cmd: sys.stderr.write(c + " ") sys.stderr.write("...\n\r") service.stop()
def test_delete(self): global dbaas if not hasattr(instance_info, "initial_result"): raise SkipTest("Instance was never created, skipping test...") volumes = db.volume_get_all_by_instance(context.get_admin_context(), instance_info.local_id) instance_info.volume_id = volumes[0].id # Update the report so the logs inside the instance will be saved. report.update() dbaas.instances.delete(instance_info.id) attempts = 0 try: time.sleep(1) result = True while result is not None: attempts += 1 result = dbaas.instances.get(instance_info.id) assert_equal(dbaas_mapping[power_state.SHUTDOWN], result.status) except nova_exceptions.NotFound: pass except Exception as ex: fail("A failure occured when trying to GET instance %s for the %d " "time: %s" % (str(instance_info.id), attempts, str(ex)))