Esempio n. 1
0
 def test_instance_size_too_big(self):
     vol_ok = CONFIG.get('reddwarf_volume_support', False)
     if 'reddwarf_max_accepted_volume_size' in CONFIG.values and vol_ok:
         too_big = CONFIG.reddwarf_max_accepted_volume_size
         assert_raises(exceptions.OverLimit, dbaas.instances.create,
                       "way_too_large", instance_info.dbaas_flavor_href,
                       {'size': too_big + 1}, [])
         assert_equal(413, dbaas.last_http_code)
Esempio n. 2
0
    def test_instance_size_too_big(self):
        vol_ok = CONFIG.get('reddwarf_volume_support', False)
        if 'reddwarf_max_accepted_volume_size' in CONFIG.values and vol_ok:
            too_big = CONFIG.reddwarf_max_accepted_volume_size

            self.test_info.volume = {'size': too_big + 1}
            self.test_info.name = "way_too_large"
            assert_raises(exceptions.OverLimit,
                          dbaas.instances.create,
                          self.test_info.name,
                          self.test_info.dbaas_flavor_href,
                          self.test_info.volume)
Esempio n. 3
0
def call_xmllint(name, body):
    try:
        with open(CONFIG.xml_temp_file, 'w') as file:
            file.write(body)

        #if CONFIG.get('xml_xsd', None):
        args = [CONFIG.xml_temp_file]
        if CONFIG.get('xml_xsd', None):
            args += ["--schema", CONFIG.xml_xsd]
        output = processutils.execute(CONFIG.xmllint_bin, *args,
                                      check_exit_code=0, shell=False)
    except processutils.ProcessExecutionError as pe:
        fail("Error validating XML! %s" % pe)
Esempio n. 4
0
def create_dbaas_client(user):
    """Creates a rich client for the RedDwarf API using the test config."""
    auth_strategy = None

    kwargs = {
        'service_type': 'reddwarf',
        'insecure': test_config.values['reddwarf_client_insecure'],
    }

    def set_optional(kwargs_name, test_conf_name):
        value = test_config.values.get(test_conf_name, None)
        if value is not None:
            kwargs[kwargs_name] = value
    force_url = 'override_reddwarf_api_url' in test_config.values

    service_url = test_config.get('override_reddwarf_api_url', None)
    if user.requirements.is_admin:
        service_url = test_config.get('override_admin_reddwarf_api_url',
                                      service_url)
    if service_url:
        kwargs['service_url'] = service_url

    auth_strategy = None
    if user.requirements.is_admin:
        auth_strategy = test_config.get('admin_auth_strategy',
                                        test_config.auth_strategy)
    else:
        auth_strategy = test_config.auth_strategy
    set_optional('region_name', 'reddwarf_client_region_name')
    if test_config.values.get('override_reddwarf_api_url_append_tenant',
                              False):
        kwargs['service_url'] += "/" + user.tenant

    if auth_strategy == 'fake':
        from reddwarfclient import auth

        class FakeAuth(auth.Authenticator):

            def authenticate(self):
                class FakeCatalog(object):
                    def __init__(self, auth):
                        self.auth = auth

                    def get_public_url(self):
                        return "%s/%s" % (test_config.dbaas_url,
                                          self.auth.tenant)

                    def get_token(self):
                        return self.auth.tenant

                return FakeCatalog(self)

        auth_strategy = FakeAuth

    if auth_strategy:
        kwargs['auth_strategy'] = auth_strategy

    if not user.requirements.is_admin:
        auth_url = test_config.reddwarf_auth_url
    else:
        auth_url = test_config.values.get('reddwarf_admin_auth_url',
                                          test_config.reddwarf_auth_url)

    dbaas = Dbaas(user.auth_user, user.auth_key, tenant=user.tenant,
                  auth_url=auth_url, **kwargs)
    dbaas.authenticate()
    with Check() as check:
        check.is_not_none(dbaas.client.auth_token, "Auth token not set!")
        if not force_url and user.requirements.is_admin:
            expected_prefix = test_config.dbaas_url
            actual = dbaas.client.service_url
            msg = "Dbaas management url was expected to start with %s, but " \
                  "was %s." % (expected_prefix, actual)
            check.true(actual.startswith(expected_prefix), msg)
    return TestClient(dbaas)
Esempio n. 5
0
def create_dbaas_client(user):
    """Creates a rich client for the RedDwarf API using the test config."""
    auth_strategy = None

    kwargs = {
        'service_type': 'database',
        'insecure': test_config.values['reddwarf_client_insecure'],
    }

    def set_optional(kwargs_name, test_conf_name):
        value = test_config.values.get(test_conf_name, None)
        if value is not None:
            kwargs[kwargs_name] = value

    force_url = 'override_reddwarf_api_url' in test_config.values

    service_url = test_config.get('override_reddwarf_api_url', None)
    if user.requirements.is_admin:
        service_url = test_config.get('override_admin_reddwarf_api_url',
                                      service_url)
    if service_url:
        kwargs['service_url'] = service_url

    auth_strategy = None
    if user.requirements.is_admin:
        auth_strategy = test_config.get('admin_auth_strategy',
                                        test_config.auth_strategy)
    else:
        auth_strategy = test_config.auth_strategy
    set_optional('region_name', 'reddwarf_client_region_name')
    if test_config.values.get('override_reddwarf_api_url_append_tenant',
                              False):
        kwargs['service_url'] += "/" + user.tenant

    if auth_strategy == 'fake':
        from reddwarfclient import auth

        class FakeAuth(auth.Authenticator):
            def authenticate(self):
                class FakeCatalog(object):
                    def __init__(self, auth):
                        self.auth = auth

                    def get_public_url(self):
                        return "%s/%s" % (test_config.dbaas_url,
                                          self.auth.tenant)

                    def get_token(self):
                        return self.auth.tenant

                return FakeCatalog(self)

        auth_strategy = FakeAuth

    if auth_strategy:
        kwargs['auth_strategy'] = auth_strategy

    if not user.requirements.is_admin:
        auth_url = test_config.reddwarf_auth_url
    else:
        auth_url = test_config.values.get('reddwarf_admin_auth_url',
                                          test_config.reddwarf_auth_url)

    if test_config.values.get('reddwarf_client_cls'):
        cls_name = test_config.reddwarf_client_cls
        kwargs['client_cls'] = import_class(cls_name)

    dbaas = Dbaas(user.auth_user,
                  user.auth_key,
                  tenant=user.tenant,
                  auth_url=auth_url,
                  **kwargs)
    dbaas.authenticate()
    with Check() as check:
        check.is_not_none(dbaas.client.auth_token, "Auth token not set!")
        if not force_url and user.requirements.is_admin:
            expected_prefix = test_config.dbaas_url
            actual = dbaas.client.service_url
            msg = "Dbaas management url was expected to start with %s, but " \
                  "was %s." % (expected_prefix, actual)
            check.true(actual.startswith(expected_prefix), msg)
    return TestClient(dbaas)