Commit cc236462 authored by Javi Moreno's avatar Javi Moreno
Browse files

Changes in the unit test automation

parent ac587367
Loading
Loading
Loading
Loading
+12 −16
Original line number Diff line number Diff line
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
+1 −1
Original line number Diff line number Diff line
@@ -27,4 +27,4 @@ COPY common/logger.py .
ENV PORT=7070
EXPOSE 7070

RUN pytest
RUN pytest --junitxml=report.xml