Commit e66ac057 authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

Tests - Tools - SIMAP Server

- Implemented first functional version of a minimalistic SIMAP server
parent f7ad3fb2
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -30,3 +30,4 @@ include:
  - local: '/src/tests/tools/mock_tfs_nbi_dependencies/.gitlab-ci.yml'
  - local: '/src/tests/tools/mock_qkd_node/.gitlab-ci.yml'
  - local: '/src/tests/tools/mock_osm_nbi/.gitlab-ci.yml'
  - local: '/src/tests/tools/simap_server/.gitlab-ci.yml'
+41 −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 image to the GitLab Docker registry
build simap_server:
  stage: build
  before_script:
    - docker image prune --force
    - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
  script:
    - docker buildx build -t "$CI_REGISTRY_IMAGE/simap-server:test" -f ./src/tests/tools/simap_server/Dockerfile ./src/tests/tools/simap_server
    - docker push "$CI_REGISTRY_IMAGE/simap-server:test"
  after_script:
    - docker image prune --force
  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/src/tests/tools/simap_server/**/*.{py,in,yml,yaml,yang,sh,json}
      - src/src/tests/tools/simap_server/Dockerfile
      - src/src/tests/.gitlab-ci.yml
      #- src/device/**/*.{py,in,yml}
      #- src/device/Dockerfile
      #- src/device/tests/*.py
      #- src/qkd_app/**/*.{py,in,yml}
      #- src/qkd_app/Dockerfile
      #- src/qkd_app/tests/*.py
      - .gitlab-ci.yml
+34 −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.

FROM python:3.9-slim

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

# Get Python dependencies
RUN python3 -m pip install --upgrade pip
RUN python3 -m pip install --upgrade setuptools wheel
RUN python3 -m pip install https://github.com/freeconf/lang/releases/download/v0.1.0-alpha/freeconf-0.1.0-py3-none-any.whl
RUN fc-lang-install -v

# Create component sub-folders, and copy content
RUN mkdir -p /var/simap_server/
WORKDIR /var/simap_server
COPY ./yang ./yang
COPY ./startup.json ./startup.json
COPY ./*.py .

# Start the service
ENTRYPOINT ["python", "simap_server.py"]
+34 −0
Original line number Diff line number Diff line
# Mock QKD Node

This Mock implements very basic support for the software-defined QKD node information models specified in ETSI GS QKD 015 V2.1.1.

The aim of this mock is to enable testing the TFS QKD Framework with an emulated data plane.


## Build the Mock QKD Node Docker image
```bash
./build.sh
```

## Run the Mock QKD Node as a container:
```bash
docker network create --driver bridge --subnet=172.254.252.0/24 --gateway=172.254.252.254 tfs-qkd-net-mgmt

docker run --name qkd-node-01 --detach --publish 80:80 \
  --network=tfs-qkd-net-mgmt --ip=172.254.252.101 \
  --env "DATA_FILE_PATH=/var/teraflow/mock-qkd-node/data/database.json" \
  --volume "$PWD/src/tests/mock-qkd-node/data/database-01.json:/var/teraflow/mock-qkd-node/data/database.json" \
  mock-qkd-node:test

docker run --name qkd-node-02 --detach --publish 80:80 \
  --network=tfs-qkd-net-mgmt --ip=172.254.252.102 \
  --env "DATA_FILE_PATH=/var/teraflow/mock-qkd-node/data/database.json" \
  --volume "$PWD/src/tests/mock-qkd-node/data/database-02.json:/var/teraflow/mock-qkd-node/data/database.json" \
  mock-qkd-node:test

docker run --name qkd-node-03 --detach --publish 80:80 \
  --network=tfs-qkd-net-mgmt --ip=172.254.252.103 \
  --env "DATA_FILE_PATH=/var/teraflow/mock-qkd-node/data/database.json" \
  --volume "$PWD/src/tests/mock-qkd-node/data/database-03.json:/var/teraflow/mock-qkd-node/data/database.json" \
  mock-qkd-node:test
```
+21 −0
Original line number Diff line number Diff line
#!/bin/bash
# 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.

# Make folder containing the script the root folder for its execution
cd $(dirname $0)

docker buildx build -t simap-server:test -f Dockerfile .
#docker tag simap-server:test localhost:32000/tfs/simap-server:test
#docker push localhost:32000/tfs/simap-server:test
Loading