From 76d28c7fa08c93d9c24eefe256992f04ccecdafc Mon Sep 17 00:00:00 2001 From: gifrerenom <lluis.gifre@cttc.es> Date: Thu, 14 Mar 2024 14:43:55 +0000 Subject: [PATCH] Fix CI/CD pipeline - end-to-end automated tests --- deploy/crdb.sh | 6 ++++-- deploy/qdb.sh | 5 ++--- deploy/tfs.sh | 6 +++--- src/tests/ofc22/.gitlab-ci.yml | 2 +- src/tests/ofc22/deploy_specs.sh | 18 ++++++++++++++++-- 5 files changed, 26 insertions(+), 11 deletions(-) diff --git a/deploy/crdb.sh b/deploy/crdb.sh index b26ef3ecf..89ec72454 100755 --- a/deploy/crdb.sh +++ b/deploy/crdb.sh @@ -158,10 +158,12 @@ function crdb_undeploy_single() { function crdb_drop_database_single() { echo "Drop database if exists" - kubectl --namespace ${CRDB_NAMESPACE} get service cockroachdb-public -o yaml + #kubectl --namespace ${CRDB_NAMESPACE} get service cockroachdb-public -o yaml + CRDB_HOST_SQL=$(kubectl --namespace ${CRDB_NAMESPACE} get service cockroachdb-public -o 'jsonpath={.spec.clusterIP}') + echo "CRDB_HOST_SQL=${CRDB_HOST_SQL}" CRDB_PORT_SQL=$(kubectl --namespace ${CRDB_NAMESPACE} get service cockroachdb-public -o 'jsonpath={.spec.ports[?(@.name=="sql")].port}') echo "CRDB_PORT_SQL=${CRDB_PORT_SQL}" - CRDB_CLIENT_URL="postgresql://${CRDB_USERNAME}:${CRDB_PASSWORD}@cockroachdb-0:${CRDB_PORT_SQL}/defaultdb?sslmode=require" + CRDB_CLIENT_URL="postgresql://${CRDB_USERNAME}:${CRDB_PASSWORD}@${CRDB_HOST_SQL}:${CRDB_PORT_SQL}/defaultdb?sslmode=require" echo "CRDB_CLIENT_URL=${CRDB_CLIENT_URL}" kubectl exec -it --namespace ${CRDB_NAMESPACE} cockroachdb-0 -- \ ./cockroach sql --certs-dir=/cockroach/cockroach-certs --url=${CRDB_CLIENT_URL} \ diff --git a/deploy/qdb.sh b/deploy/qdb.sh index 5e4ee761a..09308cf4c 100755 --- a/deploy/qdb.sh +++ b/deploy/qdb.sh @@ -160,13 +160,12 @@ function qdb_undeploy() { } function qdb_drop_tables() { - kubectl --namespace ${QDB_NAMESPACE} get service questdb-public -o yaml + echo "Drop tables, if exist" + #kubectl --namespace ${QDB_NAMESPACE} get service questdb-public -o yaml QDB_HOST=$(kubectl --namespace ${QDB_NAMESPACE} get service questdb-public -o 'jsonpath={.spec.clusterIP}') echo "QDB_HOST=${QDB_HOST}" QDB_PORT=$(kubectl --namespace ${QDB_NAMESPACE} get service questdb-public -o 'jsonpath={.spec.ports[?(@.name=="http")].port}') echo "QDB_PORT=${QDB_PORT}" - - echo "Drop tables, if exist" curl "http://${QDB_HOST}:${QDB_PORT}/exec?fmt=json&query=DROP+TABLE+IF+EXISTS+${QDB_TABLE_MONITORING_KPIS}+;" echo curl "http://${QDB_HOST}:${QDB_PORT}/exec?fmt=json&query=DROP+TABLE+IF+EXISTS+${QDB_TABLE_SLICE_GROUPS}+;" diff --git a/deploy/tfs.sh b/deploy/tfs.sh index aeeda08a3..fd49c9758 100755 --- a/deploy/tfs.sh +++ b/deploy/tfs.sh @@ -370,11 +370,11 @@ for COMPONENT in $TFS_COMPONENTS; do COMPONENT_OBJNAME=$(echo "${COMPONENT}" | sed "s/\_/-/") kubectl wait --namespace $TFS_K8S_NAMESPACE \ --for='condition=available' --timeout=90s deployment/${COMPONENT_OBJNAME}service - WAIT_EXIT_CODE=$! + WAIT_EXIT_CODE=$? if [[ $WAIT_EXIT_CODE != 0 ]]; then - echo " Failed to deploy '$COMPONENT' component, exiting..." + echo " Failed to deploy '${COMPONENT}' component, exit code '${WAIT_EXIT_CODE}', exiting..." kubectl logs --namespace $TFS_K8S_NAMESPACE deployment/${COMPONENT_OBJNAME}service --all-containers=true - exit $exit_code + exit $WAIT_EXIT_CODE fi printf "\n" done diff --git a/src/tests/ofc22/.gitlab-ci.yml b/src/tests/ofc22/.gitlab-ci.yml index 86505017f..54e00041f 100644 --- a/src/tests/ofc22/.gitlab-ci.yml +++ b/src/tests/ofc22/.gitlab-ci.yml @@ -46,4 +46,4 @@ end2end ofc22: artifacts: when: always reports: - junit: src/$IMAGE_NAME/tests/${IMAGE_NAME}_report.xml + junit: src/tests/${TEST_NAME}/report*.xml diff --git a/src/tests/ofc22/deploy_specs.sh b/src/tests/ofc22/deploy_specs.sh index d0696f91d..aad41f33d 100755 --- a/src/tests/ofc22/deploy_specs.sh +++ b/src/tests/ofc22/deploy_specs.sh @@ -26,10 +26,18 @@ export TFS_COMPONENTS="context device pathcomp service slice nbi webui" # Uncomment to activate Monitoring export TFS_COMPONENTS="${TFS_COMPONENTS} monitoring" -# Uncomment to activate ZTP and Policy Manager -#export TFS_COMPONENTS="${TFS_COMPONENTS} ztp policy" +# Uncomment to activate BGP-LS Speaker +#export TFS_COMPONENTS="${TFS_COMPONENTS} bgpls_speaker" + +# Uncomment to activate Optical Controller +#export TFS_COMPONENTS="${TFS_COMPONENTS} opticalcontroller" + +# Uncomment to activate ZTP export TFS_COMPONENTS="${TFS_COMPONENTS} ztp" +# Uncomment to activate Policy Manager +#export TFS_COMPONENTS="${TFS_COMPONENTS} policy" + # Uncomment to activate Optical CyberSecurity #export TFS_COMPONENTS="${TFS_COMPONENTS} dbscanserving opticalattackmitigator opticalattackdetector opticalattackmanager" @@ -39,6 +47,12 @@ export TFS_COMPONENTS="${TFS_COMPONENTS} ztp" # Uncomment to activate TE #export TFS_COMPONENTS="${TFS_COMPONENTS} te" +# Uncomment to activate Forecaster +#export TFS_COMPONENTS="${TFS_COMPONENTS} forecaster" + +# Uncomment to activate E2E Orchestrator +#export TFS_COMPONENTS="${TFS_COMPONENTS} e2e_orchestrator" + # Set the tag you want to use for your images. export TFS_IMAGE_TAG="dev" -- GitLab