Skip to content

Commit

Permalink
add postgresql_telemetry_sink adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
Baptiste O'Jeanson committed Jan 30, 2023
1 parent c779ded commit b2be0c1
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 9 deletions.
11 changes: 10 additions & 1 deletion .github/workflows/ci_edge_orchestrator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ jobs:
image: mongo:5.0.2
ports:
- 27017:27017
hub_telemetry_db:
image: postgres:15.1
ports:
- 5432:5432
env:
POSTGRES_DB: test
POSTGRES_USER: test
POSTGRES_PASSWORD: test
edge_model_serving:
image: ghcr.io/octo-technology/vio/edge_model_serving:latest
ports:
Expand All @@ -33,7 +41,8 @@ jobs:
ports:
- 8502:8501
env:
DATABASE_CONNECTION_URL: mongodb://localhost:27017
MONGO_DB_URI: mongodb://localhost:27017
POSTGRES_DB_URI: postgresql://test:test@localhost:5432/test
TENSORFLOW_SERVING_HOST: localhost
TENSORFLOW_SERVING_PORT: 8501
TFLITE_SERVING_HOST: localhost
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ services:

hub_telemetry_db:
container_name: hub_telemetry_db
image: postgres
image: postgres:15.1
restart: always
environment:
POSTGRES_DB: vio
Expand Down
10 changes: 6 additions & 4 deletions edge_orchestrator/tests/fixtures/containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ def check_image_presence_or_pull_it_from_registry(image_name: str):
'password': os.environ.get('REGISTRY_PASSWORD')})


def start_test_db(image_name: str) -> Tuple[str, MongoDbContainer]:
connection_url = os.environ.get('DATABASE_CONNECTION_URL')
def start_test_db(image_name: str, db_connection_url: str) -> Tuple[str, MongoDbContainer]:
connection_url = os.environ.get(db_connection_url)
container = None
if connection_url is None:
check_image_presence_or_pull_it_from_registry(image_name)
Expand All @@ -54,7 +54,8 @@ def stop_test_container(container: DockerContainer):
@fixture(scope='session')
def setup_test_mongo_db() -> str:
image_name = EDGE_DB_IMG # noqa
connection_url, mongo_db_container = start_test_db(image_name=image_name)
connection_url, mongo_db_container = start_test_db(image_name=image_name,
db_connection_url=os.environ.get('MONGO_DB_URI'))
yield connection_url
stop_test_container(mongo_db_container)

Expand All @@ -69,7 +70,8 @@ def test_mongo_db_uri(setup_test_mongo_db) -> str:
@fixture(scope='session')
def setup_test_postgres_db() -> str:
image_name = TELEMETRY_DB_IMG # noqa
connection_url, postgres_db_container = start_test_db(image_name=image_name)
connection_url, postgres_db_container = start_test_db(image_name=image_name,
db_connection_url=os.environ.get('POSTGRES_DB_URI'))
apply_db_migrations(connection_url)
yield connection_url
stop_test_container(postgres_db_container)
Expand Down
11 changes: 8 additions & 3 deletions edge_orchestrator/tests/functional_tests/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,18 @@

from tests.conftest import ROOT_REPOSITORY_PATH, TEST_DATA_FOLDER_PATH, EDGE_DB_IMG, EDGE_MODEL_SERVING_IMG, \
TELEMETRY_DB_IMG
from tests.fixtures.containers import start_test_db, start_test_tf_serving, stop_test_container
from tests.fixtures.containers import start_test_db, start_test_tf_serving, stop_test_container, apply_db_migrations


def before_all(context: Context):
context.test_directory = Path(__file__).parent.parent
context.mongo_db_uri, context.mongo_db_container = start_test_db(image_name=EDGE_DB_IMG)
context.postgres_db_uri, context.postgres_db_container = start_test_db(image_name=TELEMETRY_DB_IMG)
context.mongo_db_uri, context.mongo_db_container = start_test_db(image_name=EDGE_DB_IMG,
db_connection_url=os.environ.get('MONGO_DB_URI'))
context.postgres_db_uri, context.postgres_db_container = start_test_db(image_name=TELEMETRY_DB_IMG,
db_connection_url=os.environ.get(
'POSTGRES_DB_URI'))
apply_db_migrations(context.postgres_db_uri)

context.tensorflow_serving_url, context.tensorflow_serving_container = start_test_tf_serving(
image_name=EDGE_MODEL_SERVING_IMG,
starting_log=r'Entering the event loop ...',
Expand Down

0 comments on commit b2be0c1

Please sign in to comment.