Commit 83d1d42a authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

Service component:

- added pathcomp to CI/CD unitary tests
parent 5e8130ad
Loading
Loading
Loading
Loading
+29 −1
Original line number Diff line number Diff line
@@ -46,20 +46,40 @@ unit test service:
  stage: unit_test
  needs:
    - build service
    - build pathcomp
  before_script:
    - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
    - if docker network list | grep teraflowbridge; then echo "teraflowbridge is already created"; else docker network create -d bridge teraflowbridge; fi
    - if docker network list | grep teraflowbridge; then echo "teraflowbridge is already created"; else docker network create --driver=bridge --subnet=172.28.0.0/24 --gateway=172.28.0.254 teraflowbridge; fi
    - if docker container ls | grep $IMAGE_NAME; then docker rm -f $IMAGE_NAME; else echo "$IMAGE_NAME image is not in the system"; fi
    - if docker container ls | grep pathcomp-frontend; then docker rm -f pathcomp-frontend; else echo "pathcomp-frontend image is not in the system"; fi
    - if docker container ls | grep pathcomp-backend; then docker rm -f pathcomp-backend; else echo "pathcomp-backend image is not in the system"; fi
  script:
    - docker pull "$CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG"
    - docker pull "$CI_REGISTRY_IMAGE/pathcomp-frontend:$IMAGE_TAG"
    - docker pull "$CI_REGISTRY_IMAGE/pathcomp-backend:$IMAGE_TAG"
    - docker run --name pathcomp-backend -d -p 8081:8081 --network=teraflowbridge --ip 172.28.0.1 $CI_REGISTRY_IMAGE/pathcomp-backend:$IMAGE_TAG
    - sleep 1
    - docker run --name pathcomp-frontend -d -p 10020:10020 --env "PATHCOMP_BACKEND_HOST=172.28.0.1" --env "PATHCOMP_BACKEND_PORT=8081" --network=teraflowbridge --ip 172.28.0.2 $CI_REGISTRY_IMAGE/pathcomp-frontend:$IMAGE_TAG
    - sleep 1
    - docker run --name $IMAGE_NAME -d -p 3030:3030 -v "$PWD/src/$IMAGE_NAME/tests:/opt/results" --network=teraflowbridge $CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG
    - sleep 5
    - docker ps -a
    - docker logs pathcomp-frontend
    - docker logs pathcomp-backend
    - docker logs $IMAGE_NAME
    - docker exec -i $IMAGE_NAME bash -c "coverage run -m pytest --log-level=INFO --verbose $IMAGE_NAME/tests/test_unitary.py --junitxml=/opt/results/${IMAGE_NAME}_report.xml"
    - docker exec -i $IMAGE_NAME bash -c "coverage report --include='${IMAGE_NAME}/*' --show-missing"
    - docker logs pathcomp-frontend
    - docker logs pathcomp-backend
    - docker logs $IMAGE_NAME
  coverage: '/TOTAL\s+\d+\s+\d+\s+(\d+%)/'
  after_script:
    - docker ps -a
    - docker logs pathcomp-frontend
    - docker logs pathcomp-backend
    - docker logs ${IMAGE_NAME}
    - docker rm -f pathcomp-frontend
    - docker rm -f pathcomp-backend
    - docker rm -f $IMAGE_NAME
    - docker network rm teraflowbridge
  rules:
@@ -72,7 +92,15 @@ unit test service:
      - src/$IMAGE_NAME/Dockerfile
      - src/$IMAGE_NAME/tests/*.py
      - src/$IMAGE_NAME/tests/Dockerfile
      - src/pathcomp/.gitlab-ci.yml
      - src/pathcomp/frontend/**/*.{py,in,yml}
      - src/pathcomp/frontend/Dockerfile
      - src/pathcomp/frontend/tests/*.py
      - src/pathcomp/backend/**/*.{c,h,conf}
      - src/pathcomp/backend/Makefile
      - src/pathcomp/backend/Dockerfile
      - manifests/${IMAGE_NAME}service.yaml
      - manifests/pathcompservice.yaml
      - .gitlab-ci.yml
  artifacts:
      when: always