Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Fix aiohttp server autoinstrumentation #6391

Merged
merged 83 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
5160d11
Fix aiohttp server autoinstrumentation with a hack
mrnicegyu11 Sep 18, 2024
c777852
Merge branch 'master' into 2024/fix/tracing
mrnicegyu11 Sep 18, 2024
aa730ed
Merge branch 'master' into 2024/fix/tracing
mrnicegyu11 Sep 19, 2024
61366a3
minor: fix typo
mrnicegyu11 Oct 2, 2024
d1a70da
🎨 backend pulls inputs before iframe is displayed (#6392)
GitHK Sep 19, 2024
77e54ce
🚨🐛 Mitigate dy-service file upload bug: Increase traefik timeouts (#6…
mrnicegyu11 Sep 19, 2024
b44eb75
✨ [Frontend] Force reload ``no-cache`` (#6397)
odeimaiz Sep 19, 2024
ed2db58
🐛⚗️Prometheus instrumentation incorrectly setup (#6398)
sanderegg Sep 19, 2024
51edfa8
✨E2E: increase timeout for video streaming and improve a bit logs abo…
sanderegg Sep 20, 2024
26aa165
🎨Clusters keeper/use ssm (🚨change in private clusters) (#6361)
sanderegg Sep 20, 2024
9ebe05b
♻️CI: autoscaling mypy takes longer and longer. (#6417)
sanderegg Sep 20, 2024
060c9cb
🐛 Improved Error Handling for Missing Billing Details (#6418)
pcrespov Sep 21, 2024
ffba5ae
🎨 Enhances Product parsing to strip whitespaces in host_regex (#6419)
pcrespov Sep 23, 2024
2e287ab
🐛 [Frontend] Fix: Share and Leave Study (#6401)
odeimaiz Sep 23, 2024
a876819
✨ [Frontend] Workspaces & Folders: Merge Workspace header and Folder …
odeimaiz Sep 23, 2024
fcc7b78
🎨 [Frontend] Access Full TIP (#6423)
odeimaiz Sep 23, 2024
0a11c8e
🐛 [Frontend] Do not list/request ``/frontend/`` service's pricing pla…
odeimaiz Sep 23, 2024
e5b9664
Bump actions/setup-node from 4.0.3 to 4.0.4 (#6425)
dependabot[bot] Sep 23, 2024
2129de4
🎨 Persistent logs when GC removes services (#6403)
GitHK Sep 24, 2024
84119ba
🎨 The user can remove themselves from the project/workspace. (#6415)
matusdrobuliak66 Sep 24, 2024
aa0b57c
♻️ Maintenance: removing old folders (#6383)
matusdrobuliak66 Sep 24, 2024
83b3152
🎨 improve DB foreign key dependencies (🗃️) (#6428)
matusdrobuliak66 Sep 24, 2024
529122e
✨ `dynamic-scheduler` pushes service state to the frontend (⚠️ devops…
GitHK Sep 24, 2024
5457f0d
🐛 [Frontend] Fix: Do not listen to output related backend updates if …
odeimaiz Sep 24, 2024
0b7f87e
✅ e2e: new workflow to test `tiplite` (#6388)
pcrespov Sep 24, 2024
83c79c6
🎨 [Frontend] App mode: Scrollable Instructions (#6430)
odeimaiz Sep 24, 2024
a712acc
🎨 publish port events to frontend (#6396)
GitHK Sep 25, 2024
8a8319f
🔒️ Strip credentials form image VCS (#6433)
GitHK Sep 25, 2024
699e05b
⬆️ Sep tests and tooling upgrade (#6431)
mrnicegyu11 Oct 2, 2024
aaee3b2
✅ fixes check on full version (#6445)
pcrespov Sep 25, 2024
aa87f17
🐛 Fixes flaky tests in service-library test_deferred_tasks.py (#6439)
GitHK Sep 25, 2024
97ccf19
🐛 [Frontend] Announcements: allow in ribbon only (#6440)
odeimaiz Sep 25, 2024
76e96c7
🎨 improve error handling on pricing plans (#6436)
matusdrobuliak66 Sep 25, 2024
02a7908
🐛[FrontEnd] Better error handling of invalid pre-registration data (#…
pcrespov Sep 25, 2024
6b7f9f8
e2e: fixes wrong sequence in classic tip (#6450)
pcrespov Sep 25, 2024
e2a6bdc
🎨 improve tip e2e test (#6448)
matusdrobuliak66 Sep 25, 2024
32bedc7
🐛 Fixes issue with parsing logs polluting sidecar logs (#6442)
GitHK Sep 26, 2024
bd45d6b
🎨 [Frontend] TIP: Rebranding (#6446)
odeimaiz Sep 26, 2024
b6ca20a
Adding favicon for all devices (#6447)
jsaq007 Sep 26, 2024
f01b218
🎨 [Frontend] Unify ``border-radius`` (#6451)
odeimaiz Sep 26, 2024
3200fe2
🐛 fix tip e2e test (#6458)
matusdrobuliak66 Sep 27, 2024
925b817
🎨 adding `folder_id` to project resource (#6460)
matusdrobuliak66 Sep 27, 2024
7dab0e1
✅ e2e: Final touches to tip testing (#6459)
pcrespov Sep 27, 2024
afce906
✅ e2e: Fixes typo in tests (#6468)
pcrespov Sep 30, 2024
c0ba01a
✨ [Frontend] Keep View Mode in localStorage (#6463)
odeimaiz Sep 30, 2024
54e8174
🎨 [Frontend] Move multiple studies at once (#6457)
odeimaiz Sep 30, 2024
d74fa86
✨ New repository helpers on asyncpg (#6465)
pcrespov Sep 30, 2024
eca803b
♻️ Preparations in webserver to integrate asyncpg engine (#6466)
pcrespov Sep 30, 2024
cd9b335
✨ introduce `/projects:search` full search (#6464)
matusdrobuliak66 Sep 30, 2024
d34ac48
🎨 Frees up space on runner for `[build] docker images` part of the CI…
GitHK Oct 1, 2024
4cf5278
🐛🎨 Fixes unhandled config error and new log helpers for better troubl…
pcrespov Oct 1, 2024
a90d033
🎨 [Frontend] S4L: Include deprecated versions in plus button, they sh…
odeimaiz Oct 1, 2024
38ea07a
🐛 [Frontend] Guided Tours: point to visible selector or skip (#6481)
odeimaiz Oct 1, 2024
5560acd
🔨📝 Misc improvements in tooling and doc (#6478)
pcrespov Oct 1, 2024
6c46d46
Merge remote-tracking branch 'upstream/master' into 2024/fix/tracing
mrnicegyu11 Oct 2, 2024
8f06a87
Add verbose comment for special call to add midleware
mrnicegyu11 Oct 2, 2024
89d9a1d
Merge branch 'master' into 2024/fix/tracing
mrnicegyu11 Oct 2, 2024
68c6aef
Merge branch 'master' into 2024/fix/tracing
mrnicegyu11 Oct 2, 2024
6588f3b
🐛 [Frontend] Move grouped nodes (#6486)
odeimaiz Oct 2, 2024
0f1ef1d
🎨 [Frontend] Handle LongRunningTask errors better (#6485)
odeimaiz Oct 2, 2024
e3cfd8b
🐛 [Frontend] Fix for Folders disabled scenario (#6488)
odeimaiz Oct 3, 2024
b7065d9
🐛 archiving_utils creates deterministic zip archives (#6472)
GitHK Oct 3, 2024
b936411
🐛 Fixes duplicates in tags listings and new `priority` to enforce ord…
pcrespov Oct 3, 2024
2dfed79
✨Releases public-api 0.7 (#6489)
pcrespov Oct 4, 2024
1b728af
♻️ Polished and modernised agent service ⚠️ (#6452)
GitHK Oct 4, 2024
783bb1d
🎨 improve project full search (#6483)
matusdrobuliak66 Oct 4, 2024
f4dc38b
🎨 efs improvements (group extra properties) 🗃️ (#6493)
matusdrobuliak66 Oct 7, 2024
f074e42
🐛 Front-end: fixes PO center widget (#6496)
pcrespov Oct 7, 2024
3ca168d
🎨 Adds authentication for new style dynamic services and platform ven…
GitHK Oct 8, 2024
8b34d98
🎨 Expose env var to raise timeout of downloading/uploading data to an…
GitHK Oct 8, 2024
26e7fd6
🔨 New sql script template to remove readonly user (#6500)
pcrespov Oct 8, 2024
475fd13
🐛 Fixes bad formatting while handling missing configuration errors (#…
pcrespov Oct 8, 2024
9c8d0ec
♻️ increase e2e tip test timeout (#6504)
matusdrobuliak66 Oct 9, 2024
4d27c32
🎨 EFS Guardian: adding size monitoring (#6502)
matusdrobuliak66 Oct 10, 2024
42682d5
Merge remote-tracking branch 'upstream/master' into 2024/fix/tracing
mrnicegyu11 Oct 14, 2024
3ad20a7
Add middleware test
mrnicegyu11 Oct 14, 2024
d98371d
Merge branch 'master' into 2024/fix/tracing
mrnicegyu11 Oct 14, 2024
cf3eaa0
refactors test
pcrespov Oct 14, 2024
c3371b5
moves environs
pcrespov Oct 14, 2024
a29b33a
Merge branch 'master' into 2024/fix/tracing
mrnicegyu11 Oct 15, 2024
2134327
Adress pylint
mrnicegyu11 Oct 15, 2024
e62cb83
Merge branch 'master' into 2024/fix/tracing
mrnicegyu11 Oct 15, 2024
ebc9e8f
Merge branch 'master' into 2024/fix/tracing
mrnicegyu11 Oct 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions packages/service-library/src/servicelib/aiohttp/tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
from opentelemetry.instrumentation.aiohttp_client import ( # pylint:disable=no-name-in-module
AioHttpClientInstrumentor,
)
from opentelemetry.instrumentation.aiohttp_server import ( # pylint:disable=no-name-in-module
AioHttpServerInstrumentor,
from opentelemetry.instrumentation.aiohttp_server import (
middleware as aiohttp_server_opentelemetry_middleware, # pylint:disable=no-name-in-module
)
from opentelemetry.instrumentation.aiopg import ( # pylint:disable=no-name-in-module
AiopgInstrumentor,
Expand Down Expand Up @@ -72,8 +72,24 @@ def setup_tracing(

# Add the span processor to the tracer provider
tracer_provider.add_span_processor(BatchSpanProcessor(otlp_exporter)) # type: ignore[attr-defined] # https://github.com/open-telemetry/opentelemetry-python/issues/3713
# Instrument aiohttp server and client
AioHttpServerInstrumentor().instrument()
# Instrument aiohttp server
# Explanation for custom middleware call DK 10/2024:
# OpenTelemetry Aiohttp autoinstrumentation is meant to be used by only calling `AioHttpServerInstrumentor().instrument()`
# The call `AioHttpServerInstrumentor().instrument()` monkeypatches the __init__() of aiohttp's web.application() to inject the tracing middleware, in it's `__init__()`.
# In simcore, we want to switch tracing on or off using the simcore-settings-library.
# The simcore-settings library in turn depends on the instance of web.application(), i.e. the aiohttp webserver, to exist. So here we face a hen-and-egg problem.
# At the time when the instrumentation should be configured, the instance of web.application already exists and the overwrite to the __init__() is never called
#
# Since the code that is provided (monkeypatched) in the __init__ that the opentelemetry-autoinstrumentation-library provides is only 4 lines,
# just adding a middleware, we are free to simply execute this "missed call" [since we can't call the monkeypatch'ed __init__()] in this following line:
app.middlewares.insert(0, aiohttp_server_opentelemetry_middleware)
mrnicegyu11 marked this conversation as resolved.
Show resolved Hide resolved
# Code of the aiohttp server instrumentation: github.com/open-telemetry/opentelemetry-python-contrib/blob/eccb05c808a7d797ef5b6ecefed3590664426fbf/instrumentation/opentelemetry-instrumentation-aiohttp-server/src/opentelemetry/instrumentation/aiohttp_server/__init__.py#L246
# For reference, the above statement was written for:
# - osparc-simcore 1.77.x
# - opentelemetry-api==1.27.0
# - opentelemetry-instrumentation==0.48b0

# Instrument aiohttp client
mrnicegyu11 marked this conversation as resolved.
Show resolved Hide resolved
AioHttpClientInstrumentor().instrument()
if instrument_aiopg:
AiopgInstrumentor().instrument()
Expand Down
2 changes: 1 addition & 1 deletion services/datcore-adapter/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ FROM python:${PYTHON_VERSION}-slim-bookworm as base

#
# USAGE:
# cd sercices/datcore-adapter
# cd services/datcore-adapter
# docker build -f Dockerfile -t datcore-adapter:prod --target production ../../
# docker run datcore-adapter:prod
#
Expand Down
144 changes: 143 additions & 1 deletion services/web/server/tests/unit/isolated/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
from faker import Faker
from pytest_mock import MockerFixture
from pytest_simcore.helpers.dict_tools import ConfigDict
from pytest_simcore.helpers.monkeypatch_envs import setenvs_from_dict
from pytest_simcore.helpers.monkeypatch_envs import (
setenvs_from_dict,
setenvs_from_envfile,
)
from pytest_simcore.helpers.typing_env import EnvVarsDict


Expand Down Expand Up @@ -89,6 +92,145 @@ def mock_env_deployer_pipeline(monkeypatch: pytest.MonkeyPatch) -> EnvVarsDict:
)


@pytest.fixture
def mock_env_devel_environment(
mock_env_devel_environment: EnvVarsDict, # pylint: disable=redefined-outer-name
monkeypatch: pytest.MonkeyPatch,
) -> EnvVarsDict:
# Overrides to ensure dev-features are enabled testings
return mock_env_devel_environment | setenvs_from_dict(
monkeypatch,
envs={
"WEBSERVER_DEV_FEATURES_ENABLED": "1",
},
)


@pytest.fixture
def mock_env_makefile(monkeypatch: pytest.MonkeyPatch) -> EnvVarsDict:
"""envvars produced @Makefile (export)"""
# TODO: add Makefile recipe 'make dump-envs' to produce the file we load here
return setenvs_from_dict(
monkeypatch,
{
"API_SERVER_API_VERSION": "0.3.0",
"BUILD_DATE": "2022-01-14T21:28:15Z",
"CATALOG_API_VERSION": "0.3.2",
"CLIENT_WEB_OUTPUT": "/home/crespo/devp/osparc-simcore/services/static-webserver/client/source-output",
"DATCORE_ADAPTER_API_VERSION": "0.1.0-alpha",
"DIRECTOR_API_VERSION": "0.1.0",
"DIRECTOR_V2_API_VERSION": "2.0.0",
"DOCKER_IMAGE_TAG": "production",
"DOCKER_REGISTRY": "local",
"S3_ENDPOINT": "http://127.0.0.1:9001",
"STORAGE_API_VERSION": "0.2.1",
"SWARM_HOSTS": "",
"SWARM_STACK_NAME": "master-simcore",
"SWARM_STACK_NAME_NO_HYPHEN": "master_simcore",
"VCS_REF_CLIENT": "99b8022d2",
"VCS_STATUS_CLIENT": "'modified/untracked'",
"VCS_URL": "[email protected]:pcrespov/osparc-simcore.git",
"WEBSERVER_API_VERSION": "0.7.0",
},
)


@pytest.fixture
def mock_env_dockerfile_build(monkeypatch: pytest.MonkeyPatch) -> EnvVarsDict:
#
# docker run -it --hostname "{{.Node.Hostname}}-{{.Service.Name}}-{{.Task.Slot}}" local/webserver:production printenv
#
return setenvs_from_envfile(
monkeypatch,
"""\
GPG_KEY=123456789123456789
HOME=/home/scu
HOSTNAME=osparc-master-55-master-simcore_master_webserver-1
IS_CONTAINER_CONTEXT=Yes
LANG=C.UTF-8
PATH=/home/scu/.venv/bin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PWD=/home/scu
PYTHON_GET_PIP_SHA256=6123659241292b2147b58922b9ffe11dda66b39d52d8a6f3aa310bc1d60ea6f7
PYTHON_GET_PIP_URL=https://github.com/pypa/get-pip/raw/a1675ab6c2bd898ed82b1f58c486097f763c74a9/public/get-pip.py
PYTHON_PIP_VERSION=21.1.3
PYTHON_VERSION=3.11.9
PYTHONDONTWRITEBYTECODE=1
PYTHONOPTIMIZE=TRUE
SC_BOOT_MODE=production
SC_BUILD_DATE=2022-01-09T12:26:29Z
SC_BUILD_TARGET=production
SC_HEALTHCHECK_INTERVAL=30
SC_HEALTHCHECK_RETRY=3
SC_USER_ID=8004
SC_USER_NAME=scu
SC_VCS_REF=dd536f998
[email protected]:ITISFoundation/osparc-simcore.git
TERM=xterm
VIRTUAL_ENV=/home/scu/.venv
""",
)


@pytest.fixture
def mock_webserver_service_environment(
monkeypatch: pytest.MonkeyPatch,
mock_env_makefile: EnvVarsDict, # pylint: disable=redefined-outer-name
mock_env_devel_environment: EnvVarsDict, # pylint: disable=redefined-outer-name
mock_env_dockerfile_build: EnvVarsDict, # pylint: disable=redefined-outer-name
mock_env_deployer_pipeline: EnvVarsDict, # pylint: disable=redefined-outer-name
) -> EnvVarsDict:
"""
Mocks environment produce in the docker compose config with a .env (.env-devel)
and launched with a makefile
"""
# @docker compose config (overrides)
# TODO: get from docker compose config
# r'- ([A-Z2_]+)=\$\{\1:-([\w-]+)\}'

# - .env-devel + docker-compose service environs
# hostname: "{{.Node.Hostname}}-{{.Service.Name}}-{{.Task.Slot}}"

# environment:
# - CATALOG_HOST=${CATALOG_HOST:-catalog}
# - CATALOG_PORT=${CATALOG_PORT:-8000}
# - DIAGNOSTICS_MAX_AVG_LATENCY=10
# - DIAGNOSTICS_MAX_TASK_DELAY=30
# - DIRECTOR_PORT=${DIRECTOR_PORT:-8080}
# - DIRECTOR_V2_HOST=${DIRECTOR_V2_HOST:-director-v2}
# - DIRECTOR_V2_PORT=${DIRECTOR_V2_PORT:-8000}
# - STORAGE_HOST=${STORAGE_HOST:-storage}
# - STORAGE_PORT=${STORAGE_PORT:-8080}
# - SWARM_STACK_NAME=${SWARM_STACK_NAME:-simcore}
# - WEBSERVER_LOGLEVEL=${LOG_LEVEL:-WARNING}
# env_file:
# - ../.env
mock_envs_docker_compose_environment = setenvs_from_dict(
monkeypatch,
{
# Emulates MYVAR=${MYVAR:-default}
"CATALOG_HOST": os.environ.get("CATALOG_HOST", "catalog"),
"CATALOG_PORT": os.environ.get("CATALOG_PORT", "8000"),
"DIAGNOSTICS_MAX_AVG_LATENCY": "30",
"DIRECTOR_PORT": os.environ.get("DIRECTOR_PORT", "8080"),
"DIRECTOR_V2_HOST": os.environ.get("DIRECTOR_V2_HOST", "director-v2"),
"DIRECTOR_V2_PORT": os.environ.get("DIRECTOR_V2_PORT", "8000"),
"STORAGE_HOST": os.environ.get("STORAGE_HOST", "storage"),
"STORAGE_PORT": os.environ.get("STORAGE_PORT", "8080"),
"SWARM_STACK_NAME": os.environ.get("SWARM_STACK_NAME", "simcore"),
"WEBSERVER_LOGLEVEL": os.environ.get("LOG_LEVEL", "WARNING"),
"SESSION_COOKIE_MAX_AGE": str(7 * 24 * 60 * 60),
},
)

return (
mock_env_makefile
| mock_env_devel_environment
| mock_env_dockerfile_build
| mock_env_deployer_pipeline
| mock_envs_docker_compose_environment
)


@pytest.fixture
def mocked_login_required(mocker: MockerFixture):

Expand Down
143 changes: 0 additions & 143 deletions services/web/server/tests/unit/isolated/test_application_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,11 @@
# pylint:disable=no-name-in-module

import json
import os

import pytest
from aiohttp import web
from models_library.utils.json_serialization import json_dumps
from pydantic import HttpUrl, parse_obj_as
from pytest_simcore.helpers.monkeypatch_envs import (
setenvs_from_dict,
setenvs_from_envfile,
)
from pytest_simcore.helpers.typing_env import EnvVarsDict
from simcore_service_webserver.application_settings import (
APP_SETTINGS_KEY,
Expand All @@ -21,144 +16,6 @@
)


@pytest.fixture
def mock_env_devel_environment(
mock_env_devel_environment: EnvVarsDict, monkeypatch: pytest.MonkeyPatch
) -> EnvVarsDict:
# Overrides to ensure dev-features are enabled testings
return mock_env_devel_environment | setenvs_from_dict(
monkeypatch,
envs={
"WEBSERVER_DEV_FEATURES_ENABLED": "1",
},
)


@pytest.fixture
def mock_env_makefile(monkeypatch: pytest.MonkeyPatch) -> EnvVarsDict:
"""envvars produced @Makefile (export)"""
# TODO: add Makefile recipe 'make dump-envs' to produce the file we load here
return setenvs_from_dict(
monkeypatch,
{
"API_SERVER_API_VERSION": "0.3.0",
"BUILD_DATE": "2022-01-14T21:28:15Z",
"CATALOG_API_VERSION": "0.3.2",
"CLIENT_WEB_OUTPUT": "/home/crespo/devp/osparc-simcore/services/static-webserver/client/source-output",
"DATCORE_ADAPTER_API_VERSION": "0.1.0-alpha",
"DIRECTOR_API_VERSION": "0.1.0",
"DIRECTOR_V2_API_VERSION": "2.0.0",
"DOCKER_IMAGE_TAG": "production",
"DOCKER_REGISTRY": "local",
"S3_ENDPOINT": "http://127.0.0.1:9001",
"STORAGE_API_VERSION": "0.2.1",
"SWARM_HOSTS": "",
"SWARM_STACK_NAME": "master-simcore",
"SWARM_STACK_NAME_NO_HYPHEN": "master_simcore",
"VCS_REF_CLIENT": "99b8022d2",
"VCS_STATUS_CLIENT": "'modified/untracked'",
"VCS_URL": "[email protected]:pcrespov/osparc-simcore.git",
"WEBSERVER_API_VERSION": "0.7.0",
},
)


@pytest.fixture
def mock_env_dockerfile_build(monkeypatch: pytest.MonkeyPatch) -> EnvVarsDict:
#
# docker run -it --hostname "{{.Node.Hostname}}-{{.Service.Name}}-{{.Task.Slot}}" local/webserver:production printenv
#
return setenvs_from_envfile(
monkeypatch,
"""\
GPG_KEY=123456789123456789
HOME=/home/scu
HOSTNAME=osparc-master-55-master-simcore_master_webserver-1
IS_CONTAINER_CONTEXT=Yes
LANG=C.UTF-8
PATH=/home/scu/.venv/bin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PWD=/home/scu
PYTHON_GET_PIP_SHA256=6123659241292b2147b58922b9ffe11dda66b39d52d8a6f3aa310bc1d60ea6f7
PYTHON_GET_PIP_URL=https://github.com/pypa/get-pip/raw/a1675ab6c2bd898ed82b1f58c486097f763c74a9/public/get-pip.py
PYTHON_PIP_VERSION=21.1.3
PYTHON_VERSION=3.11.9
PYTHONDONTWRITEBYTECODE=1
PYTHONOPTIMIZE=TRUE
SC_BOOT_MODE=production
SC_BUILD_DATE=2022-01-09T12:26:29Z
SC_BUILD_TARGET=production
SC_HEALTHCHECK_INTERVAL=30
SC_HEALTHCHECK_RETRY=3
SC_USER_ID=8004
SC_USER_NAME=scu
SC_VCS_REF=dd536f998
[email protected]:ITISFoundation/osparc-simcore.git
TERM=xterm
VIRTUAL_ENV=/home/scu/.venv
""",
)


@pytest.fixture
def mock_webserver_service_environment(
monkeypatch: pytest.MonkeyPatch,
mock_env_makefile: EnvVarsDict,
mock_env_devel_environment: EnvVarsDict,
mock_env_dockerfile_build: EnvVarsDict,
mock_env_deployer_pipeline: EnvVarsDict,
) -> EnvVarsDict:
"""
Mocks environment produce in the docker compose config with a .env (.env-devel)
and launched with a makefile
"""
# @docker compose config (overrides)
# TODO: get from docker compose config
# r'- ([A-Z2_]+)=\$\{\1:-([\w-]+)\}'

# - .env-devel + docker-compose service environs
# hostname: "{{.Node.Hostname}}-{{.Service.Name}}-{{.Task.Slot}}"

# environment:
# - CATALOG_HOST=${CATALOG_HOST:-catalog}
# - CATALOG_PORT=${CATALOG_PORT:-8000}
# - DIAGNOSTICS_MAX_AVG_LATENCY=10
# - DIAGNOSTICS_MAX_TASK_DELAY=30
# - DIRECTOR_PORT=${DIRECTOR_PORT:-8080}
# - DIRECTOR_V2_HOST=${DIRECTOR_V2_HOST:-director-v2}
# - DIRECTOR_V2_PORT=${DIRECTOR_V2_PORT:-8000}
# - STORAGE_HOST=${STORAGE_HOST:-storage}
# - STORAGE_PORT=${STORAGE_PORT:-8080}
# - SWARM_STACK_NAME=${SWARM_STACK_NAME:-simcore}
# - WEBSERVER_LOGLEVEL=${LOG_LEVEL:-WARNING}
# env_file:
# - ../.env
mock_envs_docker_compose_environment = setenvs_from_dict(
monkeypatch,
{
# Emulates MYVAR=${MYVAR:-default}
"CATALOG_HOST": os.environ.get("CATALOG_HOST", "catalog"),
"CATALOG_PORT": os.environ.get("CATALOG_PORT", "8000"),
"DIAGNOSTICS_MAX_AVG_LATENCY": "30",
"DIRECTOR_PORT": os.environ.get("DIRECTOR_PORT", "8080"),
"DIRECTOR_V2_HOST": os.environ.get("DIRECTOR_V2_HOST", "director-v2"),
"DIRECTOR_V2_PORT": os.environ.get("DIRECTOR_V2_PORT", "8000"),
"STORAGE_HOST": os.environ.get("STORAGE_HOST", "storage"),
"STORAGE_PORT": os.environ.get("STORAGE_PORT", "8080"),
"SWARM_STACK_NAME": os.environ.get("SWARM_STACK_NAME", "simcore"),
"WEBSERVER_LOGLEVEL": os.environ.get("LOG_LEVEL", "WARNING"),
"SESSION_COOKIE_MAX_AGE": str(7 * 24 * 60 * 60),
},
)

return (
mock_env_makefile
| mock_env_devel_environment
| mock_env_dockerfile_build
| mock_env_deployer_pipeline
| mock_envs_docker_compose_environment
)


@pytest.fixture
def app_settings(
mock_webserver_service_environment: EnvVarsDict,
Expand Down
Loading
Loading