Commit 25babf95 authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

Merge branch 'feat/195-opt-integrate-qkd-tests-in-tfs-ci-cd-pipeline' into 'develop'

Resolve "(OPT) Integrate QKD tests in TFS CI/CD pipeline"

See merge request !268
parents 459c6f14 5d2d4546
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -669,6 +669,10 @@ if [[ "$TFS_COMPONENTS" == *"monitoring"* ]] && [[ "$TFS_COMPONENTS" == *"webui"
    printf "\n\n"
fi

echo "Pruning Docker Images..."
docker image prune --force
printf "\n\n"

if [ "$DOCKER_BUILD" == "docker buildx build" ]; then
    echo "Pruning Docker Buildx Cache..."
    docker buildx prune --force
+3 −3
Original line number Diff line number Diff line
@@ -63,9 +63,9 @@ spec:
                port:
                  number: 8080
          - path: /()(qkd_app/.*)
          - pathType: Prefix
            pathType: Prefix
            backend:
              service:
                name: qkdappservice
                name: qkd-appservice
                port:
                  number: 8005
+7 −9
Original line number Diff line number Diff line
@@ -15,16 +15,16 @@
apiVersion: apps/v1
kind: Deployment
metadata:
  name: qkdappservice
  name: qkd-appservice
spec:
  selector:
    matchLabels:
      app: qkdappservice
      app: qkd-appservice
  #replicas: 1
  template:
    metadata:
      labels:
        app: qkdappservice
        app: qkd-appservice
    spec:
      terminationGracePeriodSeconds: 5
      containers:
@@ -36,10 +36,8 @@ spec:
        - containerPort: 9192
        - containerPort: 8005
        env:
        - name: MB_BACKEND
          value: "nats"
        - name: LOG_LEVEL
          value: "INFO"
          value: "DEBUG"
        - name: CRDB_DATABASE_APP
          value: "qkd_app"
        envFrom:
@@ -64,13 +62,13 @@ spec:
apiVersion: v1
kind: Service
metadata:
  name: qkdappservice
  name: qkd-appservice
  labels:
    app: qkdappservice
    app: qkd-appservice
spec:
  type: ClusterIP
  selector:
    app: qkdappservice
    app: qkd-appservice
  ports:
  - name: grpc
    protocol: TCP
+27 −0
Original line number Diff line number Diff line
#!/bin/bash
# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

########################################################################################################################
# Define your deployment settings here
########################################################################################################################

# If not already set, set the name of the Kubernetes namespace to deploy to.
export TFS_K8S_NAMESPACE=${TFS_K8S_NAMESPACE:-"tfs"}

########################################################################################################################
# Automated steps start here
########################################################################################################################

kubectl --namespace $TFS_K8S_NAMESPACE logs deployment/qkd-appservice -c server
+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:
Loading