Skip to content

Commit

Permalink
Fixing storeage tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pcrespov committed Jun 27, 2021
1 parent c5c00d2 commit 6754842
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 13 deletions.
12 changes: 6 additions & 6 deletions services/storage/src/simcore_service_storage/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ async def pg_engine(app: web.Application):
pg_cfg: PostgresSettings = app[APP_CONFIG_KEY].STORAGE_POSTGRES
dsn = DataSourceName(
application_name=f"{__name__}_{id(app)}",
database=pg_cfg.db,
user=pg_cfg.user,
password=pg_cfg.password.get_secret_value(),
host=pg_cfg.host,
port=pg_cfg.port,
database=pg_cfg.POSTGRES_DB,
user=pg_cfg.POSTGRES_USER,
password=pg_cfg.POSTGRES_PASSWORD.get_secret_value(),
host=pg_cfg.POSTGRES_HOST,
port=pg_cfg.POSTGRES_PORT,
) # type: ignore

log.info("Creating pg engine for %s", dsn)
Expand All @@ -40,7 +40,7 @@ async def pg_engine(app: web.Application):
):
with attempt:
engine = await create_pg_engine(
dsn, minsize=pg_cfg.minsize, maxsize=pg_cfg.maxsize
dsn, minsize=pg_cfg.POSTGRES_MINSIZE, maxsize=pg_cfg.POSTGRES_MAXSIZE
)
await raise_if_not_responsive(engine)

Expand Down
2 changes: 1 addition & 1 deletion services/storage/src/simcore_service_storage/dsm.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ async def _cleanup_context(app: web.Application):
engine=app.get(APP_DB_ENGINE_KEY),
loop=asyncio.get_event_loop(),
pool=executor,
simcore_bucket_name=cfg.STORAGE_S3.bucket_name,
simcore_bucket_name=cfg.STORAGE_S3.S3_BUCKET_NAME,
has_project_db=not cfg.STORAGE_TESTING,
app=app,
) # type: ignore
Expand Down
8 changes: 4 additions & 4 deletions services/storage/src/simcore_service_storage/s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ def setup_s3(app: web.Application):
cfg = app[APP_CONFIG_KEY]

s3_client = MinioClientWrapper(
cfg.STORAGE_S3.endpoint,
cfg.STORAGE_S3.access_key,
cfg.STORAGE_S3.secret_key,
secure=cfg.STORAGE_S3.secure == 1,
cfg.STORAGE_S3.S3_ENDPOINT,
cfg.STORAGE_S3.S3_ACCESS_KEY,
cfg.STORAGE_S3.S3_SECRET_KEY,
secure=cfg.STORAGE_S3.S3_SECURE,
)
app[APP_S3_KEY] = s3_client

Expand Down
14 changes: 12 additions & 2 deletions services/storage/tests/test_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,18 @@ def client(
pg_config = postgres_service.copy()
pg_config.pop("database")

monkeypatch.setenv("STORAGE_POSTGRES", json.dumps(pg_config))
monkeypatch.setenv("STORAGE_S3", json.dumps(minio_service))
monkeypatch.setenv(
"STORAGE_POSTGRES",
json.dumps(
{f"POSTGRES_{key.upper()}": value for key, value in pg_config.items()}
),
)
monkeypatch.setenv(
"STORAGE_S3",
json.dumps(
{f"S3_{key.upper()}": value for key, value in minio_service.items()}
),
)
monkeypatch.setenv("STORAGE_PORT", str(aiohttp_unused_port()))
monkeypatch.setenv("STORAGE_LOG_LEVEL", "DEBUG")
monkeypatch.setenv("STORAGE_TESTING", "1")
Expand Down

0 comments on commit 6754842

Please sign in to comment.