From cc236462218363ea0b0571a1f8a11a3262861485 Mon Sep 17 00:00:00 2001 From: Javi Moreno Date: Mon, 26 Jul 2021 04:37:55 -0400 Subject: [PATCH] Changes in the unit test automation --- src/monitoring/.gitlab-ci.yml | 28 ++++++++++++---------------- src/monitoring/tests/Dockerfile | 2 +- 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/src/monitoring/.gitlab-ci.yml b/src/monitoring/.gitlab-ci.yml index 4cf564398..3e11772b0 100644 --- a/src/monitoring/.gitlab-ci.yml +++ b/src/monitoring/.gitlab-ci.yml @@ -1,5 +1,6 @@ variables: IMAGE_NAME: 'monitoring' # name of the microservice + IMAGE_NAME_TEST: 'monitoring-test' # name of the microservice IMAGE_TAG: 'latest' # tag of the container image (production, development, etc) # build the Docker image @@ -12,15 +13,6 @@ build monitoring: - src/$IMAGE_NAME/** - .gitlab-ci.yml -build monitoring test: - stage: build - script: - - docker build -t "$IMAGE_NAME:$IMAGE_TAG" -f ./src/$IMAGE_NAME/tests/Dockerfile ./src/ - rules: - - changes: - - src/$IMAGE_NAME/** - - .gitlab-ci.yml - # tags the Docker image tag monitoring: stage: build @@ -84,11 +76,15 @@ test monitoring run: test monitoring pytest: stage: test needs: - - build monitoring test - before_script: - - if docker network list | grep teraflowbridge; then echo "teraflowbridge is already created"; else docker network create -d bridge teraflowbridge; fi + - build monitoring script: - - docker run -d -p 7070:7070 --name monitoring-tests --network=teraflowbridge --rm "$IMAGE_NAME:$IMAGE_TAG" - after_script: - - docker stop monitoring-tests - + - docker build -t "$IMAGE_NAME_TEST:$IMAGE_TAG" -f ./src/$IMAGE_NAME_TEST/tests/Dockerfile ./src/ > pytest_report.txt + rules: + - changes: + - src/$IMAGE_NAME/** + - .gitlab-ci.yml + artifacts: + when: always + paths: + - pytest_report.txt + expire_in: 1 day \ No newline at end of file diff --git a/src/monitoring/tests/Dockerfile b/src/monitoring/tests/Dockerfile index b95389cb6..ca0dd15a6 100644 --- a/src/monitoring/tests/Dockerfile +++ b/src/monitoring/tests/Dockerfile @@ -27,4 +27,4 @@ COPY common/logger.py . ENV PORT=7070 EXPOSE 7070 -RUN pytest +RUN pytest --junitxml=report.xml -- GitLab