MinIO#
Integration with MinIO, an S3-compatible object storage service.
Installation#
pip install pytest-databases
Install your preferred S3 or MinIO client library (for example minio or boto3) alongside pytest-databases.
Docker Image#
Chainguard MinIO Docker Image:
cgr.dev/chainguard/minio:latest(override viaminio_image)
The fixture creates the default bucket with a signed S3 PUT request before yielding, so no mc client
container is needed. Use MinioService.endpoint_url as the S3 endpoint and MinioService.ensure_bucket(name) to
create more buckets.
Usage Example#
from minio import Minio
from pytest_databases.docker.minio import MinioService
pytest_plugins = ["pytest_databases.docker.minio"]
def test_minio_service(minio_service: MinioService, minio_default_bucket_name: str) -> None:
client = Minio(
endpoint=minio_service.endpoint,
access_key=minio_service.access_key,
secret_key=minio_service.secret_key,
secure=minio_service.secure,
)
assert client.bucket_exists(minio_default_bucket_name)
Available Fixtures#
minio_image: Container image for the MinIO server (default:cgr.dev/chainguard/minio:latest).minio_access_key: Access key for MinIO (default:minio; override viaMINIO_ACCESS_KEY).minio_secret_key: Secret key for MinIO (default:minio123; override viaMINIO_SECRET_KEY).minio_secure: Whether to use HTTPS for MinIO (default:False; override viaMINIO_SECURE).minio_default_bucket_name: Default bucket automatically provisioned on startup (default:pytest-databases, suffixed with the worker number underpytest-xdist; override viaMINIO_DEFAULT_BUCKET_NAME).minio_service: Provides a runningMinioServiceinstance.
Service API#
Chainguard MinIO S3-compatible object storage service fixtures.
- class pytest_databases.docker.minio.MinioService(container: docker.models.containers.Container, host: str, port: int, endpoint: str, access_key: str, secret_key: str, secure: bool)[source]#
Bases:
ServiceContainerService container for MinIO object storage.
- pytest_databases.docker.minio.minio_default_bucket_name(xdist_minio_isolation_level: Literal['database', 'server']) str[source]#
Default bucket name provisioned on startup, isolated per
pytest-xdistworker.
- pytest_databases.docker.minio.minio_image() str[source]#
Default MinIO container image from Chainguard.
- pytest_databases.docker.minio.minio_service(docker_service: DockerService, minio_access_key: str, minio_secret_key: str, minio_secure: bool, minio_default_bucket_name: str, xdist_minio_isolation_level: XdistIsolationLevel, minio_image: str) Generator[MinioService, None, None][source]#
Start a Chainguard MinIO service and create the default bucket.
- Yields:
MinioService – Started MinIO container service metadata.
- pytest_databases.docker.minio.provide_minio_service(docker_service: DockerService, *, access_key: str, secret_key: str, secure: bool, default_bucket_name: str, isolation_level: XdistIsolationLevel, image: str = 'cgr.dev/chainguard/minio:latest') Generator[MinioService, None, None][source]#
Start a Chainguard MinIO service and create the default bucket with a SigV4-signed request.
- Yields:
MinioService – Started MinIO container service metadata.