Commit 3fcbe991 authored by Alberto Gonzalez Barneo's avatar Alberto Gonzalez Barneo
Browse files

Modified gitlab-ci.yml to autoexecute the qkd test creating at the beginning the mocked qkd nodes

parent 9b17d6a6
Loading
Loading
Loading
Loading
+27 −0
Original line number Diff line number Diff line
@@ -38,6 +38,30 @@ build device:
      - manifests/${IMAGE_NAME}service.yaml
      - .gitlab-ci.yml

# Start Mock QKD Nodes before unit testing
start_mock_nodes:
  stage: deploy
  script:
    - bash src/tests/tools/mock_qkd_nodes/start.sh &
    - sleep 10 # wait for nodes to spin up
  artifacts:
    paths:
      - mock_nodes.log
  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"'

# Prepare Scenario (Start NBI, mock services)
prepare_scenario:
  stage: deploy
  script:
    - pytest src/tests/qkd/unit/PrepareScenario.py
  needs:
    - start_mock_nodes
  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"'

# Apply unit test to the component
unit_test device:
  variables:
@@ -46,6 +70,8 @@ unit_test device:
  stage: unit_test
  needs:
    - build device
    - start_mock_nodes
    - prepare_scenario
  before_script:
    - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
    - >
@@ -68,6 +94,7 @@ unit_test device:
    - docker logs $IMAGE_NAME
    - docker exec -i $IMAGE_NAME bash -c "coverage run --append -m pytest --log-level=INFO --verbose $IMAGE_NAME/tests/test_unitary_emulated.py --junitxml=/opt/results/${IMAGE_NAME}_report_emulated.xml"
    - docker exec -i $IMAGE_NAME bash -c "coverage run --append -m pytest --log-level=INFO --verbose $IMAGE_NAME/tests/test_unitary_ietf_actn.py --junitxml=/opt/results/${IMAGE_NAME}_report_ietf_actn.xml"
    - docker exec -i $IMAGE_NAME bash -c "coverage run --append -m pytest --log-level=INFO --verbose $IMAGE_NAME/tests/qkd/unit/test_*.py"
    - docker exec -i $IMAGE_NAME bash -c "coverage report --include='${IMAGE_NAME}/*' --show-missing"
  coverage: '/TOTAL\s+\d+\s+\d+\s+(\d+%)/'
  after_script:
+1 −1
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@ import json, logging, uuid
from typing import Any, Dict, List, Optional, Tuple, Union
from common.method_wrappers.Decorator import MetricsPool, metered_subclass_method
from common.proto.context_pb2 import ConfigRule, DeviceId, Service
from common.proto.app_pb2 import App, QKDAppStatusEnum, QKDAppTypesEnum
from common.proto.qkd_app_pb2 import App, QKDAppStatusEnum, QKDAppTypesEnum
from common.tools.object_factory.ConfigRule import json_config_rule_delete, json_config_rule_set
from common.tools.object_factory.Device import json_device_id
from common.type_checkers.Checkers import chk_type