Skip to content

Commit ad23fdb

Browse files
author
Pedro Crespo
committed
storage/tests/test_config passes
- Adds workspace variables in config-files - Update config files with new section - Adds APIHUB_HOST, _PORT in storage docker-compose - Fixes duplication of docker-compose storage service
1 parent 552e601 commit ad23fdb

File tree

6 files changed

+43
-39
lines changed

6 files changed

+43
-39
lines changed

services/docker-compose.yml

+2-30
Original file line numberDiff line numberDiff line change
@@ -148,36 +148,8 @@ services:
148148
ports:
149149
- "11111:8080"
150150
environment:
151-
- POSTGRES_ENDPOINT=${POSTGRES_ENDPOINT}
152-
- POSTGRES_USER=${POSTGRES_USER}
153-
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
154-
- POSTGRES_DB=${POSTGRES_DB}
155-
- POSTGRES_HOST=${POSTGRES_HOST}
156-
- POSTGRES_PORT=${POSTGRES_PORT}
157-
- S3_ENDPOINT=${S3_ENDPOINT}
158-
- S3_ACCESS_KEY=${S3_ACCESS_KEY}
159-
- S3_SECRET_KEY=${S3_SECRET_KEY}
160-
- S3_BUCKET_NAME=${S3_BUCKET_NAME}
161-
- STORAGE_ENDPOINT=${STORAGE_ENDPOINT}
162-
- RUN_DOCKER_ENGINE_ROOT=${RUN_DOCKER_ENGINE_ROOT}
163-
- BF_API_SECRET=${BF_API_SECRET}
164-
- BF_API_KEY=${BF_API_KEY}
165-
depends_on:
166-
- minio
167-
- postgres
168-
#--------------------------------------------------------------------
169-
storage:
170-
build:
171-
# the context for the build is the git repo root directory, this allows to copy
172-
# the packages directory into any docker image
173-
context: ../
174-
dockerfile: services/storage/Dockerfile
175-
args:
176-
- DOCKER_GID_ARG=${DOCKER_GID:?Undefined docker gid in host}
177-
target: production
178-
ports:
179-
- "11111:8080"
180-
environment:
151+
- APIHUB_HOST=apihub
152+
- APIHUB_PORT=8043
181153
- POSTGRES_ENDPOINT=${POSTGRES_ENDPOINT}
182154
- POSTGRES_USER=${POSTGRES_USER}
183155
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}

services/storage/src/simcore_service_storage/cli.py

+25-1
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,36 @@
1515
import argparse
1616
import logging
1717
import sys
18+
import os
1819

1920
from . import application, cli_config
21+
from servicelib.utils import search_osparc_repo_dir
22+
2023

2124
log = logging.getLogger(__name__)
2225

2326

27+
def create_environ(skip_system_environ=False):
28+
"""
29+
Build environment of substitutable variables
30+
31+
"""
32+
# system's environment variables
33+
environ = {} if skip_system_environ else dict(os.environ)
34+
35+
# project-related environment variables
36+
here = os.path.dirname(__file__)
37+
environ['THIS_PACKAGE_DIR'] = here
38+
39+
rootdir = search_osparc_repo_dir(start=here)
40+
if rootdir is not None:
41+
environ['OSPARC_SIMCORE_REPO_ROOTDIR'] = str(rootdir)
42+
43+
44+
return environ
45+
46+
47+
2448
def setup(_parser):
2549
cli_config.add_cli_options(_parser)
2650
return _parser
@@ -33,7 +57,7 @@ def parse(args, _parser):
3357

3458
# ignore unknown options
3559
options, _ = _parser.parse_known_args(args)
36-
config = cli_config.config_from_options(options)
60+
config = cli_config.config_from_options(options, vars=create_environ())
3761

3862
# TODO: check whether extra options can be added to the config?!
3963
return config

services/storage/src/simcore_service_storage/data/docker-dev-config.yaml

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
version: '1.0'
12
main:
2-
# disable_services: ['postgres', 's3']
33
host: 0.0.0.0
44
log_level: INFO
55
port: 8080
@@ -21,4 +21,6 @@ s3:
2121
access_key: ${S3_ACCESS_KEY}
2222
secret_key: ${S3_SECRET_KEY}
2323
bucket_name: ${S3_BUCKET_NAME}
24-
version: '1.0'
24+
rest:
25+
oas_repo: ${OSPARC_SIMCORE_REPO_ROOTDIR}/api/specs
26+
#oas_repo: http://0.0.0.0:8043/api/specs

services/storage/src/simcore_service_storage/data/docker-prod-config.yaml

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
version: '1.0'
12
main:
2-
# disable_services: ['postgres', 's3']
33
host: 0.0.0.0
44
log_level: INFO
55
port: 8080
@@ -20,4 +20,5 @@ s3:
2020
access_key: ${S3_ACCESS_KEY}
2121
secret_key: ${S3_SECRET_KEY}
2222
bucket_name: ${S3_BUCKET_NAME}
23-
version: '1.0'
23+
rest:
24+
oas_repo: http://${APIHUB_HOST}:${APIHUB_PORT}/api/specs

services/storage/src/simcore_service_storage/data/host-dev-config.yaml

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
version: '1.0'
12
main:
23
disable_services: ['postgres', 's3']
34
host: 127.0.0.1
@@ -22,4 +23,6 @@ s3:
2223
bucket_name: simcore
2324
endpoint: minio:9000
2425
secret_key: '12345678'
25-
version: '1.0'
26+
rest:
27+
oas_repo: ${OSPARC_SIMCORE_REPO_ROOTDIR}/api/specs
28+
#oas_repo: http://localhost:8043/api/specs

services/storage/tests/test_configs.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ def devel_environ(env_devel_file):
4141
env_devel[key] = value
4242
return env_devel
4343

44+
from simcore_service_storage.cli import create_environ
4445

4546
@pytest.fixture("session")
4647
def container_environ(services_docker_compose_file, devel_environ):
@@ -51,11 +52,12 @@ def container_environ(services_docker_compose_file, devel_environ):
5152
with services_docker_compose_file.open() as f:
5253
dc = yaml.safe_load(f)
5354

54-
container_environ = {
55+
container_environ = create_environ(skip_system_environ=True)
56+
container_environ.update({
5557
'VENV2': '/home/scu/.venv27/' # defined in Dockerfile
56-
}
58+
})
5759

58-
environ_items =dc["services"][THIS_SERVICE].get("environment", list())
60+
environ_items = dc["services"][THIS_SERVICE].get("environment", list())
5961
MATCH = re.compile(r'\$\{(\w+)+')
6062

6163
for item in environ_items:

0 commit comments

Comments
 (0)