diff --git a/expose_ingress_grpc.sh b/expose_ingress_grpc.sh new file mode 100755 index 0000000000000000000000000000000000000000..37d72aa8d66e1d2ff2e4677f245db8eaf2438ac4 --- /dev/null +++ b/expose_ingress_grpc.sh @@ -0,0 +1,53 @@ +#!/bin/bash +# Copyright 2021-2023 H2020 TeraFlow (https://www.teraflow-h2020.eu/) +# +# 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. + +######################################################################################################################## +# Define your deployment settings here +######################################################################################################################## + +# If not already set, set the name of the Kubernetes namespace to deploy to. +export TFS_K8S_NAMESPACE=${TFS_K8S_NAMESPACE:-"tfs-dev"} + +# If not already set, set the list of components you want to build images for, and deploy. +export TFS_COMPONENTS=${TFS_COMPONENTS:-"context device automation policy service compute monitoring dbscanserving opticalattackmitigator opticalcentralizedattackdetector webui"} + +######################################################################################################################## +# Automated steps start here +######################################################################################################################## + +echo "Exposing GRPC ports for components..." +for COMPONENT in $TFS_COMPONENTS; do + echo "Processing '$COMPONENT' component..." + + SERVICE_GRPC_PORT=$(kubectl get service ${COMPONENT}service --namespace $TFS_K8S_NAMESPACE -o 'jsonpath={.spec.ports[?(@.name=="grpc")].port}') + if [ -z "${SERVICE_GRPC_PORT}" ]; then + printf "\n" + continue; + fi + + PATCH='{"data": {"'${SERVICE_GRPC_PORT}'": "'$TFS_K8S_NAMESPACE'/'${COMPONENT}service':'${SERVICE_GRPC_PORT}'"}}' + #echo "PATCH: ${PATCH}" + kubectl patch configmap nginx-ingress-tcp-microk8s-conf --namespace ingress --patch "${PATCH}" + + PORT_MAP='{"containerPort": '${SERVICE_GRPC_PORT}', "hostPort": '${SERVICE_GRPC_PORT}'}' + CONTAINER='{"name": "nginx-ingress-microk8s", "ports": ['${PORT_MAP}']}' + PATCH='{"spec": {"template": {"spec": {"containers": ['${CONTAINER}']}}}}' + #echo "PATCH: ${PATCH}" + kubectl patch daemonset nginx-ingress-microk8s-controller --namespace ingress --patch "${PATCH}" + + printf "\n" +done + +echo "Done!" diff --git a/scripts/report_coverage_all.sh b/scripts/report_coverage_all.sh index a7e4797f3118a03c5f4db7eb384a67bdea4d795a..3b7df170c880ede72dea356752c5120e59dd9d71 100755 --- a/scripts/report_coverage_all.sh +++ b/scripts/report_coverage_all.sh @@ -16,7 +16,7 @@ PROJECTDIR=`pwd` -cd $(dirname $0)/src +cd $PROJECTDIR/src RCFILE=$PROJECTDIR/coverage/.coveragerc echo diff --git a/scripts/run_tests_locally-compute.sh b/scripts/run_tests_locally-compute.sh index 48ce6e232a8005ee37fce8a0dbd9f7aed4cf83dc..d48fe417134d2f8c3078d549b3bb84e2cc745da6 100755 --- a/scripts/run_tests_locally-compute.sh +++ b/scripts/run_tests_locally-compute.sh @@ -20,9 +20,5 @@ cd $PROJECTDIR/src RCFILE=$PROJECTDIR/coverage/.coveragerc # Run unitary tests and analyze coverage of code at same time - -# Useful flags for pytest: -#-o log_cli=true -o log_file=service.log -o log_file_level=DEBUG - coverage run --rcfile=$RCFILE --append -m pytest --log-level=INFO --verbose \ compute/tests/test_unitary.py diff --git a/scripts/run_tests_locally-device-all.sh b/scripts/run_tests_locally-device-all.sh index 2cf8faaf50355a3cc5f3a0206498ed4dacb48523..a60eab0be932862cf1adc3a81678239de566bd37 100755 --- a/scripts/run_tests_locally-device-all.sh +++ b/scripts/run_tests_locally-device-all.sh @@ -21,9 +21,6 @@ RCFILE=$PROJECTDIR/coverage/.coveragerc # Run unitary tests and analyze coverage of code at same time -# Useful flags for pytest: -#-o log_cli=true -o log_file=device.log -o log_file_level=DEBUG - coverage run --rcfile=$RCFILE --append -m pytest --log-level=INFO --verbose \ device/tests/test_unitary_emulated.py diff --git a/scripts/run_tests_locally-device-emulated.sh b/scripts/run_tests_locally-device-emulated.sh index ab4f77adaf9c0549551c91d944c1c6db77a8b9cb..541017f7a6b9f3d1289162ad69b27f572aa046cb 100755 --- a/scripts/run_tests_locally-device-emulated.sh +++ b/scripts/run_tests_locally-device-emulated.sh @@ -20,9 +20,5 @@ cd $PROJECTDIR/src RCFILE=$PROJECTDIR/coverage/.coveragerc # Run unitary tests and analyze coverage of code at same time - -# Useful flags for pytest: -#-o log_cli=true -o log_file=device.log -o log_file_level=DEBUG - coverage run --rcfile=$RCFILE --append -m pytest --log-level=INFO --verbose \ device/tests/test_unitary_emulated.py diff --git a/scripts/run_tests_locally-device-microwave.sh b/scripts/run_tests_locally-device-microwave.sh index e03630c9f63c65cae91464b76cc3ddc447835f42..21f3e5ab67c882ab51f7c8c14a95ed6df26418de 100755 --- a/scripts/run_tests_locally-device-microwave.sh +++ b/scripts/run_tests_locally-device-microwave.sh @@ -20,9 +20,5 @@ cd $PROJECTDIR/src RCFILE=$PROJECTDIR/coverage/.coveragerc # Run unitary tests and analyze coverage of code at same time - -# Useful flags for pytest: -#-o log_cli=true -o log_file=device.log -o log_file_level=DEBUG - coverage run --rcfile=$RCFILE --append -m pytest --log-level=INFO --verbose \ device/tests/test_unitary_microwave.py diff --git a/scripts/run_tests_locally-device-openconfig.sh b/scripts/run_tests_locally-device-openconfig.sh index 83d4a0545a3386395ead97f40d45c034350c73b9..f87346fed8ebe9b27c806759fafc851a15afd068 100755 --- a/scripts/run_tests_locally-device-openconfig.sh +++ b/scripts/run_tests_locally-device-openconfig.sh @@ -20,9 +20,5 @@ cd $PROJECTDIR/src RCFILE=$PROJECTDIR/coverage/.coveragerc # Run unitary tests and analyze coverage of code at same time - -# Useful flags for pytest: -#-o log_cli=true -o log_file=device.log -o log_file_level=DEBUG - coverage run --rcfile=$RCFILE --append -m pytest --log-level=INFO --verbose \ device/tests/test_unitary_openconfig.py diff --git a/scripts/run_tests_locally-device-p4.sh b/scripts/run_tests_locally-device-p4.sh index 36b381a3cd9214603456828b41e6d70b8c6c908d..4e6754e4d56741f960e1e5562abb0c10abc0ccb4 100755 --- a/scripts/run_tests_locally-device-p4.sh +++ b/scripts/run_tests_locally-device-p4.sh @@ -20,9 +20,5 @@ cd $PROJECTDIR/src RCFILE=$PROJECTDIR/coverage/.coveragerc # Run unitary tests and analyze coverage of code at same time - -# Useful flags for pytest: -#-o log_cli=true -o log_file=device.log -o log_file_level=DEBUG - coverage run --rcfile=$RCFILE --append -m pytest --log-level=INFO --verbose \ device/tests/test_unitary_p4.py diff --git a/scripts/run_tests_locally-device-tapi.sh b/scripts/run_tests_locally-device-tapi.sh index a281466b677f256b2ce9fe7770bf2b052ef59126..d37e4e2b7f8545c2033b0049722cdbb8c589b55b 100755 --- a/scripts/run_tests_locally-device-tapi.sh +++ b/scripts/run_tests_locally-device-tapi.sh @@ -20,9 +20,5 @@ cd $PROJECTDIR/src RCFILE=$PROJECTDIR/coverage/.coveragerc # Run unitary tests and analyze coverage of code at same time - -# Useful flags for pytest: -#-o log_cli=true -o log_file=device.log -o log_file_level=DEBUG - coverage run --rcfile=$RCFILE --append -m pytest --log-level=INFO --verbose \ device/tests/test_unitary_tapi.py diff --git a/scripts/run_tests_locally-device.sh b/scripts/run_tests_locally-device.sh index ba6c0b6a58031720addc17cc0de9169e592099f5..5cd4adce46a98973b5db83a1f57239e536cf8ee2 100755 --- a/scripts/run_tests_locally-device.sh +++ b/scripts/run_tests_locally-device.sh @@ -20,9 +20,5 @@ cd $PROJECTDIR/src RCFILE=$PROJECTDIR/coverage/.coveragerc # Run unitary tests and analyze coverage of code at same time - -# Useful flags for pytest: -#-o log_cli=true -o log_file=device.log -o log_file_level=DEBUG - coverage run --rcfile=$RCFILE --append -m pytest --log-level=INFO --verbose \ device/tests/test_unitary.py diff --git a/scripts/run_tests_locally-service.sh b/scripts/run_tests_locally-service.sh index 853eb97673e9e2a3a3fa28d025bd8af9ef4ea6cf..8a2a8d0be1d1960c6197a67e471ae29abba501a7 100755 --- a/scripts/run_tests_locally-service.sh +++ b/scripts/run_tests_locally-service.sh @@ -20,9 +20,5 @@ cd $PROJECTDIR/src RCFILE=$PROJECTDIR/coverage/.coveragerc # Run unitary tests and analyze coverage of code at same time - -# Useful flags for pytest: -#-o log_cli=true -o log_file=service.log -o log_file_level=DEBUG - coverage run --rcfile=$RCFILE --append -m pytest --log-level=INFO --verbose \ service/tests/test_unitary.py diff --git a/scripts/run_tests_locally-slice.sh b/scripts/run_tests_locally-slice.sh index adad39b5b2de2f4de0f2451e89a20732d1ecda2c..fa3af4eba1f9d42a1f9d283964a536a00f9547ae 100755 --- a/scripts/run_tests_locally-slice.sh +++ b/scripts/run_tests_locally-slice.sh @@ -20,9 +20,5 @@ cd $PROJECTDIR/src RCFILE=$PROJECTDIR/coverage/.coveragerc # Run unitary tests and analyze coverage of code at same time - -# Useful flags for pytest: -#-o log_cli=true -o log_file=service.log -o log_file_level=DEBUG - coverage run --rcfile=$RCFILE --append -m pytest --log-level=INFO --verbose \ slice/tests/test_unitary.py diff --git a/scripts/run_tests_locally.sh b/scripts/run_tests_locally.sh index 4a95fd8be7ac83ff0b5ec5a3db47c0cf4fae06f4..c0e95e5278724c425d0bcb0a6d51fee3ab256fb9 100755 --- a/scripts/run_tests_locally.sh +++ b/scripts/run_tests_locally.sh @@ -51,9 +51,6 @@ export INFLUXDB_DATABASE=$(kubectl --namespace $K8S_NAMESPACE get secrets influx # First destroy old coverage file rm -f $COVERAGEFILE -# Useful flags for pytest: -#-o log_cli=true -o log_file=device.log -o log_file_level=DEBUG - coverage run --rcfile=$RCFILE --append -m pytest --log-level=INFO --verbose \ common/orm/tests/test_unitary.py \ common/message_broker/tests/test_unitary.py \