Example #1
0
def bucket(s3_client: S3Client) -> str:  # pylint: disable=W0621
    bucket_name = "simcore-test"
    s3_client.create_bucket(bucket_name, delete_contents_if_exists=True)
    # set env variables
    os.environ["S3_BUCKET_NAME"] = bucket_name
    yield bucket_name

    s3_client.remove_bucket(bucket_name, delete_contents=True)
Example #2
0
def s3_client(docker_ip, docker_services):
    """wait for minio to be up"""

    # Build URL to service listening on random port.
    url = 'http://%s:%d/' % (
        docker_ip,
        docker_services.port_for('minio', 9000),
    )

    # Wait until service is responsive.
    docker_services.wait_until_responsive(
        check=lambda: is_responsive(url, 403),
        timeout=30.0,
        pause=0.1,
    )

    # Contact the service.
    response = requests.get(url)
    assert response.status_code == 403

    endpoint = '{ip}:{port}'.format(ip=docker_ip,
                                    port=docker_services.port_for(
                                        'minio', 9000))
    access_key = "12345678"
    secret_key = "12345678"
    secure = False
    s3_client = S3Client(endpoint, access_key, secret_key, secure)
    return s3_client
def wait_till_minio_responsive(minio_config: Dict[str, str]) -> bool:
    """Check if something responds to ``url`` """
    client = S3Client(**minio_config["client"])
    if client.create_bucket("pytest"):
        client.remove_bucket("pytest")
        return True
    raise Exception(f"Minio not responding to {minio_config}")
 def __init__(self):
     self._config = s3_config()
     self.client = S3Client(endpoint=self._config.endpoint,
                            access_key=self._config.access_key,
                            secret_key=self._config.secret_key)
     self.bucket = self._config.bucket_name
     self.client.create_bucket(self.bucket)
Example #5
0
def s3_client(minio_service):
    from s3wrapper.s3_client import S3Client

    s3_client = S3Client(endpoint=minio_service['endpoint'],
                         access_key=minio_service["access_key"],
                         secret_key=minio_service["secret_key"])
    return s3_client
Example #6
0
def setup(app: web.Application):
    """ minio/s3 service setup"""

    log.debug("Setting up %s ...", __name__)
    disable_services = app[APP_CONFIG_KEY].get("main",
                                               {}).get("disable_services", [])

    if _SERVICE_NAME in disable_services:
        log.warning("Service '%s' explicitly disabled in config",
                    _SERVICE_NAME)
        return

    cfg = app[APP_CONFIG_KEY]
    s3_cfg = cfg[_SERVICE_NAME]
    s3_access_key = s3_cfg["access_key"]
    s3_endpoint = s3_cfg["endpoint"]
    s3_secret_key = s3_cfg["secret_key"]
    s3_secure = s3_cfg["secure"]

    s3_client = S3Client(s3_endpoint,
                         s3_access_key,
                         s3_secret_key,
                         secure=s3_secure == 1)
    app[APP_S3_KEY] = s3_client

    app.cleanup_ctx.append(_on_startup_and_cleanup)
Example #7
0
def minio_service(minio_config: Dict[str, str]) -> S3Client:
    assert wait_till_minio_responsive(minio_config)

    client = S3Client(**minio_config["client"])
    assert client.create_bucket(minio_config["bucket_name"])

    yield client

    assert client.remove_bucket(minio_config["bucket_name"],
                                delete_contents=True)
def bucket(minio_config: Dict[str, str], minio_service: S3Client) -> str:
    bucket_name = minio_config["bucket_name"]
    minio_service.create_bucket(bucket_name, delete_contents_if_exists=True)
    yield bucket_name

    minio_service.remove_bucket(bucket_name, delete_contents=True)
Example #9
0
def s3_client(external_minio: Dict) -> S3Client:  # pylint:disable=redefined-outer-name
    s3_endpoint = "{}:{}".format(external_minio["host"],
                                 external_minio["port"])
    yield S3Client(s3_endpoint, external_minio["s3access"],
                   external_minio["s3secret"], False)
Example #10
0
def s3_client(minio_service):
    from s3wrapper.s3_client import S3Client

    s3_client = S3Client(**minio_service)
    return s3_client