Loading src/monitoring/.gitlab-ci.yml +8 −1 Original line number Diff line number Diff line Loading @@ -62,6 +62,7 @@ test monitoring run: - docker ps after_script: - docker stop "$IMAGE_NAME" - docker network rm teraflowbridge rules: - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && ($CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "develop" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH)' - if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "develop"' Loading @@ -82,9 +83,15 @@ test monitoring pytest: stage: unit_test needs: - build monitoring before_script: - if docker network list | grep teraflowbridge; then echo "teraflowbridge is already created"; else docker network create -d bridge teraflowbridge; fi script: - docker run -p 8086:8086 -e INFLUXDB_DB=$INFLUXDB_DATABASE -e INFLUXDB_ADMIN_USER=$INFLUXDB_USER -e INFLUXDB_ADMIN_PASSWORD=$INFLUXDB_PASSWORD -e INXLUXDB_HTTP_AUTH_ENABLED=True --network=teraflowbridge --name influxdb-tests influxdb:1.8 - docker build -t "$IMAGE_NAME_TEST:$IMAGE_TAG" -f ./src/$IMAGE_NAME/tests/Dockerfile ./src/ - docker run -v "$PWD/src/$IMAGE_NAME/tests:/opt/results" $IMAGE_NAME_TEST:$IMAGE_TAG - docker run -v "$PWD/src/$IMAGE_NAME/tests:/opt/results" --build-arg user=$INFLUXDB_USER --build-arg pass=$INFLUXDB_PASSWORD --build-arg db=$INFLUXDB_DATABASE --network=teraflowbridge $IMAGE_NAME_TEST:$IMAGE_TAG after_script: - docker stop influxdb-tests - docker network rm teraflowbridge rules: - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && ($CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "develop" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH)' - if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "develop"' Loading src/monitoring/service/MonitoringServiceServicerImpl.py +2 −1 Original line number Diff line number Diff line Loading @@ -23,11 +23,12 @@ INFLUXDB_DB = os.environ.get("INFLUXDB_DATABASE") class MonitoringServiceServicerImpl(monitoring_pb2_grpc.MonitoringServiceServicer): def __init__(self): LOGGER.info('Init monitoringService') # Init sqlite monitoring db self.sql_db = sqlite_tools.SQLite('monitoring.db') # Create influx_db client self.influx_db = influx_tools.Influx("localhost","8086",INFLUXDB_USER,INFLUXDB_PASS,INFLUXDB_DB) self.influx_db = influx_tools.Influx("influxdb-tests","8086",INFLUXDB_USER,INFLUXDB_PASS,INFLUXDB_DB) # CreateKpi (CreateKpiRequest) returns (KpiId) {} def CreateKpi(self, request : monitoring_pb2.CreateKpiRequest, context) -> monitoring_pb2.KpiId : Loading src/monitoring/tests/Dockerfile +8 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,14 @@ RUN python3 -m pip install -r requirements.txt COPY monitoring/. monitoring COPY common/logger.py common # define variables for the influxdb ARG user ARG pass ARG db ENV INFLUXDB_USER=$user ENV INFLUXDB_PASSWORD=$pass ENV INFLUXDB_DATABASE=$db # set listen port ENV PORT=7070 EXPOSE 7070 Loading Loading
src/monitoring/.gitlab-ci.yml +8 −1 Original line number Diff line number Diff line Loading @@ -62,6 +62,7 @@ test monitoring run: - docker ps after_script: - docker stop "$IMAGE_NAME" - docker network rm teraflowbridge rules: - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && ($CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "develop" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH)' - if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "develop"' Loading @@ -82,9 +83,15 @@ test monitoring pytest: stage: unit_test needs: - build monitoring before_script: - if docker network list | grep teraflowbridge; then echo "teraflowbridge is already created"; else docker network create -d bridge teraflowbridge; fi script: - docker run -p 8086:8086 -e INFLUXDB_DB=$INFLUXDB_DATABASE -e INFLUXDB_ADMIN_USER=$INFLUXDB_USER -e INFLUXDB_ADMIN_PASSWORD=$INFLUXDB_PASSWORD -e INXLUXDB_HTTP_AUTH_ENABLED=True --network=teraflowbridge --name influxdb-tests influxdb:1.8 - docker build -t "$IMAGE_NAME_TEST:$IMAGE_TAG" -f ./src/$IMAGE_NAME/tests/Dockerfile ./src/ - docker run -v "$PWD/src/$IMAGE_NAME/tests:/opt/results" $IMAGE_NAME_TEST:$IMAGE_TAG - docker run -v "$PWD/src/$IMAGE_NAME/tests:/opt/results" --build-arg user=$INFLUXDB_USER --build-arg pass=$INFLUXDB_PASSWORD --build-arg db=$INFLUXDB_DATABASE --network=teraflowbridge $IMAGE_NAME_TEST:$IMAGE_TAG after_script: - docker stop influxdb-tests - docker network rm teraflowbridge rules: - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && ($CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "develop" || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH)' - if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "develop"' Loading
src/monitoring/service/MonitoringServiceServicerImpl.py +2 −1 Original line number Diff line number Diff line Loading @@ -23,11 +23,12 @@ INFLUXDB_DB = os.environ.get("INFLUXDB_DATABASE") class MonitoringServiceServicerImpl(monitoring_pb2_grpc.MonitoringServiceServicer): def __init__(self): LOGGER.info('Init monitoringService') # Init sqlite monitoring db self.sql_db = sqlite_tools.SQLite('monitoring.db') # Create influx_db client self.influx_db = influx_tools.Influx("localhost","8086",INFLUXDB_USER,INFLUXDB_PASS,INFLUXDB_DB) self.influx_db = influx_tools.Influx("influxdb-tests","8086",INFLUXDB_USER,INFLUXDB_PASS,INFLUXDB_DB) # CreateKpi (CreateKpiRequest) returns (KpiId) {} def CreateKpi(self, request : monitoring_pb2.CreateKpiRequest, context) -> monitoring_pb2.KpiId : Loading
src/monitoring/tests/Dockerfile +8 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,14 @@ RUN python3 -m pip install -r requirements.txt COPY monitoring/. monitoring COPY common/logger.py common # define variables for the influxdb ARG user ARG pass ARG db ENV INFLUXDB_USER=$user ENV INFLUXDB_PASSWORD=$pass ENV INFLUXDB_DATABASE=$db # set listen port ENV PORT=7070 EXPOSE 7070 Loading