Skip to content

Python API inside a Docker container fails #190

Open
@swarmt

Description

@swarmt

Describe the bug
Using the Python API example works perfectly in a virtual environment.
Fails when run in a docker container with a time out.
HTTPConnectionPool(host='172.17.0.1', port=63342): Max retries exceeded with url:

To Reproduce

import os
import pathlib as pl
import shutil

import pytest
from gcp_storage_emulator.server import create_server
from google.auth.credentials import AnonymousCredentials
from google.cloud import storage

import upload


@pytest.fixture
def mock_storage_client():
    """Google Cloud Storage emulator"""
    host = "localhost"
    port = 9023
    server = create_server(host, port, in_memory=True)
    server.start()
    os.environ["STORAGE_EMULATOR_HOST"] = f"http://{host}:{port}"
    yield storage.Client(credentials=AnonymousCredentials(), project="test-project")
    server.stop()
    del os.environ["STORAGE_EMULATOR_HOST"]


def test_upload_folder(mock_storage_client):
    """Test uploading a folder to Google Cloud Storage"""
    bucket_name = "test-upload-bucket"
    mock_storage_client.create_bucket(bucket_name)

Expected behavior
Bucket is created.

System (please complete the following information):

  • OS version: macos / linux
  • Python version: 3.9
  • gcp-storage-emulator version: latest

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions