33# Copyright 2018-2024 the Kubeapps contributors.
44# SPDX-License-Identifier: Apache-2.0
55
6- set -o errexit
7- set -o nounset
8- set -o pipefail
6+ set -euo pipefail
97
108startTime=$( date +%s)
119
1210# Constants
1311ROOT_DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) /.." > /dev/null && pwd) "
1412ALL_TESTS=" all"
1513MAIN_TESTS=" main"
14+ MAIN_TESTS_SUBGROUP=" main-group-"
15+ EXISTENT_MAIN_TESTS_SUBGROUPS=3
1616MULTICLUSTER_TESTS=" multicluster"
1717MULTICLUSTER_NOKUBEAPPS_TESTS=" multicluster-nokubeapps"
1818CARVEL_TESTS=" carvel"
1919FLUX_TESTS=" flux"
20- OPERATOR_TESTS=" operator "
20+ OPERATOR_TESTS=" operators "
2121SUPPORTED_TESTS_GROUPS=(" ${ALL_TESTS} " " ${MAIN_TESTS} " " ${MULTICLUSTER_TESTS} " " ${CARVEL_TESTS} " " ${FLUX_TESTS} " " ${OPERATOR_TESTS} " " ${MULTICLUSTER_NOKUBEAPPS_TESTS} " )
2222INTEGRATION_HOST=kubeapps-ci.kubeapps
2323INTEGRATION_ENTRYPOINT=" http://${INTEGRATION_HOST} "
@@ -40,9 +40,9 @@ DEBUG_MODE=${DEBUG_MODE:-false}
4040TEST_LATEST_RELEASE=${TEST_LATEST_RELEASE:- false}
4141
4242# shellcheck disable=SC2076
43- if [[ ! " ${SUPPORTED_TESTS_GROUPS[*]} " =~ " ${TESTS_GROUP} " ]]; then
43+ if [[ ! " ${SUPPORTED_TESTS_GROUPS[*]} " =~ " ${TESTS_GROUP} " && ! " ${TESTS_GROUP} " == " ${MAIN_TESTS_SUBGROUP} " * ]]; then
4444 # shellcheck disable=SC2046
45- echo $( IFS=' ,' ; echo " The provided TEST_GROUP [${TESTS_GROUP} ] is not supported. Supported groups are: ${SUPPORTED_TESTS_GROUPS[*]} " )
45+ echo $( IFS=' ,' ; echo " The provided TESTS_GROUP [${TESTS_GROUP} ] is not supported. Supported groups are: ${SUPPORTED_TESTS_GROUPS[*]} . Subgroups of the main group are also supported: ${MAIN_TESTS_SUBGROUP} * " )
4646 exit 1
4747fi
4848
@@ -576,14 +576,18 @@ edit_token="$(kubectl get -n kubeapps secret kubeapps-edit-token -o go-template=
576576
577577info " Bootstrap time: $( elapsedTimeSince " $startTime " ) "
578578
579- # #################################
580- # ####### Main tests group ########
581- # #################################
582- if [[ " ${TESTS_GROUP} " == " ${ALL_TESTS} " || " ${TESTS_GROUP} " == " ${MAIN_TESTS} " ]]; then
583- sectionStartTime=$( date +%s)
584- info " Running main Integration tests without k8s API access..."
585- test_command="
586- CI_TIMEOUT_MINUTES=40 \
579+ # #######################################################################################################################
580+ # Returns the test command to be executed to run the e2e tests in the e2e runner image.
581+ # Arguments:
582+ # $1: Test group to be executed (eg. main)
583+ # $2: Timeout in minutes. Optional, default: 20
584+ # Returns: the command to be executed (a yarn command at the time of this writing).
585+ # #######################################################################################################################
586+ getTestCommand () {
587+ local tests_group=${1:? Missing test group}
588+ local timeout=${2:- 20}
589+ echo "
590+ CI_TIMEOUT_MINUTES=${timeout} \
587591 DOCKER_USERNAME=${DOCKER_USERNAME} \
588592 DOCKER_PASSWORD=${DOCKER_PASSWORD} \
589593 DOCKER_REGISTRY_URL=${DOCKER_REGISTRY_URL} \
@@ -593,18 +597,47 @@ if [[ "${TESTS_GROUP}" == "${ALL_TESTS}" || "${TESTS_GROUP}" == "${MAIN_TESTS}"
593597 ADMIN_TOKEN=${admin_token} \
594598 VIEW_TOKEN=${view_token} \
595599 EDIT_TOKEN=${edit_token} \
596- yarn test \" tests/main /\"
600+ yarn test \" tests/${tests_group} /\"
597601 "
602+ }
603+
604+ # #######################################################################################################################
605+ # Run a subgroup of the Main tests group.
606+ # Arguments:
607+ # $1: Subgroup to run (eg. main-group-1)
608+ # Returns: None
609+ # #######################################################################################################################
610+ runMainTestsSubgroup () {
611+ local subgroup=${1:? Missing main tests subgroup to run}
612+ local test_command=$( getTestCommand " ${subgroup} " " 20" )
613+
614+ sectionStartTime=$( date +%s)
615+ info " Running Main Integration tests subgroup [${subgroup} ] without k8s API access..."
598616 info " ${test_command} "
599617 if ! kubectl exec -it " $pod " -- /bin/sh -c " ${test_command} " ; then
600618 # # Integration tests failed, get report screenshot
601619 warn " PODS status on failure"
602620 kubectl cp " ${pod} :/app/reports" ./reports
603621 exit 1
604622 fi
605- info " Main integration tests succeeded!!"
623+ info " Main integration tests subgroup [${subgroup} ] succeeded!!"
624+ info " Execution time: $( elapsedTimeSince " $sectionStartTime " ) "
625+ }
606626
607- info " Main tests execution time: $( elapsedTimeSince " $sectionStartTime " ) "
627+ # #####################################
628+ # ####### Main tests SUBGROUPS ########
629+ # #####################################
630+ if [[ " ${TESTS_GROUP} " == " ${ALL_TESTS} " || " ${TESTS_GROUP} " == " ${MAIN_TESTS_SUBGROUP} " * ]]; then
631+ if [[ " ${TESTS_GROUP} " == " ${ALL_TESTS} " ]]; then
632+ # Run all subgroups
633+ for group in $( seq 1 " ${EXISTENT_MAIN_TESTS_SUBGROUPS} " ) ; do
634+ subgroup=" ${MAIN_TESTS_SUBGROUP}${group} "
635+ runMainTestsSubgroup " ${subgroup} "
636+ done
637+ else
638+ # Run a specific subgroup
639+ runMainTestsSubgroup " ${TESTS_GROUP} "
640+ fi
608641fi
609642
610643# ##########################################
613646if [[ -z " ${GKE_VERSION-} " && (" ${TESTS_GROUP} " == " ${ALL_TESTS} " || " ${TESTS_GROUP} " == " ${MULTICLUSTER_TESTS} " ) ]]; then
614647 sectionStartTime=$( date +%s)
615648 info " Running multi-cluster integration tests..."
616- test_command="
617- CI_TIMEOUT_MINUTES=40 \
618- DOCKER_USERNAME=${DOCKER_USERNAME} \
619- DOCKER_PASSWORD=${DOCKER_PASSWORD} \
620- DOCKER_REGISTRY_URL=${DOCKER_REGISTRY_URL} \
621- TEST_TIMEOUT_MINUTES=${TEST_TIMEOUT_MINUTES} \
622- INTEGRATION_ENTRYPOINT=${INTEGRATION_ENTRYPOINT} \
623- USE_MULTICLUSTER_OIDC_ENV=${USE_MULTICLUSTER_OIDC_ENV} \
624- ADMIN_TOKEN=${admin_token} \
625- VIEW_TOKEN=${view_token} \
626- EDIT_TOKEN=${edit_token} \
627- yarn test \" tests/multicluster/\"
628- "
649+ test_command=$( getTestCommand " ${TESTS_GROUP} " " 40" )
629650 info " ${test_command} "
630651 if ! kubectl exec -it " $pod " -- /bin/sh -c " ${test_command} " ; then
631652 # # Integration tests failed, get report screenshot
@@ -654,16 +675,7 @@ if [[ "${TESTS_GROUP}" == "${ALL_TESTS}" || "${TESTS_GROUP}" == "${CARVEL_TESTS}
654675 k8s_wait_for_deployment kubeapps kubeapps-ci
655676
656677 info " Running carvel integration test..."
657- test_command="
658- CI_TIMEOUT_MINUTES=20 \
659- TEST_TIMEOUT_MINUTES=${TEST_TIMEOUT_MINUTES} \
660- INTEGRATION_ENTRYPOINT=${INTEGRATION_ENTRYPOINT} \
661- USE_MULTICLUSTER_OIDC_ENV=${USE_MULTICLUSTER_OIDC_ENV} \
662- ADMIN_TOKEN=${admin_token} \
663- VIEW_TOKEN=${view_token} \
664- EDIT_TOKEN=${edit_token} \
665- yarn test \" tests/carvel/\"
666- "
678+ test_command=$( getTestCommand " ${TESTS_GROUP} " " 20" )
667679 info " ${test_command} "
668680 if ! kubectl exec -it " $pod " -- /bin/sh -c " ${test_command} " ; then
669681 # # Integration tests failed, get report screenshot
@@ -693,16 +705,7 @@ if [[ "${TESTS_GROUP}" == "${ALL_TESTS}" || "${TESTS_GROUP}" == "${FLUX_TESTS}"
693705 k8s_wait_for_deployment kubeapps kubeapps-ci
694706
695707 info " Running flux integration test..."
696- test_command="
697- CI_TIMEOUT_MINUTES=20 \
698- TEST_TIMEOUT_MINUTES=${TEST_TIMEOUT_MINUTES} \
699- INTEGRATION_ENTRYPOINT=${INTEGRATION_ENTRYPOINT} \
700- USE_MULTICLUSTER_OIDC_ENV=${USE_MULTICLUSTER_OIDC_ENV} \
701- ADMIN_TOKEN=${admin_token} \
702- VIEW_TOKEN=${view_token} \
703- EDIT_TOKEN=${edit_token} \
704- yarn test \" tests/flux/\"
705- "
708+ test_command=$( getTestCommand " ${TESTS_GROUP} " " 20" )
706709 info " ${test_command} "
707710
708711 if ! kubectl exec -it " $pod " -- /bin/sh -c " ${test_command} " ; then
720723# ######################################
721724if [[ " ${TESTS_GROUP} " == " ${ALL_TESTS} " || " ${TESTS_GROUP} " == " ${OPERATOR_TESTS} " ]]; then
722725 sectionStartTime=$( date +%s)
723- # # Upgrade and run operator test
726+ # # Upgrade and run operators test
724727 # Operators are not supported in GKE 1.14 and flaky in 1.15, skipping test
725728 if [[ -z " ${GKE_VERSION-} " ]] && [[ -n " ${TEST_OPERATORS-} " ]]; then
726729 installOLM " ${OLM_VERSION} "
@@ -741,25 +744,17 @@ if [[ "${TESTS_GROUP}" == "${ALL_TESTS}" || "${TESTS_GROUP}" == "${OPERATOR_TEST
741744 info " Waiting for the OperatorHub Catalog to be ready ..."
742745 retry_while isOperatorHubCatalogRunning 24
743746
744- info " Running operator integration test with k8s API access..."
745- test_command="
746- CI_TIMEOUT_MINUTES=20 \
747- TEST_TIMEOUT_MINUTES=${TEST_TIMEOUT_MINUTES} \
748- INTEGRATION_ENTRYPOINT=${INTEGRATION_ENTRYPOINT} \
749- USE_MULTICLUSTER_OIDC_ENV=${USE_MULTICLUSTER_OIDC_ENV} \
750- ADMIN_TOKEN=${admin_token} \
751- VIEW_TOKEN=${view_token} \
752- EDIT_TOKEN=${edit_token} \
753- yarn test \" tests/operators/\"
754- "
747+ info " Running operators integration test with k8s API access..."
748+ test_command=$( getTestCommand " ${TESTS_GROUP} " " 20" )
749+ info " ${test_command} "
755750 if ! kubectl exec -it " $pod " -- /bin/sh -c " ${test_command} " ; then
756751 # # Integration tests failed, get report screenshot
757752 warn " PODS status on failure"
758753 kubectl cp " ${pod} :/app/reports" ./reports
759754 exit 1
760755 fi
761- info " Operator integration tests (with k8s API access) succeeded!!"
762- info " Operator tests execution time: $( elapsedTimeSince " $sectionStartTime " ) "
756+ info " Operators integration tests (with k8s API access) succeeded!!"
757+ info " Operators tests execution time: $( elapsedTimeSince " $sectionStartTime " ) "
763758 fi
764759fi
765760
@@ -806,19 +801,7 @@ if [[ -z "${GKE_VERSION-}" && ("${TESTS_GROUP}" == "${ALL_TESTS}" || "${TESTS_GR
806801 info " Waiting for updated Kubeapps components to be ready..."
807802 k8s_wait_for_deployment kubeapps kubeapps-ci
808803
809- test_command="
810- CI_TIMEOUT_MINUTES=40 \
811- DOCKER_USERNAME=${DOCKER_USERNAME} \
812- DOCKER_PASSWORD=${DOCKER_PASSWORD} \
813- DOCKER_REGISTRY_URL=${DOCKER_REGISTRY_URL} \
814- TEST_TIMEOUT_MINUTES=${TEST_TIMEOUT_MINUTES} \
815- INTEGRATION_ENTRYPOINT=${INTEGRATION_ENTRYPOINT} \
816- USE_MULTICLUSTER_OIDC_ENV=${USE_MULTICLUSTER_OIDC_ENV} \
817- ADMIN_TOKEN=${admin_token} \
818- VIEW_TOKEN=${view_token} \
819- EDIT_TOKEN=${edit_token} \
820- yarn test \" tests/multicluster-nokubeapps/\"
821- "
804+ test_command=$( getTestCommand " ${TESTS_GROUP} " " 40" )
822805 info " ${test_command} "
823806
824807 if ! kubectl exec -it " $pod " -- /bin/sh -c " ${test_command} " ; then
@@ -828,9 +811,7 @@ if [[ -z "${GKE_VERSION-}" && ("${TESTS_GROUP}" == "${ALL_TESTS}" || "${TESTS_GR
828811 exit 1
829812 fi
830813 info " Multi-cluster integration tests succeeded!!"
831-
832- sectionEndTime=$( date +%s)
833- info " Multi-cluster tests execution time: $( formattedElapsedTime sectionEndTime-sectionStartTime) "
814+ info " Multi-cluster tests execution time:$( elapsedTimeSince " $sectionStartTime " ) "
834815fi
835816
836817info " Integration tests succeeded!"
0 commit comments