コード例 #1
0
ファイル: configurations.py プロジェクト: nnt1997/trove
 def expected_default_datastore_configs():
     """Returns the expected test configurations for the default datastore
     defined in the Test Config as dbaas_datastore.
     """
     default_datastore = CONFIG.get('dbaas_datastore', None)
     datastore_test_configs = CONFIG.get(default_datastore, {})
     return datastore_test_configs.get("configurations", {})
コード例 #2
0
ファイル: run_tests.py プロジェクト: edwardt/trove
def main(import_func):
    try:
        wsgi_install()
        add_support_for_localization()
        # Load Trove app
        # Paste file needs absolute path
        config_file = os.path.realpath('etc/trove/trove.conf.test')
        # 'etc/trove/test-api-paste.ini'
        app = initialize_trove(config_file)
        # Initialize sqlite database.
        initialize_database()
        # Swap out WSGI, httplib, and other components with test doubles.
        initialize_fakes(app)

        # Initialize the test configuration.
        test_config_file, repl = parse_args_for_test_config()
        CONFIG.load_from_file(test_config_file)

        import_func()

        from trove.tests.util import event_simulator
        event_simulator.run_main(functools.partial(run_tests, repl))

    except Exception as e:
        # Printing the error manually like this is necessary due to oddities
        # with sys.excepthook.
        print("Run tests failed: %s" % e)
        traceback.print_exc()
        raise
コード例 #3
0
ファイル: instances.py プロジェクト: VinodKrGupta/trove
    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...")
        # Update the report so the logs inside the instance will be saved.
        CONFIG.get_report().update()
        dbaas.instances.delete(instance_info.id)
        instance_info.deleted_at = timeutils.utcnow().isoformat()

        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)))
コード例 #4
0
ファイル: test_runners.py プロジェクト: windofthesky/trove
    def __init__(self, sleep_time=10, timeout=1200):
        self.def_sleep_time = sleep_time
        self.def_timeout = timeout

        self.instance_info.name = "TEST_" + datetime.datetime.strftime(
            datetime.datetime.now(), '%Y_%m_%d__%H_%M_%S')
        self.instance_info.dbaas_datastore = CONFIG.dbaas_datastore
        self.instance_info.dbaas_datastore_version = (
            CONFIG.dbaas_datastore_version)
        self.instance_info.user = CONFIG.users.find_user_by_name('alt_demo')
        if self.VOLUME_SUPPORT:
            self.instance_info.volume_size = CONFIG.get('trove_volume_size', 1)
            self.instance_info.volume = {
                'size': self.instance_info.volume_size}
        else:
            self.instance_info.volume_size = None
            self.instance_info.volume = None
        self.instance_info.nics = None
        shared_network = CONFIG.get('shared_network', None)
        if shared_network:
            self.instance_info.nics = [{'net-id': shared_network}]

        self._auth_client = None
        self._unauth_client = None
        self._admin_client = None
        self._swift_client = None
        self._nova_client = None
        self._test_helper = None
        self._servers = {}
コード例 #5
0
ファイル: snippets.py プロジェクト: pombredanne/RDS
def create_client_args(user):

    auth_strategy = None

    kwargs = {"service_type": "trove", "insecure": CONFIG.values["trove_client_insecure"]}

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

    service_url = CONFIG.get("override_trove_api_url", None)
    if user.requirements.is_admin:
        service_url = CONFIG.get("override_admin_trove_api_url", service_url)
    if service_url:
        kwargs["service_url"] = service_url

    auth_strategy = None
    if user.requirements.is_admin:
        auth_strategy = CONFIG.get("admin_auth_strategy", CONFIG.auth_strategy)
    else:
        auth_strategy = CONFIG.auth_strategy
    set_optional("region_name", "trove_client_region_name")
    if CONFIG.values.get("override_trove_api_url_append_tenant", False):
        kwargs["service_url"] += "/" + user.tenant

    if auth_strategy == "fake":
        from troveclient.compat 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" % (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 = CONFIG.trove_auth_url
    else:
        auth_url = CONFIG.values.get("trove_admin_auth_url", CONFIG.trove_auth_url)

    if CONFIG.values.get("trove_client_cls"):
        cls_name = CONFIG.trove_client_cls
        kwargs["client_cls"] = import_class(cls_name)

    kwargs["tenant"] = user.tenant
    kwargs["auth_url"] = auth_url
    return (user.auth_user, user.auth_key), kwargs
コード例 #6
0
ファイル: instances.py プロジェクト: hejianle/trove
    def set_up(self):
        """Create client for mgmt instance test (2)."""
        if not CONFIG.fake_mode:
            raise SkipTest("This test only works in fake mode.")
        self.client = create_client(is_admin=True)
        self.mgmt = self.client.management
        # Fake nova will fail a server ending with 'test_SERVER_ERROR'."
        # Fake volume will fail if the size is 13.
        # TODO(tim.simpson): This would be a lot nicer looking if we used a
        #                    traditional mock framework.
        datastore = {'type': 'mysql', 'version': '5.5'}
        body = {'datastore': datastore}
        vol_support = CONFIG.get(datastore['type'], 'mysql')['volume_support']
        if vol_support:
            body.update({'size': 13})

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

        response = self.client.instances.create(
            'test_SERVER_ERROR',
            instance_info.dbaas_flavor_href,
            body,
            [], [],
            nics=nics
        )

        poll_until(lambda: self.client.instances.get(response.id),
                   lambda instance: instance.status == 'ERROR',
                   time_out=10)
        self.id = response.id
コード例 #7
0
    def test_delete(self):
        """Delete instance for clean up."""
        if not hasattr(instance_info, "initial_result"):
            raise SkipTest("Instance was never created, skipping test...")
        # Update the report so the logs inside the instance will be saved.
        CONFIG.get_report().update()

        dbaas = instance_info.dbaas
        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)
                asserts.assert_equal(200, dbaas.last_http_code)
                asserts.assert_equal("SHUTDOWN", result.status)
                time.sleep(1)
        except exceptions.NotFound:
            pass
        except Exception as ex:
            asserts.fail("A failure occurred when trying to GET instance %s "
                         "for the %d time: %s" %
                         (str(instance_info.id), attempts, str(ex)))
コード例 #8
0
ファイル: instances.py プロジェクト: jeredding/trove
    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...")
        # Update the report so the logs inside the instance will be saved.
        CONFIG.get_report().update()
        dbaas.instances.delete(instance_info.id)
        instance_info.deleted_at = timeutils.utcnow().isoformat()

        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)))
コード例 #9
0
ファイル: configurations.py プロジェクト: tangguochang/trove
 def expected_default_datastore_configs():
     """Returns the expected test configurations for the default datastore
     defined in the Test Config as dbaas_datastore.
     """
     default_datatstore = CONFIG.get('dbaas_datastore', None)
     datastore_test_configs = CONFIG.get(default_datatstore, {})
     return datastore_test_configs.get("configurations", {})
コード例 #10
0
ファイル: client.py プロジェクト: ReVolly/trove
 def __cb(*args, **kwargs):
     # While %s turns a var into a string but in some rare cases explicit
     # str() is less likely to raise an exception.
     arg_strs = [repr(arg) for arg in args]
     arg_strs += ["%s=%s" % (repr(key), repr(value)) for (key, value) in kwargs.items()]
     CONFIG.get_reporter().log("[RDC] Calling : %s(%s)..." % (name, ",".join(arg_strs)))
     value = func(*args, **kwargs)
     CONFIG.get_reporter.log("[RDC]     returned %s." % str(value))
     return value
コード例 #11
0
ファイル: client.py プロジェクト: qingyufei/trove
 def __cb(*args, **kwargs):
     # While %s turns a var into a string but in some rare cases explicit
     # str() is less likely to raise an exception.
     arg_strs = [repr(arg) for arg in args]
     arg_strs += ['%s=%s' % (repr(key), repr(value))
                  for (key, value) in kwargs.items()]
     CONFIG.get_reporter().log("[RDC] Calling : %s(%s)..."
                               % (name, ','.join(arg_strs)))
     value = func(*args, **kwargs)
     CONFIG.get_reporter.log("[RDC]     returned %s." % str(value))
     return value
コード例 #12
0
ファイル: instances_actions.py プロジェクト: ReVolly/trove
 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.")
コード例 #13
0
 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.")
コード例 #14
0
    def run_initialized_instance_create(
            self, with_dbs=True, with_users=True, configuration_id=None,
            expected_states=['BUILD', 'ACTIVE'], expected_http_code=200,
            create_helper_user=True):
        # TODO(pmalik): Instance create should return 202 Accepted (cast)
        # rather than 200 OK (call).
        name = self.instance_info.name
        flavor = self._get_instance_flavor()
        trove_volume_size = CONFIG.get('trove_volume_size', 1)
        self.init_inst_dbs = (self.test_helper.get_valid_database_definitions()
                              if with_dbs else [])
        self.init_inst_users = (self.test_helper.get_valid_user_definitions()
                                if with_users else [])
        if configuration_id:
            self.init_config_group_id = configuration_id

        if (self.init_inst_dbs or self.init_inst_users or
                self.init_config_group_id):
            info = self.assert_instance_create(
                name, flavor, trove_volume_size,
                self.init_inst_dbs, self.init_inst_users,
                self.init_config_group_id, None,
                CONFIG.dbaas_datastore, CONFIG.dbaas_datastore_version,
                expected_states, expected_http_code,
                create_helper_user=create_helper_user)

            self.init_inst_id = info.id
        else:
            # There is no need to run this test as it's effectively the same as
            # the empty instance test.
            raise SkipTest("No testable initial properties provided.")
コード例 #15
0
    def run_initialized_instance_create(
            self, with_dbs=True, with_users=True, configuration_id=None,
            expected_states=['BUILD', 'ACTIVE'], expected_http_code=200):
        # TODO(pmalik): Instance create should return 202 Accepted (cast)
        # rather than 200 OK (call).
        name = self.instance_info.name
        flavor = self._get_instance_flavor()
        trove_volume_size = CONFIG.get('trove_volume_size', 1)
        self.init_inst_dbs = (self.test_helper.get_valid_database_definitions()
                              if with_dbs else [])
        self.init_inst_users = (self.test_helper.get_valid_user_definitions()
                                if with_users else [])
        if configuration_id:
            self.init_config_group_id = configuration_id

        if (self.init_inst_dbs or self.init_inst_users or
                self.init_config_group_id):
            info = self.assert_instance_create(
                name, flavor, trove_volume_size,
                self.init_inst_dbs, self.init_inst_users,
                self.init_config_group_id, None,
                CONFIG.dbaas_datastore, CONFIG.dbaas_datastore_version,
                expected_states, expected_http_code)

            self.init_inst_id = info.id
        else:
            # There is no need to run this test as it's effectively the same as
            # the empty instance test.
            raise SkipTest("No testable initial properties provided.")
コード例 #16
0
 def test_create_failure_with_datastore_default_not_defined(self):
     if not FAKE:
         raise SkipTest("This test only for fake mode.")
     if VOLUME_SUPPORT:
         volume = {'size': CONFIG.get('trove_volume_size', 1)}
     else:
         volume = None
     instance_name = "datastore_default_notfound"
     databases = []
     users = []
     origin_default_datastore = (datastore_models.CONF.
                                 default_datastore)
     datastore_models.CONF.default_datastore = ""
     try:
         assert_raises(exceptions.NotFound,
                       dbaas.instances.create, instance_name,
                       instance_info.dbaas_flavor_href,
                       volume, databases, users,
                       nics=instance_info.nics)
     except exceptions.BadRequest as e:
         assert_equal(e.message,
                      "Please specify datastore. No default datastore "
                      "is defined.")
     datastore_models.CONF.default_datastore = \
         origin_default_datastore
コード例 #17
0
    def test_create_too_many_instances(self):
        instance_quota = 0
        quota_dict = {'instances': instance_quota}
        new_quotas = dbaas_admin.quota.update(instance_info.user.tenant_id,
                                              quota_dict)

        set_quota = dbaas_admin.quota.show(instance_info.user.tenant_id)
        verify_quota = {q.resource: q.limit for q in set_quota}

        assert_equal(new_quotas['instances'], quota_dict['instances'])
        assert_equal(0, verify_quota['instances'])

        volume = None
        if VOLUME_SUPPORT:
            assert_equal(CONFIG.trove_max_volumes_per_tenant,
                         verify_quota['volumes'])
            volume = {'size': CONFIG.get('trove_volume_size', 1)}

        assert_raises(exceptions.OverLimit,
                      dbaas.instances.create,
                      "too_many_instances",
                      instance_info.dbaas_flavor_href,
                      volume,
                      nics=instance_info.nics)

        assert_equal(413, dbaas.last_http_code)
コード例 #18
0
    def run_empty_instance_create(self,
                                  expected_states=['BUILD', 'ACTIVE'],
                                  expected_http_code=200):
        name = self.instance_info.name
        flavor = self._get_instance_flavor()
        trove_volume_size = CONFIG.get('trove_volume_size', 1)

        instance_info = self.assert_instance_create(
            name,
            flavor,
            trove_volume_size, [], [],
            None,
            None,
            CONFIG.dbaas_datastore,
            CONFIG.dbaas_datastore_version,
            expected_states,
            expected_http_code,
            create_helper_user=True)

        # Update the shared instance info.
        self.instance_info.id = instance_info.id
        self.instance_info.name = instance_info.name
        self.instance_info.databases = instance_info.databases
        self.instance_info.users = instance_info.users
        self.instance_info.dbaas_datastore = instance_info.dbaas_datastore
        self.instance_info.dbaas_datastore_version = (
            instance_info.dbaas_datastore_version)
        self.instance_info.dbaas_flavor_href = instance_info.dbaas_flavor_href
        self.instance_info.volume = instance_info.volume
コード例 #19
0
    def run_initialized_instance_create(
            self, with_dbs=True, with_users=True, configuration_id=None,
            expected_states=['BUILD', 'ACTIVE'], expected_http_code=200,
            create_helper_user=True):
        name = self.instance_info.name + '_init'
        flavor = self._get_instance_flavor()
        trove_volume_size = CONFIG.get('trove_volume_size', 1)
        self.init_inst_dbs = (self.test_helper.get_valid_database_definitions()
                              if with_dbs else [])
        self.init_inst_users = (self.test_helper.get_valid_user_definitions()
                                if with_users else [])
        if configuration_id:
            self.init_config_group_id = configuration_id

        if self.is_using_existing_instance:
            raise SkipTest("Using existing instance.")

        if (self.init_inst_dbs or self.init_inst_users or
                self.init_config_group_id):
            info = self.assert_instance_create(
                name, flavor, trove_volume_size,
                self.init_inst_dbs, self.init_inst_users,
                self.init_config_group_id, None,
                CONFIG.dbaas_datastore, CONFIG.dbaas_datastore_version,
                expected_states, expected_http_code,
                create_helper_user=create_helper_user)

            self.init_inst_id = info.id
        else:
            # There is no need to run this test as it's effectively the same as
            # the empty instance test.
            raise SkipTest("No testable initial properties provided.")
コード例 #20
0
 def test_create_failure_with_datastore_version_notfound(self):
     if VOLUME_SUPPORT:
         volume = {'size': CONFIG.get('trove_volume_size', 1)}
     else:
         volume = None
     instance_name = "datastore_version_notfound"
     databases = []
     users = []
     datastore = CONFIG.dbaas_datastore
     datastore_version = "nonexistent"
     try:
         assert_raises(exceptions.NotFound,
                       dbaas.instances.create,
                       instance_name,
                       instance_info.dbaas_flavor_href,
                       volume,
                       databases,
                       users,
                       datastore=datastore,
                       datastore_version=datastore_version,
                       nics=instance_info.nics)
     except exceptions.BadRequest as e:
         assert_equal(
             e.message,
             "Datastore version '%s' cannot be found." % datastore_version)
コード例 #21
0
    def __init__(self):
        self.dbaas = None  # The rich client instance used by these tests.
        self.dbaas_admin = None  # The rich client with admin access.
        self.dbaas_flavor = None  # The flavor object of the instance.
        self.dbaas_flavor_href = None  # The flavor of the instance.
        self.dbaas_datastore = None  # The datastore id
        self.dbaas_datastore_version = None  # The datastore version id
        self.id = None  # The ID of the instance in the database.
        self.local_id = None

        # The IP address of the database instance for the user.
        self.address = None
        # The management network IP address.
        self.mgmt_address = None

        self.nics = None  # The dict of type/id for nics used on the instance.
        shared_network = CONFIG.get('shared_network', None)
        if shared_network:
            self.nics = [{'net-id': shared_network}]
        self.initial_result = None  # The initial result from the create call.
        self.result = None  # The instance info returned by the API
        self.nova_client = None  # The instance of novaclient.
        self.volume_client = None  # The instance of the volume client.
        self.name = None  # Test name, generated each test run.
        self.pid = None  # The process ID of the instance.
        self.user = None  # The user instance who owns the instance.
        self.admin_user = None  # The admin user for the management interfaces.
        self.volume = None  # The volume the instance will have.
        self.volume_id = None  # Id for the attached vo186lume
        self.storage = None  # The storage device info for the volumes.
        self.databases = None  # The databases created on the instance.
        self.host_info = None  # Host Info before creating instances
        self.user_context = None  # A regular user context
        self.users = None  # The users created on the instance.
        self.consumer = create_usage_verifier()
コード例 #22
0
ファイル: instances.py プロジェクト: VinodKrGupta/trove
    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 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,
                availability_zone="nova")
            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

        report = CONFIG.get_report()
        report.log("Instance UUID = %s" % instance_info.id)
        if create_new_instance():
            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 ROOT_ON_CREATE:
            expected_attrs.append('password')
        if VOLUME_SUPPORT:
            expected_attrs.append('volume')
        if CONFIG.trove_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 VOLUME_SUPPORT:
                check.volume()
コード例 #23
0
ファイル: instances.py プロジェクト: jeredding/trove
    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 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,
                availability_zone="nova")
            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

        report = CONFIG.get_report()
        report.log("Instance UUID = %s" % instance_info.id)
        if create_new_instance():
            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 ROOT_ON_CREATE:
            expected_attrs.append('password')
        if VOLUME_SUPPORT:
            expected_attrs.append('volume')
        if CONFIG.trove_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 VOLUME_SUPPORT:
                check.volume()
コード例 #24
0
ファイル: configurations.py プロジェクト: tangguochang/trove
 def expected_instance_datastore_configs(instance_id):
     """Given an instance retrieve the expected test configurations for
     instance's datastore.
     """
     instance = instance_info.dbaas.instances.get(instance_id)
     datastore_type = instance.datastore['type']
     datastore_test_configs = CONFIG.get(datastore_type, {})
     return datastore_test_configs.get("configurations", {})
コード例 #25
0
ファイル: test_runners.py プロジェクト: jjmob/trove
 def __init__(self, sleep_time=10, timeout=1200):
     self.def_sleep_time = sleep_time
     self.def_timeout = timeout
     self.instance_info = instance_info
     self.auth_client = create_dbaas_client(self.instance_info.user)
     self.unauth_client = None
     self.report = CONFIG.get_report()
     self._test_helper = None
コード例 #26
0
ファイル: configurations.py プロジェクト: nnt1997/trove
 def expected_instance_datastore_configs(instance_id):
     """Given an instance retrieve the expected test configurations for
     instance's datastore.
     """
     instance = instance_info.dbaas.instances.get(instance_id)
     datastore_type = instance.datastore['type']
     datastore_test_configs = CONFIG.get(datastore_type, {})
     return datastore_test_configs.get("configurations", {})
コード例 #27
0
 def __init__(self, sleep_time=10, timeout=1200):
     self.def_sleep_time = sleep_time
     self.def_timeout = timeout
     self.instance_info = instance_info
     self.auth_client = create_dbaas_client(self.instance_info.user)
     self.unauth_client = None
     self.report = CONFIG.get_report()
     self._test_helper = None
コード例 #28
0
ファイル: snippets.py プロジェクト: Tesora/tesora-trove
def load_config_file():
    global conf
    if CONFIG.get("examples", None) is None:
        fail("Missing 'examples' config in test config.")
    conf = CONFIG.examples
    global normal_user
    normal_user = CONFIG.users.find_user_by_name(conf['normal_user_name'])
    global admin_user
    admin_user = CONFIG.users.find_user_by_name(conf['admin_user_name'])
コード例 #29
0
ファイル: snippets.py プロジェクト: viettelidc-oss/trove
def load_config_file():
    global conf
    if CONFIG.get("examples", None) is None:
        fail("Missing 'examples' config in test config.")
    conf = CONFIG.examples
    global normal_user
    normal_user = CONFIG.users.find_user_by_name(conf['normal_user_name'])
    global admin_user
    admin_user = CONFIG.users.find_user_by_name(conf['admin_user_name'])
コード例 #30
0
ファイル: test_runners.py プロジェクト: qingyufei/trove
    def __init__(self, sleep_time=10, timeout=1800):
        self.def_sleep_time = sleep_time
        self.def_timeout = timeout

        self.instance_info.name = "TEST_" + datetime.datetime.strftime(
            timeutils.utcnow(), '%Y_%m_%d__%H_%M_%S')
        self.instance_info.dbaas_datastore = CONFIG.dbaas_datastore
        self.instance_info.dbaas_datastore_version = (
            CONFIG.dbaas_datastore_version)
        self.instance_info.user = CONFIG.users.find_user_by_name("alt_demo")
        self.instance_info.admin_user = CONFIG.users.find_user(
            Requirements(is_admin=True))
        if self.VOLUME_SUPPORT:
            self.instance_info.volume_size = CONFIG.get('trove_volume_size', 1)
            self.instance_info.volume = {
                'size': self.instance_info.volume_size
            }
        else:
            self.instance_info.volume_size = None
            self.instance_info.volume = None
        self.instance_info.nics = None
        shared_network = CONFIG.get('shared_network', None)
        if shared_network:
            self.instance_info.nics = [{'net-id': shared_network}]

        self._auth_client = None
        self._unauth_client = None
        self._admin_client = None
        self._swift_client = None
        self._nova_client = None
        self._neutron_client = None
        self._test_helper = None
        self._servers = {}

        # Attempt to register the main instance.  If it doesn't
        # exist, this will still set the 'report' and 'client' objects
        # correctly in LogOnFail
        inst_ids = []
        if hasattr(self.instance_info, 'id') and self.instance_info.id:
            inst_ids = [self.instance_info.id]
        self.register_debug_inst_ids(inst_ids)

        self.instance_info.flavors = self.nova_client.flavors.list()
コード例 #31
0
ファイル: client.py プロジェクト: ReVolly/trove
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]
        processutils.execute(CONFIG.xmllint_bin, *args, check_exit_code=0, shell=False)
    except processutils.ProcessExecutionError as pe:
        fail("Error validating XML! %s" % pe)
コード例 #32
0
 def test_create_failure_with_spaces_for_name(self):
     if VOLUME_SUPPORT:
         volume = {'size': CONFIG.get('trove_volume_size', 1)}
     else:
         volume = None
     instance_name = "      "
     databases = []
     assert_raises(exceptions.BadRequest, dbaas.instances.create,
                   instance_name, instance_info.dbaas_flavor_href,
                   volume, databases,
                   nics=instance_info.nics)
     assert_equal(400, dbaas.last_http_code)
コード例 #33
0
 def test_create_failure_with_empty_flavor(self):
     instance_name = "instance-failure-with-empty-flavor"
     databases = []
     if VOLUME_SUPPORT:
         volume = {'size': CONFIG.get('trove_volume_size', 1)}
     else:
         volume = None
     assert_raises(exceptions.BadRequest, dbaas.instances.create,
                   instance_name, '',
                   volume, databases,
                   nics=instance_info.nics)
     assert_equal(400, dbaas.last_http_code)
コード例 #34
0
 def create_instance(self):
     volume = None
     if VOLUME_SUPPORT:
         volume = {'size': 1}
     nics = None
     shared_network = CONFIG.get('shared_network', None)
     if shared_network:
         nics = [{'net-id': shared_network}]
     initial = self.client.instances.create(self.name, self.flavor_id,
                                            volume, [], [],
                                            nics=nics)
     self.id = initial.id
     self._wait_for_active()
コード例 #35
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]
        processutils.execute(CONFIG.xmllint_bin, *args,
                             check_exit_code=0, shell=False)
    except processutils.ProcessExecutionError as pe:
        fail("Error validating XML! %s" % pe)
コード例 #36
0
 def create_instance(self):
     volume = None
     if VOLUME_SUPPORT:
         volume = {'size': 1}
     nics = None
     shared_network = CONFIG.get('shared_network', None)
     if shared_network:
         nics = [{'net-id': shared_network}]
     initial = self.client.instances.create(self.name,
                                            self.flavor_id,
                                            volume, [], [],
                                            nics=nics)
     self.id = initial.id
     self._wait_for_active()
コード例 #37
0
ファイル: test_runners.py プロジェクト: Tesora/tesora-trove
    def __init__(self, sleep_time=10, timeout=1200):
        self.def_sleep_time = sleep_time
        self.def_timeout = timeout

        self.instance_info.name = "TEST_" + datetime.datetime.strftime(
            datetime.datetime.now(), '%Y_%m_%d__%H_%M_%S')
        self.instance_info.dbaas_datastore = CONFIG.dbaas_datastore
        self.instance_info.dbaas_datastore_version = (
            CONFIG.dbaas_datastore_version)
        self.instance_info.user = CONFIG.users.find_user_by_name('alt_demo')
        if self.VOLUME_SUPPORT:
            self.instance_info.volume_size = CONFIG.get('trove_volume_size', 1)
            self.instance_info.volume = {
                'size': self.instance_info.volume_size}
        else:
            self.instance_info.volume_size = None
            self.instance_info.volume = None
        self.instance_info.nics = None
        shared_network = CONFIG.get('shared_network', None)
        if shared_network:
            self.instance_info.nics = [{'net-id': shared_network}]

        self._auth_client = None
        self._unauth_client = None
        self._admin_client = None
        self._swift_client = None
        self._nova_client = None
        self._test_helper = None
        self._servers = {}

        # Attempt to register the main instance.  If it doesn't
        # exist, this will still set the 'report' and 'client' objects
        # correctly in LogOnFail
        inst_ids = []
        if hasattr(self.instance_info, 'id') and self.instance_info.id:
            inst_ids = [self.instance_info.id]
        self.register_debug_inst_ids(inst_ids)
コード例 #38
0
ファイル: flavors.py プロジェクト: Tesora/tesora-trove
    def setUp(self):
        rd_user = test_config.users.find_user(
            Requirements(is_admin=False, services=["trove"]))
        self.rd_client = create_dbaas_client(rd_user)

        self.datastore = self.rd_client.datastores.get(
            test_config.dbaas_datastore)
        self.name1 = "test_instance1"
        self.name2 = "test_instance2"
        self.volume = {'size': 2}
        self.instance_id = None
        self.nics = None
        shared_network = CONFIG.get('shared_network', None)
        if shared_network:
            self.nics = [{'net-id': shared_network}]
コード例 #39
0
ファイル: flavors.py プロジェクト: zh-f/trove
    def setUp(self):
        rd_user = test_config.users.find_user(
            Requirements(is_admin=False, services=["trove"]))
        self.rd_client = create_dbaas_client(rd_user)

        self.datastore = self.rd_client.datastores.get(
            test_config.dbaas_datastore)
        self.name1 = "test_instance1"
        self.name2 = "test_instance2"
        self.volume = {'size': 2}
        self.instance_id = None
        self.nics = None
        shared_network = CONFIG.get('shared_network', None)
        if shared_network:
            self.nics = [{'net-id': shared_network}]
コード例 #40
0
ファイル: test_runners.py プロジェクト: pombredanne/trove
    def __init__(self, sleep_time=10, timeout=1200):
        self.def_sleep_time = sleep_time
        self.def_timeout = timeout

        self.instance_info = instance_info
        instance_info.dbaas_datastore = CONFIG.dbaas_datastore
        instance_info.dbaas_datastore_version = CONFIG.dbaas_datastore_version
        if self.VOLUME_SUPPORT:
            instance_info.volume = {'size': CONFIG.get('trove_volume_size', 1)}
        else:
            instance_info.volume = None

        self.auth_client = create_dbaas_client(self.instance_info.user)
        self.unauth_client = None
        self._test_helper = None
コード例 #41
0
    def test_create_with_multiple_net_id(self):
        instance_name = "instance_failure_with_multiple_net_id"
        volume = {'size': CONFIG.get('trove_volume_size', 1)}
        databases = []
        multi_nics = [
            {"net-id": str(uuid.uuid4())},
            {"net-id": str(uuid.uuid4())}
        ]

        assert_raises(
            exceptions.BadRequest,
            dbaas.instances.create,
            instance_name, instance_info.dbaas_flavor_href,
            volume, databases, nics=multi_nics
        )
        assert_equal(400, dbaas.last_http_code)
コード例 #42
0
    def test_create_with_port_id(self):
        instance_name = "instance-failure-with-port-id"
        if VOLUME_SUPPORT:
            volume = {'size': CONFIG.get('trove_volume_size', 1)}
        else:
            volume = None
        databases = []
        bad_nic = [{"port-id": "1234"}]

        assert_raises(
            exceptions.BadRequest,
            dbaas.instances.create,
            instance_name, instance_info.dbaas_flavor_href,
            volume, databases, nics=bad_nic
        )
        assert_equal(400, dbaas.last_http_code)
コード例 #43
0
ファイル: configurations.py プロジェクト: nnt1997/trove
 def test_assign_name_to_instance_using_patch(self):
     # test assigning a name to an instance
     new_name = 'new_name_1'
     report = CONFIG.get_report()
     report.log("instance_info.id: %s" % instance_info.id)
     report.log("instance name:%s" % instance_info.name)
     report.log("instance new name:%s" % new_name)
     instance_info.dbaas.instances.edit(instance_info.id, name=new_name)
     assert_equal(202, instance_info.dbaas.last_http_code)
     check = instance_info.dbaas.instances.get(instance_info.id)
     assert_equal(200, instance_info.dbaas.last_http_code)
     assert_equal(check.name, new_name)
     # Restore instance name
     instance_info.dbaas.instances.edit(instance_info.id,
                                        name=instance_info.name)
     assert_equal(202, instance_info.dbaas.last_http_code)
コード例 #44
0
ファイル: configurations.py プロジェクト: tangguochang/trove
 def test_assign_name_to_instance_using_patch(self):
     # test assigning a name to an instance
     new_name = 'new_name_1'
     report = CONFIG.get_report()
     report.log("instance_info.id: %s" % instance_info.id)
     report.log("instance name:%s" % instance_info.name)
     report.log("instance new name:%s" % new_name)
     instance_info.dbaas.instances.edit(instance_info.id, name=new_name)
     assert_equal(202, instance_info.dbaas.last_http_code)
     check = instance_info.dbaas.instances.get(instance_info.id)
     assert_equal(200, instance_info.dbaas.last_http_code)
     assert_equal(check.name, new_name)
     # Restore instance name
     instance_info.dbaas.instances.edit(instance_info.id,
                                        name=instance_info.name)
     assert_equal(202, instance_info.dbaas.last_http_code)
コード例 #45
0
 def run(self):
     # Print out everything to make it
     print("Looking for config value %s..." % self.service_path_root)
     print(CONFIG.values[self.service_path_root])
     path = self.service_path % CONFIG.values[self.service_path_root]
     print("Path = %s" % path)
     if not os.path.exists(path):
         path = self.alternate_path
     if path is None:
         fail("Could not find path to %s" % self.service_path_root)
     conf_path = str(CONFIG.values[self.conf_file_name])
     cmds = CONFIG.python_cmd_list() + [path] + self.extra_cmds + \
            [conf_path]
     print("Running cmds: %s" % cmds)
     self.service = Service(cmds)
     if not self.service.is_service_alive():
         self.service.start()
コード例 #46
0
 def run(self):
     # Print out everything to make it
     print("Looking for config value %s..." % self.service_path_root)
     print(CONFIG.values[self.service_path_root])
     path = self.service_path % CONFIG.values[self.service_path_root]
     print("Path = %s" % path)
     if not os.path.exists(path):
         path = self.alternate_path
     if path is None:
         fail("Could not find path to %s" % self.service_path_root)
     conf_path = str(CONFIG.values[self.conf_file_name])
     cmds = CONFIG.python_cmd_list() + [path] + self.extra_cmds + \
            [conf_path]
     print("Running cmds: %s" % cmds)
     self.service = Service(cmds)
     if not self.service.is_service_alive():
         self.service.start()
コード例 #47
0
ファイル: configurations.py プロジェクト: nnt1997/trove
    def test_assign_config_and_name_to_instance_using_patch(self):
        # test assigning a configuration and name to an instance
        new_name = 'new_name'
        report = CONFIG.get_report()
        report.log("instance_info.id: %s" % instance_info.id)
        report.log("configuration_info: %s" % configuration_info)
        report.log("configuration_info.id: %s" % configuration_info.id)
        report.log("instance name:%s" % instance_info.name)
        report.log("instance new name:%s" % new_name)
        saved_name = instance_info.name
        config_id = configuration_info.id
        instance_info.dbaas.instances.edit(instance_info.id,
                                           configuration=config_id,
                                           name=new_name)
        assert_equal(202, instance_info.dbaas.last_http_code)
        check = instance_info.dbaas.instances.get(instance_info.id)
        assert_equal(200, instance_info.dbaas.last_http_code)
        assert_equal(check.name, new_name)

        # restore instance name
        instance_info.dbaas.instances.edit(instance_info.id, name=saved_name)
        assert_equal(202, instance_info.dbaas.last_http_code)

        instance = instance_info.dbaas.instances.get(instance_info.id)
        assert_equal('RESTART_REQUIRED', instance.status)
        # restart to be sure configuration is applied
        instance_info.dbaas.instances.restart(instance_info.id)
        assert_equal(202, instance_info.dbaas.last_http_code)
        sleep(2)

        def result_is_active():
            instance = instance_info.dbaas.instances.get(instance_info.id)
            if instance.status == "ACTIVE":
                return True
            else:
                assert_equal("REBOOT", instance.status)
                return False

        poll_until(result_is_active)
        # test assigning a configuration to an instance that
        # already has an assigned configuration with patch
        config_id = configuration_info.id
        assert_raises(exceptions.BadRequest,
                      instance_info.dbaas.instances.edit,
                      instance_info.id,
                      configuration=config_id)
コード例 #48
0
    def __init__(self, sleep_time=10, timeout=1200):
        self.def_sleep_time = sleep_time
        self.def_timeout = timeout

        self.instance_info = instance_info
        instance_info.dbaas_datastore = CONFIG.dbaas_datastore
        instance_info.dbaas_datastore_version = CONFIG.dbaas_datastore_version
        if self.VOLUME_SUPPORT:
            instance_info.volume = {'size': CONFIG.get('trove_volume_size', 1)}
        else:
            instance_info.volume = None

        self.auth_client = create_dbaas_client(self.instance_info.user)
        self.unauth_client = None
        self._nova_client = None
        self._test_helper = None
        self._servers = {}
コード例 #49
0
ファイル: configurations.py プロジェクト: tangguochang/trove
    def test_assign_config_and_name_to_instance_using_patch(self):
        # test assigning a configuration and name to an instance
        new_name = 'new_name'
        report = CONFIG.get_report()
        report.log("instance_info.id: %s" % instance_info.id)
        report.log("configuration_info: %s" % configuration_info)
        report.log("configuration_info.id: %s" % configuration_info.id)
        report.log("instance name:%s" % instance_info.name)
        report.log("instance new name:%s" % new_name)
        saved_name = instance_info.name
        config_id = configuration_info.id
        instance_info.dbaas.instances.edit(instance_info.id,
                                           configuration=config_id,
                                           name=new_name)
        assert_equal(202, instance_info.dbaas.last_http_code)
        check = instance_info.dbaas.instances.get(instance_info.id)
        assert_equal(200, instance_info.dbaas.last_http_code)
        assert_equal(check.name, new_name)

        # restore instance name
        instance_info.dbaas.instances.edit(instance_info.id,
                                           name=saved_name)
        assert_equal(202, instance_info.dbaas.last_http_code)

        instance = instance_info.dbaas.instances.get(instance_info.id)
        assert_equal('RESTART_REQUIRED', instance.status)
        # restart to be sure configuration is applied
        instance_info.dbaas.instances.restart(instance_info.id)
        assert_equal(202, instance_info.dbaas.last_http_code)
        sleep(2)

        def result_is_active():
            instance = instance_info.dbaas.instances.get(
                instance_info.id)
            if instance.status == "ACTIVE":
                return True
            else:
                assert_equal("REBOOT", instance.status)
                return False
        poll_until(result_is_active)
        # test assigning a configuration to an instance that
        # already has an assigned configuration with patch
        config_id = configuration_info.id
        assert_raises(exceptions.BadRequest,
                      instance_info.dbaas.instances.edit,
                      instance_info.id, configuration=config_id)
コード例 #50
0
    def run_empty_instance_create(
            self, expected_states=['BUILD', 'ACTIVE'], expected_http_code=200):
        name = self.instance_info.name
        flavor = self._get_instance_flavor()
        trove_volume_size = CONFIG.get('trove_volume_size', 1)

        info = self.assert_instance_create(
            name, flavor, trove_volume_size, [], [], None, None,
            CONFIG.dbaas_datastore, CONFIG.dbaas_datastore_version,
            expected_states, expected_http_code, create_helper_user=True)

        # Update the shared instance info.
        self.instance_info.databases = info.databases
        self.instance_info.users = info.users
        self.instance_info.dbaas_datastore = info.dbaas_datastore
        self.instance_info.dbaas_datastore_version = (info.
                                                      dbaas_datastore_version)
        self.instance_info.dbaas_flavor_href = info.dbaas_flavor_href
        self.instance_info.volume = info.volume
        self.instance_info.id = info.id
コード例 #51
0
ファイル: test_runners.py プロジェクト: ISCAS-VDI/trove-base
    def __init__(self, sleep_time=10, timeout=1200):
        self.def_sleep_time = sleep_time
        self.def_timeout = timeout

        self.instance_info.name = "TEST_" + datetime.datetime.strftime(
            datetime.datetime.now(), '%Y-%m-%d_%H:%M:%S')
        self.instance_info.dbaas_datastore = CONFIG.dbaas_datastore
        self.instance_info.dbaas_datastore_version = (
            CONFIG.dbaas_datastore_version)
        self.instance_info.user = CONFIG.users.find_user_by_name('alt_demo')
        if self.VOLUME_SUPPORT:
            self.instance_info.volume = {
                'size': CONFIG.get('trove_volume_size', 1)}
        else:
            self.instance_info.volume = None

        self._auth_client = None
        self._unauth_client = None
        self._admin_client = None
        self._swift_client = None
        self._test_helper = None
コード例 #52
0
    def run_empty_instance_create(
            self, expected_states=['BUILD', 'ACTIVE'], expected_http_code=200):
        # TODO(pmalik): Instance create should return 202 Accepted (cast)
        # rather than 200 OK (call).
        name = self.instance_info.name
        flavor = self._get_instance_flavor()
        trove_volume_size = CONFIG.get('trove_volume_size', 1)

        info = self.assert_instance_create(
            name, flavor, trove_volume_size, [], [], None, None,
            CONFIG.dbaas_datastore, CONFIG.dbaas_datastore_version,
            expected_states, expected_http_code)

        # Update the shared instance info.
        self.instance_info.databases = info.databases
        self.instance_info.users = info.users
        self.instance_info.dbaas_datastore = info.dbaas_datastore
        self.instance_info.dbaas_datastore_version = (info.
                                                      dbaas_datastore_version)
        self.instance_info.dbaas_flavor_href = info.dbaas_flavor_href
        self.instance_info.volume = info.volume
        self.instance_info.id = info.id
コード例 #53
0
ファイル: instances.py プロジェクト: Hopebaytech/trove
 def set_up(self):
     """Create client for mgmt instance test (2)."""
     if not CONFIG.fake_mode:
         raise SkipTest("This test only works in fake mode.")
     self.client = create_client(is_admin=True)
     self.mgmt = self.client.management
     # Fake nova will fail a server ending with 'test_SERVER_ERROR'."
     # Fake volume will fail if the size is 13.
     # TODO(tim.simpson): This would be a lot nicer looking if we used a
     #                    traditional mock framework.
     datastore = {'type': 'mysql', 'version': '5.5'}
     body = {'datastore': datastore}
     vol_support = CONFIG.get(datastore['type'], 'mysql')['volume_support']
     if vol_support:
         body.update({'size': 13})
     response = self.client.instances.create(
         'test_SERVER_ERROR',
         instance_info.dbaas_flavor_href,
         body,
         [])
     poll_until(lambda: self.client.instances.get(response.id),
                lambda instance: instance.status == 'ERROR',
                time_out=10)
     self.id = response.id
コード例 #54
0
ファイル: instances.py プロジェクト: jeredding/trove
    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)
        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.")
コード例 #55
0
ファイル: pxc.py プロジェクト: magictour/trove
 def setUp(self):
     self.instance = instance_info
     self.rd_client = create_dbaas_client(self.instance.user)
     self.report = CONFIG.get_report()
コード例 #56
0
ファイル: instances_actions.py プロジェクト: ReVolly/trove
 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))
コード例 #57
0
ファイル: snippets.py プロジェクト: Tesora/tesora-trove
class ZzzDeleteInstance(Example):

    @before_class
    def setup(self):
        self.client = make_client(normal_user)

    @test
    def zzz_delete_instance(self):
        global json_instance
        self.snippet(
            "delete_instance",
            "/instances/%s" % json_instance.id,
            "DELETE", 202, "Accepted",
            lambda client: client.instances.delete(json_instance.id))
        json_instance = self.client.instances.get(json_instance.id)
        assert_equal(json_instance.status, "SHUTDOWN")

    @test(depends_on=[zzz_delete_instance])
    def delete_configuration(self):
        config = STATE["CONFIGURATION"]
        self.configs = self.snippet(
            "configuration_delete",
            ("/configurations/%s" % config.id),
            "DELETE", 202, "Accepted",
            lambda client: client.configurations.delete(config.id))


if __name__ == "__main__":
    CONFIG.load_from_file("etc/tests/localhost.test.conf")
    TestProgram().run_and_exit()
コード例 #58
0
ファイル: snippets.py プロジェクト: Tesora/tesora-trove
def create_client_args(user):

    auth_strategy = None

    kwargs = {
        'service_type': 'trove',
        'insecure': CONFIG.values['trove_client_insecure'],
    }

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

    service_url = CONFIG.get('override_trove_api_url', None)
    if user.requirements.is_admin:
        service_url = CONFIG.get('override_admin_trove_api_url',
                                 service_url)
    if service_url:
        kwargs['service_url'] = service_url

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

    if auth_strategy == 'fake':
        from troveclient.compat 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" % (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 = CONFIG.trove_auth_url
    else:
        auth_url = CONFIG.values.get('trove_admin_auth_url',
                                     CONFIG.trove_auth_url)

    if CONFIG.values.get('trove_client_cls'):
        cls_name = CONFIG.trove_client_cls
        kwargs['client_cls'] = import_class(cls_name)

    kwargs['tenant'] = user.tenant
    kwargs['auth_url'] = auth_url
    return (user.auth_user, user.auth_key), kwargs
コード例 #59
0
        index += 1

    # Many of the test decorators depend on configuration values, so before
    # start importing modules we have to load the test config followed by the
    # flag files.
    from trove.tests.config import CONFIG

    # Find config file.
    if not "TEST_CONF" in os.environ:
        raise RuntimeError("Please define an environment variable named " +
                           "TEST_CONF with the location to a conf file.")
    file_path = os.path.expanduser(os.environ["TEST_CONF"])
    if not os.path.exists(file_path):
        raise RuntimeError("Could not find TEST_CONF at " + file_path + ".")
    # Load config file and then any lines we read from the arguments.
    CONFIG.load_from_file(file_path)
    for line in extra_test_conf_lines:
        CONFIG.load_from_line(line)

    # Reset values imported into tests/__init__.
    # TODO(tim.simpson): Stop importing them from there.
    from tests import initialize_globals
    initialize_globals()

    from tests import WHITE_BOX
    if WHITE_BOX:  # If white-box testing, set up the flags.
        # Handle loading up RDL's config file madness.
        initialize_rdl_config(rdl_config_file)
        if nova_flag_file:
            initialize_nova_flags(nova_flag_file)