diff --git a/helm/nsc/Chart.yaml b/helm/nsc/Chart.yaml index 4a7c7d11ce274832bf5e888cc0b1018410894555..4714aa4e101a8c3cfe894fe3ef7bdb5a16a4557f 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 4c48b8a1923cfbe1005b64728b89e19c71b0dd56..666582c092e6f88ee6ee5081629f2142fc99e702 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 d1983a52e2917bf952fe36ac2fbafc7668efbd0b..855b0123f8fa7f956d094939fc91b299e29eaff0 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 3296d969b17c8cbf647d4db675a0208fc9469392..9276defaa01f5ea5a6ecf44f35fbee20fd27c3fc 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 480cd3378b83de7b01ece56a601289196a778073..47db7f08321d08ccd09b6ef73e3c481729603121 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 f00f40a396aff2e353e033e0bdad1449e072927e..4109b4dfde6eaf7e9aa17b255af6da95fab47ebc 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 35aa8133c5ddc55d38ca2288e5b9e86d3a9f8277..80ab9ab7983873eeaafb0214ffa6bf7d9f6e9a3c 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 e0b2ea4a1c86a79ea13df06deb4431b46bbcf429..eddb6fb5906d9f4864e72c7f02a88630a1ffc7da 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. diff --git a/scripts/run_tests.sh b/scripts/run_tests.sh new file mode 100644 index 0000000000000000000000000000000000000000..ad501bd017058bed21f3adee9db84a155e858b93 --- /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