Commit 42edfa81 authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

CI/CD pipeline:

- Deactivating ECOC'22 test
- Fixed execution of OFC'22 tests
parent 9b69d5e3
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@
include:
  - local: '/src/tests/ofc22/.gitlab-ci.yml'
  #- local: '/src/tests/oeccpsc22/.gitlab-ci.yml'
  - local: '/src/tests/ecoc22/.gitlab-ci.yml'
  #- local: '/src/tests/ecoc22/.gitlab-ci.yml'
  #- local: '/src/tests/nfvsdn22/.gitlab-ci.yml'
  #- local: '/src/tests/ofc23/.gitlab-ci.yml'
  #- local: '/src/tests/ofc24/.gitlab-ci.yml'
+40 −7
Original line number Diff line number Diff line
@@ -13,6 +13,30 @@
# limitations under the License.

# Build, tag, and push the Docker image to the GitLab Docker registry
build end2end:
  variables:
    TEST_NAME: 'end2end'
    IMAGE_TAG: 'latest'
  stage: build
  before_script:
    - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
  script:
    - docker build -t "${TEST_NAME}:$IMAGE_TAG" -f ./src/tests/${TEST_NAME}/Dockerfile .
    - docker tag "${TEST_NAME}:$IMAGE_TAG" "$CI_REGISTRY_IMAGE/${TEST_NAME}:$IMAGE_TAG"
    - docker push "$CI_REGISTRY_IMAGE/${TEST_NAME}:$IMAGE_TAG"
  after_script:
    - docker images --filter="dangling=true" --quiet | xargs -r docker rmi
  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"'
    - changes:
      - src/common/**/*.py
      - proto/*.proto
      - src/tests/${TEST_NAME}/**/*.{py,in,sh,yml}
      - src/tests/${TEST_NAME}/Dockerfile
      - .gitlab-ci.yml

# Deploy TeraFlowSDN and Execute end-2-end test
end2end ofc22:
  variables:
    TEST_NAME: 'ofc22'
@@ -20,24 +44,33 @@ end2end ofc22:
  before_script:
    - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
  script:
    # Configure TeraFlowSDN deployment
    - source src/tests/${TEST_NAME}/deploy_specs.sh
    - export TFS_REGISTRY_IMAGES="labs.etsi.org:5050/tfs/controller"
    - export TFS_SKIP_BUILD="YES"
    - export TFS_IMAGE_TAG="latest"

    # Deploy TeraFlowSDN
    - ./deploy/crdb.sh
    - ./deploy/nats.sh
    - ./deploy/qdb.sh
    - ./deploy/expose_dashboard.sh
    - ./deploy/tfs.sh
    - ./deploy/show.sh
    
    # Wait for Context to be subscribed to NATS
    - while ! kubectl --namespace $TFS_K8S_NAMESPACE logs deployment/contextservice -c server 2>&1 | grep -q 'Subscriber is Ready? True'; do sleep 1; done
    - kubectl --namespace $TFS_K8S_NAMESPACE logs deployment/contextservice -c server
    # Run the tests
    - source tfs_runtime_env_vars.sh
    - pytest --verbose --log-level=INFO ./src/tests/${TEST_NAME}/tests/test_functional_bootstrap.py --junitxml=./src/tests/${TEST_NAME}/report_bootstrap.xml
    - pytest --verbose --log-level=INFO ./src/tests/${TEST_NAME}/tests/test_functional_create_service.py --junitxml=./src/tests/${TEST_NAME}/report_create_service.xml
    - pytest --verbose --log-level=INFO ./src/tests/${TEST_NAME}/tests/test_functional_delete_service.py --junitxml=./src/tests/${TEST_NAME}/report_delete_service.xml
    - pytest --verbose --log-level=INFO ./src/tests/${TEST_NAME}/tests/test_functional_cleanup.py --junitxml=./src/tests/${TEST_NAME}/report_cleanup.xml

    # Run end-to-end tests
    - docker create --name ${TEST_NAME} -d -v "$PWD/src/tests/${TEST_NAME}/tests:/opt/results" $CI_REGISTRY_IMAGE/${TEST_NAME}:$IMAGE_TAG ./run_tests.sh
    - docker cp ./tfs_runtime_env_vars.sh ${TEST_NAME}:/var/teraflow/tests/${TEST_NAME}
    - docker start
    #- source tfs_runtime_env_vars.sh
    #- pytest --verbose --log-level=INFO ./src/tests/${TEST_NAME}/tests/test_functional_bootstrap.py --junitxml=./src/tests/${TEST_NAME}/report_bootstrap.xml
    #- pytest --verbose --log-level=INFO ./src/tests/${TEST_NAME}/tests/test_functional_create_service.py --junitxml=./src/tests/${TEST_NAME}/report_create_service.xml
    #- pytest --verbose --log-level=INFO ./src/tests/${TEST_NAME}/tests/test_functional_delete_service.py --junitxml=./src/tests/${TEST_NAME}/report_delete_service.xml
    #- pytest --verbose --log-level=INFO ./src/tests/${TEST_NAME}/tests/test_functional_cleanup.py --junitxml=./src/tests/${TEST_NAME}/report_cleanup.xml
  after_script:
    - docker images --filter="dangling=true" --quiet | xargs -r docker rmi
  #coverage: '/TOTAL\s+\d+\s+\d+\s+(\d+%)/'
@@ -47,4 +80,4 @@ end2end ofc22:
  artifacts:
      when: always
      reports:
        junit: ./src/tests/${TEST_NAME}/report*.xml
        junit: ./src/tests/${TEST_NAME}/report_*.xml
+68 −0
Original line number Diff line number Diff line
# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (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.

FROM python:3.9-slim

# Install dependencies
RUN apt-get --yes --quiet --quiet update && \
    apt-get --yes --quiet --quiet install wget g++ git && \
    rm -rf /var/lib/apt/lists/*

# Set Python to show logs as they occur
ENV PYTHONUNBUFFERED=0

# Download the gRPC health probe
RUN GRPC_HEALTH_PROBE_VERSION=v0.2.0 && \
    wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-amd64 && \
    chmod +x /bin/grpc_health_probe

# Get generic Python packages
RUN python3 -m pip install --upgrade pip
RUN python3 -m pip install --upgrade setuptools wheel
RUN python3 -m pip install --upgrade pip-tools

# Get common Python packages
# Note: this step enables sharing the previous Docker build steps among all the Python components
WORKDIR /var/teraflow
COPY common_requirements.in common_requirements.in
RUN pip-compile --quiet --output-file=common_requirements.txt common_requirements.in
RUN python3 -m pip install -r common_requirements.txt

# Add common files into working directory
WORKDIR /var/teraflow/common
COPY src/common/. ./
RUN rm -rf proto

# Create proto sub-folder, copy .proto files, and generate Python code
RUN mkdir -p /var/teraflow/common/proto
WORKDIR /var/teraflow/common/proto
RUN touch __init__.py
COPY proto/*.proto ./
RUN python3 -m grpc_tools.protoc -I=. --python_out=. --grpc_python_out=. *.proto
RUN rm *.proto
RUN find . -type f -exec sed -i -E 's/(import\ .*)_pb2/from . \1_pb2/g' {} \;

# Create component sub-folders, get specific Python packages
RUN mkdir -p /var/teraflow/tests/ofc22
WORKDIR /var/teraflow/tests/ofc22
COPY src/tests/ofc22/requirements.in requirements.in
RUN pip-compile --quiet --output-file=requirements.txt requirements.in
RUN python3 -m pip install -r requirements.txt

# Add component files into working directory
WORKDIR /var/teraflow/tests/ofc22
COPY src/tests/ofc22/tests/. ./tests/
COPY src/tests/ofc22/__init__.py __init__.py
COPY src/tests/ofc22/descriptors_emulated.json descriptors_emulated.json
COPY src/tests/ofc22/run_tests.sh run_tests.sh
+15 −0
Original line number Diff line number Diff line
# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (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.

requests==2.27.*
+4 −4
Original line number Diff line number Diff line
@@ -15,7 +15,7 @@

# Run functional tests
source tfs_runtime_env_vars.sh
pytest --verbose --log-level=INFO src/tests/ofc22/tests/test_functional_bootstrap.py
pytest --verbose --log-level=INFO src/tests/ofc22/tests/test_functional_create_service.py
pytest --verbose --log-level=INFO src/tests/ofc22/tests/test_functional_delete_service.py
pytest --verbose --log-level=INFO src/tests/ofc22/tests/test_functional_cleanup.py
pytest --verbose --log-level=INFO ./src/tests/ofc22/tests/test_functional_bootstrap.py      --junitxml=/opt/results/report_bootstrap.xml
pytest --verbose --log-level=INFO ./src/tests/ofc22/tests/test_functional_create_service.py --junitxml=/opt/results/report_create_service.xml
pytest --verbose --log-level=INFO ./src/tests/ofc22/tests/test_functional_delete_service.py --junitxml=/opt/results/report_delete_service.xml
pytest --verbose --log-level=INFO ./src/tests/ofc22/tests/test_functional_cleanup.py        --junitxml=/opt/results/report_cleanup.xml