From 4a078db2eb09acdece139f5a4429952eb6fe8895 Mon Sep 17 00:00:00 2001 From: velazquez Date: Tue, 4 Aug 2026 13:50:53 +0200 Subject: [PATCH 1/2] Script to run tests locally --- scripts/run_tests.sh | 90 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 scripts/run_tests.sh diff --git a/scripts/run_tests.sh b/scripts/run_tests.sh new file mode 100644 index 0000000..ad501bd --- /dev/null +++ b/scripts/run_tests.sh @@ -0,0 +1,90 @@ +#!/bin/bash +# Copyright 2022-2026 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. + +# This file includes contributions from Telefonica Innovación Digital S.L. + +IMAGE_NAME="nsc-test" +IMAGE_TAG="local-test" + +# Get project root directory +PROJECTDIR=$(pwd) + +echo "=========================================" +echo " Starting Local Unit Tests & Coverage" +echo "=========================================" + +# 1. Clean up old test containers +echo "" +echo "Cleaning up any old test containers..." +echo "------------------------------------" +if [ -n "$(docker ps -a -q -f name=$IMAGE_NAME 2>/dev/null)" ]; then + echo "Stopping and removing existing container '$IMAGE_NAME'..." + docker stop $IMAGE_NAME >/dev/null 2>&1 + docker rm $IMAGE_NAME >/dev/null 2>&1 +fi + +# 2. Build the Docker image +echo "" +echo "Building Docker image '$IMAGE_NAME:$IMAGE_TAG'..." +echo "--------------------------------------------------" +docker build -t "$IMAGE_NAME:$IMAGE_TAG" -f ./Dockerfile . +if [ $? -ne 0 ]; then + echo "Error: Docker build failed." + exit 1 +fi + +# 3. Run the container in detached mode +echo "" +echo "Starting test container '$IMAGE_NAME'..." +echo "--------------------------------------" +docker run --name "$IMAGE_NAME" -d "$IMAGE_NAME:$IMAGE_TAG" +if [ $? -ne 0 ]; then + echo "Error: Failed to run container." + exit 1 +fi + +# Give the container a few seconds to initialize +sleep 3 + +# 4. Run unit tests using pytest & coverage +echo "" +echo "Running unit tests inside the container..." +echo "-----------------------------------------" +docker exec -i "$IMAGE_NAME" bash -c "coverage run -m pytest --log-level=INFO --verbose" +TEST_EXIT_CODE=$? + +# 5. Report coverage +echo "" +echo "Generating Coverage Report..." +echo "----------------------------" +docker exec -i "$IMAGE_NAME" bash -c "coverage report --show-missing" + +# 6. Post-test clean-up +echo "" +echo "Post-test clean-up..." +echo "--------------------" +docker stop "$IMAGE_NAME" >/dev/null 2>&1 +docker rm "$IMAGE_NAME" >/dev/null 2>&1 + +echo "" +echo "=========================================" +if [ $TEST_EXIT_CODE -eq 0 ]; then + echo " TESTS PASSED SUCCESSFULLY!" +else + echo " TESTS FAILED! (Exit code: $TEST_EXIT_CODE)" +fi +echo "=========================================" + +exit $TEST_EXIT_CODE -- GitLab From 3d9aa7e841098eef8b00ad9c0dd0fa5a4338e29a Mon Sep 17 00:00:00 2001 From: velazquez Date: Tue, 4 Aug 2026 13:51:06 +0200 Subject: [PATCH 2/2] Add missing copyright headers --- helm/nsc/Chart.yaml | 16 ++++++++++++++++ helm/nsc/templates/configmap.yaml | 16 ++++++++++++++++ helm/nsc/templates/deployment.yaml | 16 ++++++++++++++++ helm/nsc/templates/ingress.yaml | 16 ++++++++++++++++ helm/nsc/templates/secret.yaml | 16 ++++++++++++++++ helm/nsc/templates/service.yaml | 16 ++++++++++++++++ helm/nsc/templates/serviceaccount.yaml | 16 ++++++++++++++++ helm/nsc/values.yaml | 16 ++++++++++++++++ 8 files changed, 128 insertions(+) diff --git a/helm/nsc/Chart.yaml b/helm/nsc/Chart.yaml index 4a7c7d1..4714aa4 100644 --- a/helm/nsc/Chart.yaml +++ b/helm/nsc/Chart.yaml @@ -1,3 +1,19 @@ +# Copyright 2022-2026 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. + +# This file is an original contribution from Telefonica Innovación Digital S.L. + apiVersion: v2 name: nsc description: A Helm chart for Kubernetes deployment of the Network Slice Controller (NSC) diff --git a/helm/nsc/templates/configmap.yaml b/helm/nsc/templates/configmap.yaml index 4c48b8a..666582c 100644 --- a/helm/nsc/templates/configmap.yaml +++ b/helm/nsc/templates/configmap.yaml @@ -1,3 +1,19 @@ +# Copyright 2022-2026 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. + +# This file is an original contribution from Telefonica Innovación Digital S.L. + apiVersion: v1 kind: ConfigMap metadata: diff --git a/helm/nsc/templates/deployment.yaml b/helm/nsc/templates/deployment.yaml index d1983a5..855b012 100644 --- a/helm/nsc/templates/deployment.yaml +++ b/helm/nsc/templates/deployment.yaml @@ -1,3 +1,19 @@ +# Copyright 2022-2026 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. + +# This file is an original contribution from Telefonica Innovación Digital S.L. + apiVersion: apps/v1 kind: Deployment metadata: diff --git a/helm/nsc/templates/ingress.yaml b/helm/nsc/templates/ingress.yaml index 3296d96..9276def 100644 --- a/helm/nsc/templates/ingress.yaml +++ b/helm/nsc/templates/ingress.yaml @@ -1,3 +1,19 @@ +# Copyright 2022-2026 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. + +# This file is an original contribution from Telefonica Innovación Digital S.L. + {{- if .Values.ingress.enabled -}} {{- $fullName := include "nsc.fullname" . -}} {{- $svcPort := .Values.service.port -}} diff --git a/helm/nsc/templates/secret.yaml b/helm/nsc/templates/secret.yaml index 480cd33..47db7f0 100644 --- a/helm/nsc/templates/secret.yaml +++ b/helm/nsc/templates/secret.yaml @@ -1,3 +1,19 @@ +# Copyright 2022-2026 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. + +# This file is an original contribution from Telefonica Innovación Digital S.L. + apiVersion: v1 kind: Secret metadata: diff --git a/helm/nsc/templates/service.yaml b/helm/nsc/templates/service.yaml index f00f40a..4109b4d 100644 --- a/helm/nsc/templates/service.yaml +++ b/helm/nsc/templates/service.yaml @@ -1,3 +1,19 @@ +# Copyright 2022-2026 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. + +# This file is an original contribution from Telefonica Innovación Digital S.L. + apiVersion: v1 kind: Service metadata: diff --git a/helm/nsc/templates/serviceaccount.yaml b/helm/nsc/templates/serviceaccount.yaml index 35aa813..80ab9ab 100644 --- a/helm/nsc/templates/serviceaccount.yaml +++ b/helm/nsc/templates/serviceaccount.yaml @@ -1,3 +1,19 @@ +# Copyright 2022-2026 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. + +# This file is an original contribution from Telefonica Innovación Digital S.L. + {{- if .Values.serviceAccount.create -}} apiVersion: v1 kind: ServiceAccount diff --git a/helm/nsc/values.yaml b/helm/nsc/values.yaml index e0b2ea4..eddb6fb 100644 --- a/helm/nsc/values.yaml +++ b/helm/nsc/values.yaml @@ -1,3 +1,19 @@ +# Copyright 2022-2026 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. + +# This file is an original contribution from Telefonica Innovación Digital S.L. + # Default values for nsc. # This is a YAML-formatted file. # Declare variables to be passed into your templates. -- GitLab