def test_delete(self): if do_not_delete_instance(): CONFIG.get_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 CONFIG.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. CONFIG.get_report().update() dbaas.instances.delete(instance_info.id) attempts = 0 try: time.sleep(1) result = True while result is not None: attempts += 1 time.sleep(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 resize_should_not_delete_users(self): """Resize should not delete users.""" # Resize has an incredibly weird bug where users are deleted after # a resize. The code below is an attempt to catch this while proceeding # with the rest of the test (note the use of runs_after). if USE_IP: self.connection.connect() if not self.connection.is_connected(): # Ok, this is def. a failure, but before we toss up an error # lets recreate to see how far we can get. CONFIG.get_report().log( "Having to recreate the test_user! Resizing killed it!") self.log_current_users() self.create_user() fail("Somehow, the resize made the test user disappear.")
def resize_should_not_delete_users(self): """Resize should not delete users.""" # Resize has an incredibly weird bug where users are deleted after # a resize. The code below is an attempt to catch this while proceeding # with the rest of the test (note the use of runs_after). if USE_IP: self.connection.connect() if not self.connection.is_connected(): # Ok, this is def. a failure, but before we toss up an error # lets recreate to see how far we can get. CONFIG.get_report().log( "Having to recreate the test_user! Resizing killed it!") self.log_current_users() self.create_user() fail("Somehow, the resize made the test user disappear.")
def test_instance_created(self): # This version just checks the REST API status. def result_is_active(): instance = dbaas.instances.get(instance_info.id) if instance.status == "ACTIVE": return True else: # If its not ACTIVE, anything but BUILD must be # an error. assert_equal("BUILD", instance.status) if instance_info.volume is not None: assert_equal(instance.volume.get('used', None), None) return False poll_until(result_is_active) result = dbaas.instances.get(instance_info.id) report = CONFIG.get_report() report.log("Created an instance, ID = %s." % instance_info.id) report.log("TIP:") report.log("Rerun the tests with TESTS_USE_INSTANCE_ID=%s " "to skip ahead to this point." % instance_info.id) report.log("Add TESTS_DO_NOT_DELETE_INSTANCE=True to avoid deleting " "the instance at the end of the tests.")
def test_create(self): databases = [] databases.append({"name": "firstdb", "character_set": "latin2", "collate": "latin2_general_ci"}) databases.append({"name": "db2"}) instance_info.databases = databases users = [] users.append({"name": "lite", "password": "******", "databases": [{"name": "firstdb"}]}) instance_info.users = users if CONFIG.values['reddwarf_volume_support']: instance_info.volume = {'size': 1} else: instance_info.volume = None if create_new_instance(): instance_info.initial_result = dbaas.instances.create( instance_info.name, instance_info.dbaas_flavor_href, instance_info.volume, databases, users) assert_equal(200, dbaas.last_http_code) else: id = existing_instance() instance_info.initial_result = dbaas.instances.get(id) result = instance_info.initial_result instance_info.id = result.id if CONFIG.white_box: instance_info.local_id = dbapi.localid_from_uuid(result.id) report = CONFIG.get_report() report.log("Instance UUID = %s" % instance_info.id) if create_new_instance(): if CONFIG.white_box: building = dbaas_mapping[power_state.BUILDING] assert_equal(result.status, building) assert_equal("BUILD", instance_info.initial_result.status) else: report.log("Test was invoked with TESTS_USE_INSTANCE_ID=%s, so no " "instance was actually created." % id) # Check these attrs only are returned in create response expected_attrs = ['created', 'flavor', 'addresses', 'id', 'links', 'name', 'status', 'updated'] if CONFIG.values['reddwarf_volume_support']: expected_attrs.append('volume') if CONFIG.reddwarf_dns_support: expected_attrs.append('hostname') with CheckInstance(result._info) as check: if create_new_instance(): check.attrs_exist(result._info, expected_attrs, msg="Create response") # Don't CheckInstance if the instance already exists. check.flavor() check.links(result._info['links']) if CONFIG.values['reddwarf_volume_support']: check.volume()
def log_current_users(self): users = self.dbaas.users.list(self.instance_id) CONFIG.get_report().log("Current user count = %d" % len(users)) for user in users: CONFIG.get_report().log("\t" + str(user))
def log_current_users(self): users = self.dbaas.users.list(self.instance_id) CONFIG.get_report().log("Current user count = %d" % len(users)) for user in users: CONFIG.get_report().log("\t" + str(user))