Commit 515ee5d1 authored by Sergio Gonzalez Diaz's avatar Sergio Gonzalez Diaz
Browse files

add code coverage to L3 components

parent 3cd06d0b
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -21,6 +21,6 @@ include:
  - local: '/src/opticalcentralizedattackdetector/.gitlab-ci.yml'
  - local: '/src/automation/.gitlab-ci.yml'
  - local: '/src/webui/.gitlab-ci.yml'
  # - local: '/src/l3_distributedattackdetector/.gitlab-ci.yml'
  # - local: '/src/l3_centralizedattackdetector/.gitlab-ci.yml'
  # - local: '/src/l3_attackmitigator/.gitlab-ci.yml'
  - local: '/src/l3_distributedattackdetector/.gitlab-ci.yml'
  - local: '/src/l3_centralizedattackdetector/.gitlab-ci.yml'
  - local: '/src/l3_attackmitigator/.gitlab-ci.yml'
+10 −2
Original line number Diff line number Diff line
@@ -36,11 +36,14 @@ unit test l3_attackmitigator:
    - if docker container ls | grep $IMAGE_NAME; then docker rm -f $IMAGE_NAME; else echo "$IMAGE_NAME image is not in the system"; fi
  script:
    - docker pull "$CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG"
    - docker run --name $IMAGE_NAME -d -p 10002:10002 --network=teraflowbridge $CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG
    - docker run --name $IMAGE_NAME -d -p 10002:10002 -v "$PWD/src/$IMAGE_NAME/tests:/opt/results" --network=teraflowbridge $CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG
    - sleep 5
    - docker ps -a
    - docker logs $IMAGE_NAME
    - docker exec -i $IMAGE_NAME bash -c "pytest --log-level=DEBUG --verbose $IMAGE_NAME/tests/test_unitary.py"
    - 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 xml -o /opt/results/${IMAGE_NAME}_coverage.xml"
    - docker exec -i $IMAGE_NAME bash -c "coverage report --include='${IMAGE_NAME}/*' --show-missing"
  coverage: '/TOTAL\s+\d+\s+\d+\s+(\d+%)/'
  after_script:
    - docker rm -f $IMAGE_NAME
    - docker network rm teraflowbridge
@@ -54,6 +57,11 @@ unit test l3_attackmitigator:
      - src/$IMAGE_NAME/tests/Dockerfile
      - manifests/${IMAGE_NAME}service.yaml
      - .gitlab-ci.yml
  artifacts:
      when: always
      reports:
        junit: src/$IMAGE_NAME/tests/${IMAGE_NAME}_report.xml
        cobertura: src/$IMAGE_NAME/tests/${IMAGE_NAME}_coverage.xml

# Deployment of the service in Kubernetes Cluster
deploy l3_attackmitigator:
+1 −0
Original line number Diff line number Diff line
@@ -6,3 +6,4 @@ pytest
pytest-benchmark
numpy
scikit-learn
coverage
 No newline at end of file
+10 −2
Original line number Diff line number Diff line
@@ -36,11 +36,14 @@ unit test l3_centralizedattackdetector:
    - if docker container ls | grep $IMAGE_NAME; then docker rm -f $IMAGE_NAME; else echo "$IMAGE_NAME image is not in the system"; fi
  script:
    - docker pull "$CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG"
    - docker run --name $IMAGE_NAME -d -p 10001:10001 --network=teraflowbridge $CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG
    - docker run --name $IMAGE_NAME -d -p 10001:10001 -v "$PWD/src/$IMAGE_NAME/tests:/opt/results" --network=teraflowbridge $CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG
    - sleep 5
    - docker ps -a
    - docker logs $IMAGE_NAME
    - docker exec -i $IMAGE_NAME bash -c "pytest --log-level=DEBUG --verbose $IMAGE_NAME/tests/test_unitary.py"
    - 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 xml -o /opt/results/${IMAGE_NAME}_coverage.xml"
    - docker exec -i $IMAGE_NAME bash -c "coverage report --include='${IMAGE_NAME}/*' --show-missing"
  coverage: '/TOTAL\s+\d+\s+\d+\s+(\d+%)/'
  after_script:
    - docker rm -f $IMAGE_NAME
    - docker network rm teraflowbridge
@@ -54,6 +57,11 @@ unit test l3_centralizedattackdetector:
      - src/$IMAGE_NAME/tests/Dockerfile
      - manifests/${IMAGE_NAME}service.yaml
      - .gitlab-ci.yml
  artifacts:
      when: always
      reports:
        junit: src/$IMAGE_NAME/tests/${IMAGE_NAME}_report.xml
        cobertura: src/$IMAGE_NAME/tests/${IMAGE_NAME}_coverage.xml

# Deployment of the service in Kubernetes Cluster
deploy l3_centralizedattackdetector:
+1 −0
Original line number Diff line number Diff line
@@ -7,3 +7,4 @@ pytest-benchmark
numpy
scikit-learn
onnxruntime
coverage
 No newline at end of file
Loading