コード例 #1
0
 def _assert_is_replica(self, instance_id, master_id):
     instance = self.get_instance(instance_id)
     self.assert_client_code(200)
     CheckInstance(instance._info).replica_of()
     self.assert_equal(master_id, instance._info['replica_of']['id'],
                       'Unexpected replication master ID')
     self._validate_replica(instance_id)
コード例 #2
0
 def _assert_is_master(self, instance_id, replica_ids):
     instance = self.get_instance(instance_id)
     self.assert_client_code(200)
     CheckInstance(instance._info).slaves()
     self.assert_true(
         set(replica_ids).issubset(self._get_replica_set(instance_id)))
     self._validate_master(instance_id)
コード例 #3
0
    def run_validate_error_instance(self):
        if not self.error_inst_id:
            raise SkipTest("No error instance created.")

        instance = self.get_instance(self.error_inst_id, self.auth_client)
        with CheckInstance(instance._info) as check:
            check.fault()

        err_msg = "disk is too small for requested image"
        self.assert_true(
            err_msg in instance.fault['message'],
            "Message '%s' does not contain '%s'" %
            (instance.fault['message'], err_msg))
コード例 #4
0
    def run_validate_error2_instance(self):
        if not self.error2_inst_id:
            raise SkipTest("No error2 instance created.")

        instance = self.get_instance(self.error2_inst_id,
                                     client=self.admin_client)
        with CheckInstance(instance._info) as check:
            check.fault(is_admin=True)

        err_msg = "Quota exceeded for ram"
        self.assert_true(
            err_msg in instance.fault['message'],
            "Message '%s' does not contain '%s'" %
            (instance.fault['message'], err_msg))
コード例 #5
0
    def assert_instance_create(self,
                               name,
                               flavor,
                               trove_volume_size,
                               database_definitions,
                               user_definitions,
                               configuration_id,
                               root_password,
                               datastore,
                               datastore_version,
                               expected_states,
                               expected_http_code,
                               create_helper_user=False):
        """This assert method executes a 'create' call and verifies the server
        response. It neither waits for the instance to become available
        nor it performs any other validations itself.
        It has been designed this way to increase test granularity
        (other tests may run while the instance is building) and also to allow
        its reuse in other runners .
        """

        databases = database_definitions
        users = [{
            'name': item['name'],
            'password': item['password']
        } for item in user_definitions]

        # Here we add helper user/database if any.
        if create_helper_user:
            helper_db_def, helper_user_def, root_def = self.build_helper_defs()
            if helper_db_def:
                self.report.log(
                    "Appending a helper database '%s' to the instance "
                    "definition." % helper_db_def['name'])
                databases.append(helper_db_def)
            if helper_user_def:
                self.report.log(
                    "Appending a helper user '%s:%s' to the instance "
                    "definition." %
                    (helper_user_def['name'], helper_user_def['password']))
                users.append(helper_user_def)

        instance_info = InstanceTestInfo()
        instance_info.name = name
        instance_info.databases = databases
        instance_info.users = users
        instance_info.dbaas_datastore = CONFIG.dbaas_datastore
        instance_info.dbaas_datastore_version = CONFIG.dbaas_datastore_version
        instance_info.dbaas_flavor_href = self._get_flavor_href(flavor)
        if self.VOLUME_SUPPORT:
            instance_info.volume = {'size': trove_volume_size}
        else:
            instance_info.volume = None

        shared_network = CONFIG.get('shared_network', None)
        if shared_network:
            instance_info.nics = [{'net-id': shared_network}]

        self.report.log(
            "Testing create instance: %s" % {
                'name': name,
                'flavor': flavor.id,
                'volume': trove_volume_size,
                'nics': instance_info.nics,
                'databases': databases,
                'users': users,
                'configuration': configuration_id,
                'root password': root_password,
                'datastore': datastore,
                'datastore version': datastore_version
            })

        instance = self.get_existing_instance()
        if instance:
            self.report.log("Using an existing instance: %s" % instance.id)
            self.assert_equal(expected_states[-1], instance.status,
                              "Given instance is in a bad state.")
        else:
            self.report.log("Creating a new instance.")
            instance = self.auth_client.instances.create(
                instance_info.name,
                instance_info.dbaas_flavor_href,
                instance_info.volume,
                instance_info.databases,
                instance_info.users,
                nics=instance_info.nics,
                configuration=configuration_id,
                availability_zone="nova",
                datastore=instance_info.dbaas_datastore,
                datastore_version=instance_info.dbaas_datastore_version)
            self.assert_instance_action(instance.id, expected_states[0:1],
                                        expected_http_code)

        instance_info.id = instance.id

        with CheckInstance(instance._info) as check:
            check.flavor()
            check.datastore()
            check.links(instance._info['links'])
            if self.VOLUME_SUPPORT:
                check.volume()
                self.assert_equal(trove_volume_size,
                                  instance._info['volume']['size'],
                                  "Unexpected Trove volume size")

            self.assert_equal(instance_info.name, instance._info['name'],
                              "Unexpected instance name")
            self.assert_equal(flavor.id, int(instance._info['flavor']['id']),
                              "Unexpected instance flavor")
            self.assert_equal(instance_info.dbaas_datastore,
                              instance._info['datastore']['type'],
                              "Unexpected instance datastore version")
            self.assert_equal(instance_info.dbaas_datastore_version,
                              instance._info['datastore']['version'],
                              "Unexpected instance datastore version")
            self.assert_configuration_group(instance_info.id, configuration_id)

        return instance_info