Skip to content

fix(gcs): add fake-gcs-server container - #1145

Open
AvinashKalamati wants to merge 2 commits into
testcontainers:mainfrom
AvinashKalamati:feat/gcs-container
Open

AvinashKalamati wants to merge 2 commits into
testcontainers:mainfrom
AvinashKalamati:feat/gcs-container

Conversation

@AvinashKalamati

Copy link
Copy Markdown

New Container

Fixes #1084

Adds GcsContainer (testcontainers.community.gcs), a Google Cloud Storage emulator based on
fake-gcs-server, similar to the existing GCS support in
testcontainers for Java, Go and .NET, and to AzuriteContainer for Azure.

What it does

  • Runs fsouza/fake-gcs-server:1.56.1 over plain HTTP with the in-memory backend.
  • Waits until the JSON API (/storage/v1/b) responds.
  • After start, sets the server's externalUrl via PUT /_internal/config to the host-mapped address.
    Without this, object links such as mediaLink point to 0.0.0.0:4443, which is unreachable from the host.
    -get_url() returns the emulator endpoint; get_client() returns a google.cloud.storage.Client
    with anonymous credentials (requires google-cloud-storage to be installed).

Tests

  • Upload, download and listing of objects
  • Object links use the mapped port
  • Resumable upload (10 MiB, above the client's multipart limit)
  • Custom project

Passing locally on Python 3.10, 3.11 and 3.14; doctest and pre-commit pass.

PR Checklist

  • Your PR title follows the Conventional Commits syntax
  • Your PR allows maintainers to edit your branch
  • The new container is implemented under src/testcontainers/community/gcs/
  • Namespacing follows testcontainers.community.gcs.*
  • Tests under tests/community/gcs/
  • docs/community/gcs.rst with .. autoclass and .. title
  • Module added in pyproject.toml as gcs = []
  • Branch is up-to-date with main

@hampsterx

Copy link
Copy Markdown

Ran this against a downstream suite that drives fake-gcs-server through its own DockerContainer subclass (panodata/omniload#433). Swapping in GcsContainer at 5d95e51 passed all three GCS integration cases unchanged, at the same runtime, with no other edits beyond get_url().

@AvinashKalamati

Copy link
Copy Markdown
Author

Thanks a lot @hampsterx for testing this against omniload's suite, great to see it works as a drop-in replacement!

@amotl amotl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hampsterx evaluated your container wrapper successfully. Thank you!

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

New Container: fake-gcs-server

4 participants