Commit 835a8e7a authored by Shayan Hajipour's avatar Shayan Hajipour
Browse files

feat:ofc25 camara e2e test added

parent d83a80d7
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
clab-*/
images/
*.clab.yml.bak
*.tar
*.tar.gz
+121 −0
Original line number Diff line number Diff line
# Copyright 2022-2025 ETSI 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.

# Build, tag, and push the Docker images to the GitLab Docker registry
build ofc25:
  variables:
    TEST_NAME: 'ofc25'
    NCE_NAME: 'nce'
    AGG_NET_NAME: 'agg_net'
    NCE_PORT: '9090'
    AGG_NET_PORT: '9091'
  stage: build
  before_script:
    - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
  script:
    - HOST_IP=$(kubectl get nodes -o json | jq -r '.items[].status.addresses[] | select(.type=="InternalIP") | .address')
    - sed -i "s/AGG_NET_IP/${HOST_IP}/g" src/tests/${TEST_NAME}/data/camara-e2e-topology.json
    - sed -i "s/NCE_IP/${HOST_IP}/g" src/tests/${TEST_NAME}/data/camara-e2e-topology.json
    - sed -i "s/AGG_NET_PORT/${AGG_NET_PORT}/g" src/tests/${TEST_NAME}/data/camara-e2e-topology.json
    - sed -i "s/NCE_PORT/${NCE_PORT}/g" src/tests/${TEST_NAME}/data/camara-e2e-topology.json
    - docker buildx build -t "${TEST_NAME}:latest" -f ./src/tests/${TEST_NAME}/Dockerfile .
    - docker tag "${TEST_NAME}:latest" "$CI_REGISTRY_IMAGE/${TEST_NAME}:latest"
    - docker push "$CI_REGISTRY_IMAGE/${TEST_NAME}:latest"
    - docker buildx build -t "${NCE_NAME}:latest" -f ./src/tests/tools/mock_nce_ctrl/Dockerfile .
    - docker tag "${NCE_NAME}:latest" "$CI_REGISTRY_IMAGE/${NCE_NAME}:latest"
    - docker push "$CI_REGISTRY_IMAGE/${NCE_NAME}:latest"
    - docker buildx build -t "${AGG_NET_NAME}:latest" -f ./src/tests/tools/mock_ietf_network_slice_sdn_ctrl/Dockerfile .
    - docker tag "${AGG_NET_NAME}:latest" "$CI_REGISTRY_IMAGE/${AGG_NET_NAME}:latest"
    - docker push "$CI_REGISTRY_IMAGE/${AGG_NET_NAME}:latest"
  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_test ofc25:
  variables:
    TEST_NAME: 'ofc25'
    NCE_NAME: 'nce'
    AGG_NET_NAME: 'agg_net'
    NCE_PORT: '9090'
    AGG_NET_PORT: '9091'
  stage: end2end_test
  # Disable to force running it after all other tasks
  before_script:
    - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
    - docker rm -f ${TEST_NAME} || true
    - docker pull "${CI_REGISTRY_IMAGE}/${NCE_NAME}:latest"
    - docker run -d --name ${NCE_NAME} -p ${NCE_PORT}:8443 $CI_REGISTRY_IMAGE/${NCE_NAME}:latest
    - docker pull "${CI_REGISTRY_IMAGE}/${AGG_NET_NAME}:latest"
    - docker run -d --name ${AGG_NET_NAME} -p ${AGG_NET_PORT}:8443 $CI_REGISTRY_IMAGE/${AGG_NET_NAME}:latest

  script:
    # Download Docker image to run the test
    - docker pull "${CI_REGISTRY_IMAGE}/${TEST_NAME}:latest"

    # Check MicroK8s is ready
    - microk8s status --wait-ready
    - kubectl get pods --all-namespaces

    - source src/tests/${TEST_NAME}/deploy_specs.sh

    # Deploy TeraFlowSDN
    - ./deploy/crdb.sh
    - ./deploy/nats.sh
    - ./deploy/qdb.sh
    - ./deploy/kafka.sh
    - ./deploy/tfs.sh
    - ./deploy/show.sh

    - kubectl --namespace $TFS_K8S_NAMESPACE logs deployment/contextservice -c server

    # Run end-to-end test: onboard scenario
    - >
      docker run -t --rm --name ${TEST_NAME} --network=host
      $CI_REGISTRY_IMAGE/${TEST_NAME}:latest /var/teraflow/run-onboarding.sh

    # Run end-to-end test: configure service TFS
    - >
      docker run -t --rm --name ${TEST_NAME} --network=host
      $CI_REGISTRY_IMAGE/${TEST_NAME}:latest /var/teraflow/run-e2e-ietf-slice-operations.sh

  after_script:
    - kubectl --namespace tfs logs deployment/contextservice -c server
    - kubectl --namespace tfs logs deployment/deviceservice -c server
    - kubectl --namespace tfs logs deployment/pathcompservice -c frontend
    - kubectl --namespace tfs logs deployment/serviceservice -c server
    - kubectl --namespace tfs logs deployment/nbiservice -c server

    # Destroy Scenario
    - kubectl delete namespaces tfs || true

    # Clean old docker images
    - docker images --filter="dangling=true" --quiet | xargs -r docker rmi

  #coverage: '/TOTAL\s+\d+\s+\d+\s+(\d+%)/'
  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"'
  artifacts:
      when: always
      reports:
        junit: ./src/tests/${TEST_NAME}/report_*.xml
+71 −0
Original line number Diff line number Diff line
# Copyright 2022-2024 ETSI 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.

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

# 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/ofc25
WORKDIR /var/teraflow/tests/ofc25
COPY src/tests/ofc25/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
COPY src/__init__.py ./__init__.py
COPY src/tests/*.py ./tests/
COPY src/tests/ofc25/__init__.py ./tests/ofc25/__init__.py
COPY src/tests/ofc25/data/. ./tests/ofc25/data/
COPY src/tests/ofc25/tests/. ./tests/ofc25/tests/
COPY src/tests/ofc25/scripts/. ./

RUN apt-get --yes --quiet --quiet update && \
    apt-get --yes --quiet --quiet install tree && \
    rm -rf /var/lib/apt/lists/*

RUN tree -la /var/teraflow
+97 −0
Original line number Diff line number Diff line
# DataPlane-in-a-Box - Control an Emulated DataPlane through TeraFlowSDN

## Emulated DataPlane Deployment
- Scenario
- Descriptor

## TeraFlowSDN Deployment
```bash
cd ~/tfs-ctrl
source ~/tfs-ctrl/src/tests/ofc25/deploy_specs.sh
./deploy/all.sh
```

## Deploy scenario
```bash
cd ~/tfs-ctrl/src/tests/ofc25/
sudo containerlab deploy --topo eucnc24.clab.yml
```

## Inspect scenario
```bash
cd ~/tfs-ctrl/src/tests/eucnc24/
sudo containerlab inspect --topo eucnc24.clab.yml
```

## Destroy scenario
```bash
cd ~/tfs-ctrl/src/tests/eucnc24/
sudo containerlab destroy --topo eucnc24.clab.yml
sudo rm -rf clab-eucnc24/ .eucnc24.clab.yml.bak
```

## Access cEOS Bash/CLI
```bash
docker exec -it clab-eucnc24-r1 bash
docker exec -it clab-eucnc24-r2 bash
docker exec -it clab-eucnc24-r3 bash
docker exec -it clab-eucnc24-r1 Cli
docker exec -it clab-eucnc24-r2 Cli
docker exec -it clab-eucnc24-r3 Cli
```

## Configure ContainerLab clients
```bash
docker exec -it clab-eucnc24-dc1 bash
    ip address add 172.16.1.10/24 dev eth1
    ip route add 172.16.2.0/24 via 172.16.1.1
    ping 172.16.2.10

docker exec -it clab-eucnc24-dc2 bash
    ip address add 172.16.2.10/24 dev eth1
    ip route add 172.16.1.0/24 via 172.16.2.1
    ping 172.16.1.10
```

## Install gNMIc
```bash
sudo bash -c "$(curl -sL https://get-gnmic.kmrd.dev)"
```

## gNMI Capabilities request
```bash
gnmic --address clab-eucnc24-r1 --port 6030 --username admin --password admin --insecure capabilities
```

## gNMI Get request
```bash
gnmic --address clab-eucnc24-r1 --port 6030 --username admin --password admin --insecure --encoding json_ietf get --path / > r1.json
gnmic --address clab-eucnc24-r1 --port 6030 --username admin --password admin --insecure --encoding json_ietf get --path /interfaces/interface > r1-ifaces.json
```

## gNMI Set request
```bash
gnmic --address clab-eucnc24-r1 --port 6030 --username admin --password admin --insecure --encoding json_ietf set --update-path /system/config/hostname --update-value srl11
gnmic --address clab-eucnc24-r1 --port 6030 --username admin --password admin --insecure --encoding json_ietf get --path /system/config/hostname
```

## Subscribe request
```bash
gnmic --address clab-eucnc24-r1 --port 6030 --username admin --password admin --insecure --encoding json_ietf subscribe --path /interfaces/interface[name=Management0]/state/

# In another terminal, you can generate traffic opening SSH connection
ssh admin@clab-eucnc24-r1
```

# Check configurations done:
```bash
gnmic --address clab-eucnc24-r1 --port 6030 --username admin --password admin --insecure --encoding json_ietf get --path '/network-instances' > r1-nis.json
gnmic --address clab-eucnc24-r1 --port 6030 --username admin --password admin --insecure --encoding json_ietf get --path '/interfaces' > r1-ifs.json
```

# Delete elements:
```bash
--address clab-eucnc24-r1 --port 6030 --username admin --password admin --insecure --encoding json_ietf set --delete '/network-instances/network-instance[name=b19229e8]'
--address clab-eucnc24-r1 --port 6030 --username admin --password admin --insecure --encoding json_ietf set --delete '/interfaces/interface[name=ethernet-1/1]/subinterfaces/subinterface[index=0]'
--address clab-eucnc24-r1 --port 6030 --username admin --password admin --insecure --encoding json_ietf set --delete '/interfaces/interface[name=ethernet-1/2]/subinterfaces/subinterface[index=0]'
```
+14 −0
Original line number Diff line number Diff line
# Copyright 2022-2025 ETSI 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.
Loading