Skip to content

Commit

Permalink
Got containers to work
Browse files Browse the repository at this point in the history
  • Loading branch information
jpbruinsslot committed Oct 16, 2023
1 parent d5b573b commit 1a8d354
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 24 deletions.
30 changes: 16 additions & 14 deletions mula/.ci/.env.test
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,33 @@ POSTGRES_PASSWORD=mysecretpassword

QUEUE_URI=amqp://guest:guest@ci_rabbitmq:5672/%2fkat

KATALOGUS_API=http://ci_katalogus:8000
OCTOPOES_API=http://octopoes_api:80
BYTES_API=http://ci_bytes:8000
SCHEDULER_API=http://ci_scheduler:8000

SCHEDULER_API_HOST="0.0.0.0"
SCHEDULER_API_PORT="8000"
SCHEDULER_PQ_MAXSIZE=0
SCHEDULER_PQ_POPULATE_INTERVAL=60
SCHEDULER_PQ_POPULATE_GRACE_PERIOD=1
SCHEDULER_DB_USER=postgres
SCHEDULER_DB_PASSWORD=mysecretpassword
SCHEDULER_DB=ci_scheduler
SCHEDULER_DB_USER=scheduler_app
SCHEDULER_DB_PASSWORD=${POSTGRES_PASSWORD}
SCHEDULER_DB=scheduler
SCHEDULER_DB_URI=postgresql://${SCHEDULER_DB_USER}:${SCHEDULER_DB_PASSWORD}@ci_postgres:5432/${SCHEDULER_DB}

KATALOGUS_API=http://ci_katalogus:8000
OCTOPOES_API=http://octopoes_api:80
BYTES_API=http://bytes:8000
SCHEDULER_API=http://scheduler:8000
KEIKO_API=http://keiko:8000

BYTES_API=http://ci_bytes:8000
BYTES_DB=bytes
BYTES_DB_USER=bytes_app
BYTES_DB_PASSWORD=${POSTGRES_PASSWORD}
BYTES_DB_URI=postgresql://${BYTES_DB_USER}:${BYTES_DB_PASSWORD}@ci_postgres:5432/${BYTES_DB}
BYTES_USERNAME=test
BYTES_PASSWORD=secret

BYTES_SECRET=3d54f6e4e65723aa678d17d8fd22aba5234136d3e44e5a77305dedaa8ce13f45
BYTES_ACCESS_TOKEN_EXPIRE_MINUTES=1000

BYTES_DB_URI=postgresql://${SCHEDULER_DB_USER}:${SCHEDULER_DB_PASSWORD}@ci_postgres:5432/ci_bytes
BYTES_LOG_FILE=/var/log/bytes-test.log
BYTES_FILE_PERMISSION=555

KATALOGUS_DB_URI=postgresql://postgres:postgres@ci_katalogus-db:5432/ci_katalogus
KATALOGUS_DB=katalogus
KATALOGUS_DB_USER=katalogus_app
KATALOGUS_DB_PASWORD=${POSTGRES_PASSWORD}
KATALOGUS_DB_URI=postgresql://${KATALOGUS_DB_USER}:${KATALOGUS_DB_PASSWORD}@ci_postgres:5432/${KATALOGUS_DB}
4 changes: 4 additions & 0 deletions mula/.ci/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ services:
retries: 5
env_file:
- .ci/.env.test
environment:
APPS: "BYTES KATALOGUS SCHEDULER"
volumes:
- ../init-user-db.sh:/docker-entrypoint-initdb.d/init-user-db.sh

ci_rabbitmq:
image: "rabbitmq:3.11-management"
Expand Down
13 changes: 4 additions & 9 deletions mula/scheduler/context/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from scheduler import storage
from scheduler.config import settings
from scheduler.connectors import services
from scheduler.utils import remove_trailing_slash


class AppContext:
Expand Down Expand Up @@ -42,20 +43,20 @@ def __init__(self) -> None:

# Services
katalogus_service = services.Katalogus(
host=self._remove_trailing_slash(str(self.config.host_katalogus)),
host=remove_trailing_slash(str(self.config.host_katalogus)),
source=f"scheduler/{scheduler.__version__}",
cache_ttl=self.config.katalogus_cache_ttl,
)

bytes_service = services.Bytes(
host=self._remove_trailing_slash(str(self.config.host_bytes)),
host=remove_trailing_slash(str(self.config.host_bytes)),
user=self.config.host_bytes_user,
password=self.config.host_bytes_password,
source=f"scheduler/{scheduler.__version__}",
)

octopoes_service = services.Octopoes(
host=self._remove_trailing_slash(str(self.config.host_octopoes)),
host=remove_trailing_slash(str(self.config.host_octopoes)),
source=f"scheduler/{scheduler.__version__}",
orgs=katalogus_service.get_organisations(),
timeout=self.config.octopoes_request_timeout,
Expand Down Expand Up @@ -110,9 +111,3 @@ def __init__(self) -> None:
registry=self.metrics_registry,
labelnames=["scheduler_id", "status"],
)

def _remove_trailing_slash(self, url: str) -> str:
"""Remove trailing slash from url."""
if url.endswith("/"):
return url[:-1]
return url
1 change: 1 addition & 0 deletions mula/scheduler/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from .datastore import GUID
from .dict_utils import ExpiredError, ExpiringDict, deep_get
from .functions import remove_trailing_slash
from .thread import ThreadRunner
5 changes: 5 additions & 0 deletions mula/scheduler/utils/functions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
def remove_trailing_slash(url: str) -> str:
"""Remove trailing slash from url."""
if url.endswith("/"):
return url[:-1]
return url
3 changes: 2 additions & 1 deletion mula/tests/integration/test_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

from scheduler import config
from scheduler.connectors import services
from scheduler.utils import remove_trailing_slash


class BytesTestCase(unittest.TestCase):
def setUp(self) -> None:
self.config = config.settings.Settings()
self.service_bytes = services.Bytes(
host=str(self.config.host_bytes),
host=remove_trailing_slash(str(self.config.host_bytes)),
user=self.config.host_bytes_user,
password=self.config.host_bytes_password,
source="scheduler_test",
Expand Down

0 comments on commit 1a8d354

Please sign in to comment.