diff --git a/add_license_header_to_files.sh b/scripts/add_license_header_to_files.sh similarity index 100% rename from add_license_header_to_files.sh rename to scripts/add_license_header_to_files.sh diff --git a/report_coverage_all.sh b/scripts/report_coverage_all.sh similarity index 100% rename from report_coverage_all.sh rename to scripts/report_coverage_all.sh diff --git a/report_coverage_common.sh b/scripts/report_coverage_common.sh similarity index 100% rename from report_coverage_common.sh rename to scripts/report_coverage_common.sh diff --git a/report_coverage_compute.sh b/scripts/report_coverage_compute.sh similarity index 100% rename from report_coverage_compute.sh rename to scripts/report_coverage_compute.sh diff --git a/report_coverage_context.sh b/scripts/report_coverage_context.sh similarity index 100% rename from report_coverage_context.sh rename to scripts/report_coverage_context.sh diff --git a/report_coverage_device.sh b/scripts/report_coverage_device.sh similarity index 100% rename from report_coverage_device.sh rename to scripts/report_coverage_device.sh diff --git a/report_coverage_l3_attackmitigator.sh b/scripts/report_coverage_l3_attackmitigator.sh similarity index 100% rename from report_coverage_l3_attackmitigator.sh rename to scripts/report_coverage_l3_attackmitigator.sh diff --git a/report_coverage_l3_centralizedattackdetector.sh b/scripts/report_coverage_l3_centralizedattackdetector.sh similarity index 100% rename from report_coverage_l3_centralizedattackdetector.sh rename to scripts/report_coverage_l3_centralizedattackdetector.sh diff --git a/report_coverage_l3_distributedattackdetector.sh b/scripts/report_coverage_l3_distributedattackdetector.sh similarity index 100% rename from report_coverage_l3_distributedattackdetector.sh rename to scripts/report_coverage_l3_distributedattackdetector.sh diff --git a/report_coverage_service.sh b/scripts/report_coverage_service.sh similarity index 100% rename from report_coverage_service.sh rename to scripts/report_coverage_service.sh diff --git a/run_tests_in_kubernetes.sh b/scripts/run_tests_in_kubernetes.sh similarity index 100% rename from run_tests_in_kubernetes.sh rename to scripts/run_tests_in_kubernetes.sh diff --git a/run_tests_locally.sh b/scripts/run_tests_locally.sh similarity index 98% rename from run_tests_locally.sh rename to scripts/run_tests_locally.sh index 0f4fba608ca1cff319372209c59d59637fe2ead2..1655d875e4f3cbb5922b773094422d32dff1ee2e 100755 --- a/run_tests_locally.sh +++ b/scripts/run_tests_locally.sh @@ -25,6 +25,7 @@ cat $PROJECTDIR/coverage/.coveragerc.template | sed s+~/teraflow/controller+$PRO # Run unitary tests and analyze coverage of code at same time +# Set the name of the Kubernetes namespace and hostname to use. K8S_NAMESPACE="tf-dev" K8S_HOSTNAME="kubernetes-master" # Populate environment variables for context to use Redis in a development machine running Kubernetes diff --git a/src/tests/ofc22/README.md b/src/tests/ofc22/README.md index 3e50d2fe33371b648c014228b7ed3f5b36a0f361..07fd4f72f494638744e7bc35eb207157bbb8cc1d 100644 --- a/src/tests/ofc22/README.md +++ b/src/tests/ofc22/README.md @@ -18,6 +18,10 @@ To run this functional test, it is assumed you have deployed a Kubernetes-based After installing Kubernetes, you can run it to deploy the appropriate components. Feel free to adapt it your particular case following the instructions described in [Wiki: Deploying a TeraFlow OS test instance](https://gitlab.com/teraflow-h2020/controller/-/wikis/Deploying-a-TeraFlow-OS-test-instance). +__Important:__ +- The `./ofc22/deploy_in_kubernetes.sh` assumes you have installed the appropriate development dependencies using the `install_development_dependencies.sh` script. +- Before running the scripts in this folder, remember to update the environment variable K8S_HOSTNAME to point to the Kubernetes node you will be using as described in [Wiki: Deploying a TeraFlow OS test instance](https://gitlab.com/teraflow-h2020/controller/-/wikis/Deploying-a-TeraFlow-OS-test-instance). + For your convenience, the configuration s sript `./ofc22/deploy_in_kubernetes.sh` has been already defined. The script will take some minutes to download the dependencies, build the micro-services, deploy them, and leave them ready for operation. The deployment will finish with a report of the items that have been created. ## Access to the WebUI and Dashboard diff --git a/src/tests/ofc22/run_test_01_bootstrap.sh b/src/tests/ofc22/run_test_01_bootstrap.sh index 9f61338a5a483bf67d80b9bd5fb603cfb46ea2b3..042e0a0a2f08b59074da2a6e185fc00f37b482c0 100755 --- a/src/tests/ofc22/run_test_01_bootstrap.sh +++ b/src/tests/ofc22/run_test_01_bootstrap.sh @@ -20,21 +20,30 @@ cd $PROJECTDIR/src RCFILE=$PROJECTDIR/coverage/.coveragerc COVERAGEFILE=$PROJECTDIR/coverage/.coverage -# Set the name of the Kubernetes namespace to deploy to. +# Configure the correct folder on the .coveragerc file +cat $PROJECTDIR/coverage/.coveragerc.template | sed s+~/teraflow/controller+$PROJECTDIR+g > $RCFILE + +# Destroy old coverage file +rm -f $COVERAGEFILE + +# Set the name of the Kubernetes namespace and hostname to use. K8S_NAMESPACE="ofc22" -K8S_NODENAME="kubernetes-master" +K8S_HOSTNAME="kubernetes-master" # Flush Context database kubectl --namespace $K8S_NAMESPACE exec -it deployment/contextservice --container redis -- redis-cli FLUSHALL -export CONTEXTSERVICE_SERVICE_HOST=$(kubectl get node $K8S_NODENAME -o 'jsonpath={.status.addresses[?(@.type=="InternalIP")].address}') +export CONTEXTSERVICE_SERVICE_HOST=$(kubectl get node $K8S_HOSTNAME -o 'jsonpath={.status.addresses[?(@.type=="InternalIP")].address}') export CONTEXTSERVICE_SERVICE_PORT_GRPC=$(kubectl get service contextservice-public --namespace $K8S_NAMESPACE -o 'jsonpath={.spec.ports[?(@.port==1010)].nodePort}') -export DEVICESERVICE_SERVICE_HOST=$(kubectl get node $K8S_NODENAME -o 'jsonpath={.status.addresses[?(@.type=="InternalIP")].address}') +export DEVICESERVICE_SERVICE_HOST=$(kubectl get node $K8S_HOSTNAME -o 'jsonpath={.status.addresses[?(@.type=="InternalIP")].address}') export DEVICESERVICE_SERVICE_PORT_GRPC=$(kubectl get service deviceservice-public --namespace $K8S_NAMESPACE -o 'jsonpath={.spec.ports[?(@.port==2020)].nodePort}') -export COMPUTESERVICE_SERVICE_HOST=$(kubectl get node $K8S_NODENAME -o 'jsonpath={.status.addresses[?(@.type=="InternalIP")].address}') +export COMPUTESERVICE_SERVICE_HOST=$(kubectl get node $K8S_HOSTNAME -o 'jsonpath={.status.addresses[?(@.type=="InternalIP")].address}') export COMPUTESERVICE_SERVICE_PORT_HTTP=$(kubectl get service computeservice-public --namespace $K8S_NAMESPACE -o 'jsonpath={.spec.ports[?(@.port==8080)].nodePort}') -# Run integration 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 + +# Run functional test and analyze coverage of code at same time coverage run --rcfile=$RCFILE --append -m pytest --log-level=INFO --verbose \ tests/ofc22/tests/test_functional_bootstrap.py diff --git a/src/tests/ofc22/run_test_02_create_service.sh b/src/tests/ofc22/run_test_02_create_service.sh index d2fbefb2e78e858873e2a6f3cdd2e574874a1d3d..b212b687c2fd5be42239e3012d91d01b963c9c7f 100755 --- a/src/tests/ofc22/run_test_02_create_service.sh +++ b/src/tests/ofc22/run_test_02_create_service.sh @@ -20,18 +20,21 @@ cd $PROJECTDIR/src RCFILE=$PROJECTDIR/coverage/.coveragerc COVERAGEFILE=$PROJECTDIR/coverage/.coverage -# Set the name of the Kubernetes namespace to deploy to. +# Set the name of the Kubernetes namespace and hostname to use. K8S_NAMESPACE="ofc22" -K8S_NODENAME="kubernetes-master" +K8S_HOSTNAME="kubernetes-master" -export CONTEXTSERVICE_SERVICE_HOST=$(kubectl get node $K8S_NODENAME -o 'jsonpath={.status.addresses[?(@.type=="InternalIP")].address}') +export CONTEXTSERVICE_SERVICE_HOST=$(kubectl get node $K8S_HOSTNAME -o 'jsonpath={.status.addresses[?(@.type=="InternalIP")].address}') export CONTEXTSERVICE_SERVICE_PORT_GRPC=$(kubectl get service contextservice-public --namespace $K8S_NAMESPACE -o 'jsonpath={.spec.ports[?(@.port==1010)].nodePort}') -export DEVICESERVICE_SERVICE_HOST=$(kubectl get node $K8S_NODENAME -o 'jsonpath={.status.addresses[?(@.type=="InternalIP")].address}') +export DEVICESERVICE_SERVICE_HOST=$(kubectl get node $K8S_HOSTNAME -o 'jsonpath={.status.addresses[?(@.type=="InternalIP")].address}') export DEVICESERVICE_SERVICE_PORT_GRPC=$(kubectl get service deviceservice-public --namespace $K8S_NAMESPACE -o 'jsonpath={.spec.ports[?(@.port==2020)].nodePort}') -export COMPUTESERVICE_SERVICE_HOST=$(kubectl get node $K8S_NODENAME -o 'jsonpath={.status.addresses[?(@.type=="InternalIP")].address}') +export COMPUTESERVICE_SERVICE_HOST=$(kubectl get node $K8S_HOSTNAME -o 'jsonpath={.status.addresses[?(@.type=="InternalIP")].address}') export COMPUTESERVICE_SERVICE_PORT_HTTP=$(kubectl get service computeservice-public --namespace $K8S_NAMESPACE -o 'jsonpath={.spec.ports[?(@.port==8080)].nodePort}') -# Run integration 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 + +# Run functional test and analyze coverage of code at same time coverage run --rcfile=$RCFILE --append -m pytest --log-level=INFO --verbose \ tests/ofc22/tests/test_functional_create_service.py diff --git a/src/tests/ofc22/run_test_03_delete_service.sh b/src/tests/ofc22/run_test_03_delete_service.sh index cb7fbeb8d08af8ac3bb4199c7145e3a8cdcd4e39..d0c3127ad7d2384285dde46c6fadefb4f6f8bdc6 100755 --- a/src/tests/ofc22/run_test_03_delete_service.sh +++ b/src/tests/ofc22/run_test_03_delete_service.sh @@ -20,18 +20,21 @@ cd $PROJECTDIR/src RCFILE=$PROJECTDIR/coverage/.coveragerc COVERAGEFILE=$PROJECTDIR/coverage/.coverage -# Set the name of the Kubernetes namespace to deploy to. +# Set the name of the Kubernetes namespace and hostname to use. K8S_NAMESPACE="ofc22" -K8S_NODENAME="kubernetes-master" +K8S_HOSTNAME="kubernetes-master" -export CONTEXTSERVICE_SERVICE_HOST=$(kubectl get node $K8S_NODENAME -o 'jsonpath={.status.addresses[?(@.type=="InternalIP")].address}') +export CONTEXTSERVICE_SERVICE_HOST=$(kubectl get node $K8S_HOSTNAME -o 'jsonpath={.status.addresses[?(@.type=="InternalIP")].address}') export CONTEXTSERVICE_SERVICE_PORT_GRPC=$(kubectl get service contextservice-public --namespace $K8S_NAMESPACE -o 'jsonpath={.spec.ports[?(@.port==1010)].nodePort}') -export DEVICESERVICE_SERVICE_HOST=$(kubectl get node $K8S_NODENAME -o 'jsonpath={.status.addresses[?(@.type=="InternalIP")].address}') +export DEVICESERVICE_SERVICE_HOST=$(kubectl get node $K8S_HOSTNAME -o 'jsonpath={.status.addresses[?(@.type=="InternalIP")].address}') export DEVICESERVICE_SERVICE_PORT_GRPC=$(kubectl get service deviceservice-public --namespace $K8S_NAMESPACE -o 'jsonpath={.spec.ports[?(@.port==2020)].nodePort}') -export COMPUTESERVICE_SERVICE_HOST=$(kubectl get node $K8S_NODENAME -o 'jsonpath={.status.addresses[?(@.type=="InternalIP")].address}') +export COMPUTESERVICE_SERVICE_HOST=$(kubectl get node $K8S_HOSTNAME -o 'jsonpath={.status.addresses[?(@.type=="InternalIP")].address}') export COMPUTESERVICE_SERVICE_PORT_HTTP=$(kubectl get service computeservice-public --namespace $K8S_NAMESPACE -o 'jsonpath={.spec.ports[?(@.port==8080)].nodePort}') -# Run integration 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 + +# Run functional test and analyze coverage of code at same time coverage run --rcfile=$RCFILE --append -m pytest --log-level=INFO --verbose \ tests/ofc22/tests/test_functional_delete_service.py diff --git a/src/tests/ofc22/run_test_04_cleanup.sh b/src/tests/ofc22/run_test_04_cleanup.sh index 6c48970d54bef8caffc3159f2919a1a90182bd9c..c31774523dd9937f82e17a7c90fbf41c7b3594f4 100755 --- a/src/tests/ofc22/run_test_04_cleanup.sh +++ b/src/tests/ofc22/run_test_04_cleanup.sh @@ -20,18 +20,21 @@ cd $PROJECTDIR/src RCFILE=$PROJECTDIR/coverage/.coveragerc COVERAGEFILE=$PROJECTDIR/coverage/.coverage -# Set the name of the Kubernetes namespace to deploy to. +# Set the name of the Kubernetes namespace and hostname to use. K8S_NAMESPACE="ofc22" -K8S_NODENAME="kubernetes-master" +K8S_HOSTNAME="kubernetes-master" -export CONTEXTSERVICE_SERVICE_HOST=$(kubectl get node $K8S_NODENAME -o 'jsonpath={.status.addresses[?(@.type=="InternalIP")].address}') +export CONTEXTSERVICE_SERVICE_HOST=$(kubectl get node $K8S_HOSTNAME -o 'jsonpath={.status.addresses[?(@.type=="InternalIP")].address}') export CONTEXTSERVICE_SERVICE_PORT_GRPC=$(kubectl get service contextservice-public --namespace $K8S_NAMESPACE -o 'jsonpath={.spec.ports[?(@.port==1010)].nodePort}') -export DEVICESERVICE_SERVICE_HOST=$(kubectl get node $K8S_NODENAME -o 'jsonpath={.status.addresses[?(@.type=="InternalIP")].address}') +export DEVICESERVICE_SERVICE_HOST=$(kubectl get node $K8S_HOSTNAME -o 'jsonpath={.status.addresses[?(@.type=="InternalIP")].address}') export DEVICESERVICE_SERVICE_PORT_GRPC=$(kubectl get service deviceservice-public --namespace $K8S_NAMESPACE -o 'jsonpath={.spec.ports[?(@.port==2020)].nodePort}') -export COMPUTESERVICE_SERVICE_HOST=$(kubectl get node $K8S_NODENAME -o 'jsonpath={.status.addresses[?(@.type=="InternalIP")].address}') +export COMPUTESERVICE_SERVICE_HOST=$(kubectl get node $K8S_HOSTNAME -o 'jsonpath={.status.addresses[?(@.type=="InternalIP")].address}') export COMPUTESERVICE_SERVICE_PORT_HTTP=$(kubectl get service computeservice-public --namespace $K8S_NAMESPACE -o 'jsonpath={.spec.ports[?(@.port==8080)].nodePort}') -# Run integration 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 + +# Run functional test and analyze coverage of code at same time coverage run --rcfile=$RCFILE --append -m pytest --log-level=INFO --verbose \ tests/ofc22/tests/test_functional_cleanup.py diff --git a/src/tests/ofc22/show_logs_automation.sh b/src/tests/ofc22/show_logs_automation.sh index 4306814271d2c69b81222e420094e3f3471893ca..778cfaa942bcb36a81ccd571afe0f024c32d373d 100755 --- a/src/tests/ofc22/show_logs_automation.sh +++ b/src/tests/ofc22/show_logs_automation.sh @@ -13,4 +13,5 @@ # See the License for the specific language governing permissions and # limitations under the License. -kubectl --namespace ofc22 logs deployment/automationservice +K8S_NAMESPACE="ofc22" +kubectl --namespace $K8S_NAMESPACE logs deployment/automationservice diff --git a/src/tests/ofc22/show_logs_compute.sh b/src/tests/ofc22/show_logs_compute.sh index fc2401d9afb137c12269e39b78dd0ef528f3e5db..cafde447ace44cc71fc75d27af2a50100f155681 100755 --- a/src/tests/ofc22/show_logs_compute.sh +++ b/src/tests/ofc22/show_logs_compute.sh @@ -13,4 +13,5 @@ # See the License for the specific language governing permissions and # limitations under the License. -kubectl --namespace ofc22 logs deployment/computeservice +K8S_NAMESPACE="ofc22" +kubectl --namespace $K8S_NAMESPACE logs deployment/computeservice diff --git a/src/tests/ofc22/show_logs_context.sh b/src/tests/ofc22/show_logs_context.sh index e4dfdd212fecc3c0065da433bf988d51a4bd5a12..6d5b77fa9e0565e6df66856829644f31f55a4197 100755 --- a/src/tests/ofc22/show_logs_context.sh +++ b/src/tests/ofc22/show_logs_context.sh @@ -13,4 +13,5 @@ # See the License for the specific language governing permissions and # limitations under the License. -kubectl --namespace ofc22 logs deployment/contextservice -c server +K8S_NAMESPACE="ofc22" +kubectl --namespace $K8S_NAMESPACE logs deployment/contextservice -c server diff --git a/src/tests/ofc22/show_logs_device.sh b/src/tests/ofc22/show_logs_device.sh index e150c0f5144f654b6c69c8daa7ce567b9dc6b207..9d976755a959dd8674a5cfe4fffb7104c27e8521 100755 --- a/src/tests/ofc22/show_logs_device.sh +++ b/src/tests/ofc22/show_logs_device.sh @@ -13,4 +13,5 @@ # See the License for the specific language governing permissions and # limitations under the License. -kubectl --namespace ofc22 logs deployment/deviceservice +K8S_NAMESPACE="ofc22" +kubectl --namespace $K8S_NAMESPACE logs deployment/deviceservice diff --git a/src/tests/ofc22/show_logs_monitoring.sh b/src/tests/ofc22/show_logs_monitoring.sh index 55d6316d64908cd7d3bd4e862a35c6f66c20c6e1..3dd7522fa57eca242225d29571956923075e14d8 100755 --- a/src/tests/ofc22/show_logs_monitoring.sh +++ b/src/tests/ofc22/show_logs_monitoring.sh @@ -13,4 +13,5 @@ # See the License for the specific language governing permissions and # limitations under the License. -kubectl --namespace ofc22 logs deployment/monitoringservice -c server +K8S_NAMESPACE="ofc22" +kubectl --namespace $K8S_NAMESPACE logs deployment/monitoringservice -c server diff --git a/src/tests/ofc22/show_logs_service.sh b/src/tests/ofc22/show_logs_service.sh index 0659cbb045d5f72b35bc3f7b3aa0973cf4b35227..2589a3cfe16f4383904c342366f3efc01c42d470 100755 --- a/src/tests/ofc22/show_logs_service.sh +++ b/src/tests/ofc22/show_logs_service.sh @@ -13,4 +13,5 @@ # See the License for the specific language governing permissions and # limitations under the License. -kubectl --namespace ofc22 logs deployment/serviceservice +K8S_NAMESPACE="ofc22" +kubectl --namespace $K8S_NAMESPACE logs deployment/serviceservice diff --git a/src/tests/ofc22/show_logs_webui.sh b/src/tests/ofc22/show_logs_webui.sh index 2f506d3345f1bbc68866d0cb2b8160c0b168c33f..ecf4f3f6fc22dd71eef2a6db2b5ac18f54ccca35 100755 --- a/src/tests/ofc22/show_logs_webui.sh +++ b/src/tests/ofc22/show_logs_webui.sh @@ -13,4 +13,5 @@ # See the License for the specific language governing permissions and # limitations under the License. -kubectl --namespace ofc22 logs deployment/webuiservice -c server +K8S_NAMESPACE="ofc22" +kubectl --namespace $K8S_NAMESPACE logs deployment/webuiservice -c server diff --git a/src/webui/requirements.in b/src/webui/requirements.in index 534f42115caae51e672bdbc247435170e4659a77..c57794403c1dee6f1764a877b83805b6d32f12f5 100644 --- a/src/webui/requirements.in +++ b/src/webui/requirements.in @@ -1,11 +1,11 @@ -Flask==2.0.1 +Flask==2.0.2 Flask-WTF==1.0.0 flask-healthz==0.0.3 flask-unittest==0.1.2 grpcio==1.43.0 grpcio-health-checking==1.43.0 -protobuf==3.17.3 -prometheus-client==0.11.0 +protobuf==3.19.3 +prometheus-client==0.13.0 pytest==6.2.5 pytest-benchmark==3.4.1 lorem-text==2.1