Exemplo n.º 1
0
    def setUpClass(cls):
        super(ObjectStorageFixture, cls).setUpClass()

        endpoint_config = UserAuthConfig()
        user_config = UserConfig()
        objectstorage_config = ObjectStorageConfig()
        objectstorage_api_config = ObjectStorageAPIConfig()

        auth_provider = AuthProvider()
        access_data = auth_provider.get_access_data(endpoint_config,
                                                    user_config)

        service = access_data.get_service(
            objectstorage_config.identity_service_name)

        endpoint = service.get_endpoint(objectstorage_config.region)
        storage_url = endpoint.public_url
        auth_token = access_data.token.id_

        cls.base_container_name = objectstorage_api_config.base_container_name
        cls.base_object_name = objectstorage_api_config.base_object_name

        cls.client = ObjectStorageAPIClient(storage_url, auth_token)

        cls.behaviors = ObjectStorageAPI_Behaviors(client=cls.client)
Exemplo n.º 2
0
 def __init__(self, client=None, config=None):
     super(ObjectStorageAPI_Behaviors, self).__init__()
     self.client = client
     if config:
         self.config = config
     else:
         self.config = ObjectStorageAPIConfig()
Exemplo n.º 3
0
    def setUpClass(cls):
        super(ObjectStorageIntegrationFixture, cls).setUpClass()
        cls.object_storage_config = ObjectStorageConfig()
        cls.object_storage_api_config = ObjectStorageAPIConfig()

        objectstorage_service = cls.access_data.get_service(
            cls.object_storage_config.identity_service_name)
        objectstorage_url_check = objectstorage_service.get_endpoint(
            cls.object_storage_config.region)
        # If endpoint validation fails, fail immediately
        if objectstorage_url_check is None:
            cls.assertClassSetupFailure('Endpoint validation failed')
        alt_objectstorage_service = cls.alt_access_data.get_service(
            cls.object_storage_config.identity_service_name)
        alt_objectstorage_url_check = alt_objectstorage_service.get_endpoint(
            cls.object_storage_config.region)
        # If endpoint validation fails, fail immediately
        if alt_objectstorage_url_check is None:
            cls.assertClassSetupFailure('Endpoint validation failed')

        cls.storage_url = objectstorage_service.get_endpoint(
            cls.object_storage_config.region).public_url
        cls.alt_storage_url = alt_objectstorage_service.get_endpoint(
            cls.object_storage_config.region).public_url

        cls.object_storage_client = ObjectStorageAPIClient(
            cls.storage_url, cls.access_data.token.id_)
        cls.alt_object_storage_client = ObjectStorageAPIClient(
            cls.alt_storage_url, cls.alt_access_data.token.id_)

        cls.object_storage_behaviors = ObjectStorageAPI_Behaviors(
            cls.object_storage_client, cls.object_storage_api_config)
        cls.alt_object_storage_behaviors = ObjectStorageAPI_Behaviors(
            cls.alt_object_storage_client, cls.object_storage_api_config)
Exemplo n.º 4
0
        def decorator(func):
            auth_data = ObjectStorageAuthComposite()
            objectstorage_api_config = ObjectStorageAPIConfig()
            client = ObjectStorageAPIClient(auth_data.storage_url,
                                            auth_data.auth_token)
            behaviors = ObjectStorageAPI_Behaviors(
                client=client, config=objectstorage_api_config)

            features = behaviors.get_configured_features()

            if features == objectstorage_api_config.ALL_FEATURES:
                return func

            if features == objectstorage_api_config.NO_FEATURES:
                setattr(func, '__unittest_skip__', True)
                setattr(func, '__unittest_skip_why__', 'Skipping All Features')

            features = features.split()
            missing_reqs = False
            for req in required_features:
                if req not in features:
                    missing_reqs = True
                    break

            if missing_reqs:
                setattr(func, '__unittest_skip__', True)
                setattr(
                    func, '__unittest_skip_why__',
                    'requires features: {0}'.format(
                        ', '.join(required_features)))

            return func
Exemplo n.º 5
0
    def required_middleware(cls, middleware):
        """
        Test decorator to skip tests if middleware is not configured in swift.
        Configuration of what middleware is in the proxy pipeline can be done
        from the objectstorage config file.

        Note: "lambda func: func" is from the Python unit tests example
              "25.3.6. Skipping tests and expected failures":

        def skipUnlessHasattr(obj, attr):
            if hasattr(obj, attr):
                return lambda func: func
            return unittest.skip("{!r} doesn't have {!r}".format(obj, attr))

        http://docs.python.org/2/library/unittest.html
        """
        objectstorage_api_config = ObjectStorageAPIConfig()
        proxy_pipeline = objectstorage_api_config.proxy_pipeline

        if proxy_pipeline == objectstorage_api_config.PROXY_PIPELINE_ALL:
            return lambda func: func

        proxy_pipeline = proxy_pipeline.split()
        for m in middleware:
            if m not in proxy_pipeline:
                return unittest.skip('middleware not configured')

        return lambda func: func
Exemplo n.º 6
0
 def setUpClass(cls):
     super(ObjectStorageFixture, cls).setUpClass()
     cls.auth_data = ObjectStorageAuthComposite()
     cls.objectstorage_api_config = ObjectStorageAPIConfig()
     cls.storage_url = cls.auth_data.storage_url
     cls.auth_token = cls.auth_data.auth_token
     cls.base_container_name = (
         cls.objectstorage_api_config.base_container_name)
     cls.client = ObjectStorageAPIClient(cls.storage_url, cls.auth_token)
     cls.behaviors = ObjectStorageAPI_Behaviors(
         client=cls.client, config=cls.objectstorage_api_config)
Exemplo n.º 7
0
    def __init__(self, client=None, config=None):
        super(ObjectStorageAPI_Behaviors, self).__init__()
        self.client = client
        if config:
            self.config = config
        else:
            self.config = ObjectStorageAPIConfig()

        self.data_pool = [
            char for char in UNICODE_BLOCKS.get_range(
                BLOCK_NAMES.basic_latin).encoded_codepoints()
        ]
Exemplo n.º 8
0
    def setUpClass(cls):
        super(ObjectStorageFixture, cls).setUpClass()

        auth_data = cls.get_auth_data()
        storage_url = auth_data['storage_url']
        auth_token = auth_data['auth_token']

        objectstorage_api_config = ObjectStorageAPIConfig()
        cls.base_container_name = objectstorage_api_config.base_container_name
        cls.base_object_name = objectstorage_api_config.base_object_name

        cls.client = ObjectStorageAPIClient(storage_url, auth_token)
        cls.behaviors = ObjectStorageAPI_Behaviors(client=cls.client)
Exemplo n.º 9
0
    def __init__(self):
        self.config = ObjectStorageAPIConfig()
        self.auth_info = self._auth_composite()

        self.storage_url = self.auth_info.public_url
        self.auth_token = self.auth_info.token_id

        if self.auth_info.auth_strategy == 'saio_tempauth':
            self.storage_url = self.auth_info.access_data.storage_url
            self.auth_token = self.auth_info.access_data.auth_token

        self.client = ObjectStorageAPIClient(self.storage_url, self.auth_token)

        self.behaviors = ObjectStorageAPI_Behaviors(client=self.client,
                                                    config=self.config)
Exemplo n.º 10
0
        def decorator(func):
            # TODO: This is not ideal, should change this to support
            # multiple versions
            required_version = required_versions[0]
            auth_data = ObjectStorageAuthComposite()
            objectstorage_api_config = ObjectStorageAPIConfig()
            client = ObjectStorageAPIClient(auth_data.storage_url,
                                            auth_data.auth_token)
            behaviors = ObjectStorageAPI_Behaviors(
                client=client, config=objectstorage_api_config)

            swift_version = objectstorage_api_config.version
            if not swift_version and objectstorage_api_config.use_swift_info:
                info = behaviors.get_swift_info()
                swift_version = info.get('swift', {
                    'version': None
                }).get('version', None)

            if not swift_version:
                return func

            if required_version.startswith('<'):
                required_version = required_version.lstrip('<')
                compare_func = lambda sv, tv: sv < tv
                extra_message = ' less than'
            elif required_version.startswith('>'):
                required_version = required_version.lstrip('>')
                compare_func = lambda sv, tv: sv > tv
                extra_message = ' greater than'
            else:
                required_version = required_version.lstrip('=')
                compare_func = lambda sv, tv: sv.startswith(tv)
                extra_message = ''

            if compare_func(swift_version, required_version):
                func

            setattr(func, '__unittest_skip__', True)
            setattr(
                func, '__unittest_skip_why__',
                'swift running version {0}, requires version{1}: {2}'.format(
                    swift_version, extra_message, required_version))
            return func
Exemplo n.º 11
0
    def __init__(self, exclude=None):
        api_config = ObjectStorageAPIConfig()
        auth_data = ObjectStorageAuthComposite()
        client = ObjectStorageAPIClient(auth_data.storage_url,
                                        auth_data.auth_token)
        behaviors = ObjectStorageAPI_Behaviors(client, api_config)
        features = behaviors.get_configured_features()

        if features == api_config.ALL_FEATURES:
            features = ['dlo', 'slo']

        generator = ObjectStorageGenerator(client)

        if exclude is None:
            exclude = []

        if 'standard' not in exclude:
            self.append_new_dataset(
                'standard', {
                    'object_type': 'standard',
                    'generate_object': generator.generate_object
                })

        if 'dlo' in features and 'dlo' not in exclude:
            self.append_new_dataset(
                'dlo', {
                    'object_type': 'dlo',
                    'generate_object': generator.generate_dynamic_large_object
                })

        if 'slo' in features and 'slo' not in exclude:
            self.append_new_dataset(
                'slo', {
                    'object_type': 'slo',
                    'generate_object': generator.generate_static_large_object
                })
Exemplo n.º 12
0
 def __init__(self, client=None, config=None):
     self.client = client
     if config:
         self.config = config
     else:
         self.config = ObjectStorageAPIConfig()
Exemplo n.º 13
0
    def setUpClass(cls):
        super(ImagesIntegrationFixture, cls).setUpClass()
        cls.object_storage_client = cls.client
        cls.object_storage_behaviors = cls.behaviors

        # Work around to create compute/obj storage additional user composites
        auth_endpoint_config = UserAuthConfig()
        compute_endpoint = ComputeEndpointConfig()
        images_config = ImagesConfig()
        flavors_config = FlavorsConfig()
        marshalling_config = MarshallingConfig()
        object_storage_config = ObjectStorageConfig()
        object_storage_api_config = ObjectStorageAPIConfig()
        servers_config = ServersConfig()
        user_config_alt_one = AltOneUserConfig()

        access_data_alt_one = AuthProvider.get_access_data(
            auth_endpoint_config, user_config_alt_one)

        # Create compute clients and behaviors for alt_one user
        compute_service_alt_one = access_data_alt_one.get_service(
            compute_endpoint.compute_endpoint_name)
        compute_url_check_alt_one = compute_service_alt_one.get_endpoint(
            compute_endpoint.region)
        # If compute endpoint validation fails, fail immediately
        if compute_url_check_alt_one is None:
            cls.assertClassSetupFailure('Compute endpoint validation failed')
        compute_url_alt_one = compute_service_alt_one.get_endpoint(
            compute_endpoint.region).public_url

        cls.compute_alt_one_images_client = ComputeImagesClient(
            compute_url_alt_one, access_data_alt_one.token.id_,
            marshalling_config.serializer, marshalling_config.deserializer)

        cls.compute_alt_one_servers_client = ServersClient(
            compute_url_alt_one, access_data_alt_one.token.id_,
            marshalling_config.serializer, marshalling_config.deserializer)

        cls.compute_alt_one_images_behaviors = ComputeImageBehaviors(
            images_client=cls.compute_alt_one_images_client,
            servers_client=cls.compute_alt_one_servers_client,
            config=images_config)

        cls.compute_alt_one_servers_behaviors = ServerBehaviors(
            servers_client=cls.compute_alt_one_servers_client,
            images_client=cls.compute_alt_one_images_client,
            servers_config=servers_config, images_config=images_config,
            flavors_config=flavors_config)

        # Create object storage client and behaviors for alt_one user
        object_storage_service_alt_one = access_data_alt_one.get_service(
            object_storage_config.identity_service_name)
        object_storage_url_check_alt_one = (
            object_storage_service_alt_one.get_endpoint(
                object_storage_config.region))
        # If endpoint validation fails, fail immediately
        if object_storage_url_check_alt_one is None:
            cls.assertClassSetupFailure('Endpoint validation failed')
        storage_url_alt_one = object_storage_service_alt_one.get_endpoint(
            object_storage_config.region).public_url

        cls.object_storage_alt_one_client = ObjectStorageAPIClient(
            storage_url_alt_one, access_data_alt_one.token.id_)

        cls.object_storage_alt_one_behaviors = ObjectStorageAPI_Behaviors(
            cls.object_storage_alt_one_client, object_storage_api_config)

        # Needed in order to allow assertions on exceptions
        cls.compute.flavors.client.delete_exception_handler(
            cls.compute_exception_handler)
Exemplo n.º 14
0
 def __init__(self, client=None):
     self.client = client
     self.config = ObjectStorageAPIConfig()
Exemplo n.º 15
0
 def __init__(self, client):
     self.client = client
     self.api_config = ObjectStorageAPIConfig()