diff --git a/Makefile b/Makefile index 844953b8421..2793f884d20 100644 --- a/Makefile +++ b/Makefile @@ -27,7 +27,7 @@ GO_TEST_FLAGS?= .PHONY: test test: PASSES="unit integration release" ./scripts/test.sh $(GO_TEST_FLAGS) - PASSES="e2e" ./scripts/test_e2e.sh $(GO_TEST_FLAGS) + ./scripts/test_e2e.sh $(GO_TEST_FLAGS) .PHONY: test-unit test-unit: @@ -39,7 +39,7 @@ test-integration: .PHONY: test-e2e test-e2e: build - PASSES="e2e" ./scripts/test_e2e.sh $(GO_TEST_FLAGS) + ./scripts/test_e2e.sh $(GO_TEST_FLAGS) .PHONY: test-grpcproxy-integration test-grpcproxy-integration: @@ -52,7 +52,7 @@ test-grpcproxy-e2e: build .PHONY: test-e2e-release test-e2e-release: build PASSES="release" ./scripts/test.sh $(GO_TEST_FLAGS) - PASSES="e2e" ./scripts/test_e2e.sh $(GO_TEST_FLAGS) + ./scripts/test_e2e.sh $(GO_TEST_FLAGS) .PHONY: test-robustness test-robustness: diff --git a/scripts/test.sh b/scripts/test.sh index 7be2b6c4eef..1d464e17a0a 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -136,7 +136,7 @@ function robustness_pass { function integration_e2e_pass { run_pass "integration" "${@}" - run_pass "e2e" "${@}" + test_executor "e2e_test" "${@}" } # generic_checker [cmd...] diff --git a/scripts/test_e2e.sh b/scripts/test_e2e.sh index 13b20196eb1..7d6478f9130 100755 --- a/scripts/test_e2e.sh +++ b/scripts/test_e2e.sh @@ -26,7 +26,6 @@ if [ -n "${OUTPUT_FILE}" ]; then exec > >(tee -a "${OUTPUT_FILE}") 2>&1 fi -PASSES=${PASSES:-"gofmt bom dep build unit"} KEEP_GOING_SUITE=${KEEP_GOING_SUITE:-false} PKG=${PKG:-} SHELLCHECK_VERSION=${SHELLCHECK_VERSION:-"v0.8.0"} @@ -59,43 +58,18 @@ if [ -n "${TESTCASE:-}" ]; then RUN_ARG=("-run=${TESTCASE}") fi -################Run e2e tests############################################### -function e2e_pass { - # e2e tests are running pre-build binary. Settings like --race,-cover,-cpu does not have any impact. - # shellcheck disable=SC2068 - run_for_module "tests" go_test "./e2e/..." "keep_going" : -timeout="${TIMEOUT:-30m}" ${RUN_ARG[@]:-} "$@" || return $? - # shellcheck disable=SC2068 - run_for_module "tests" go_test "./common/..." "keep_going" : --tags=e2e -timeout="${TIMEOUT:-30m}" ${RUN_ARG[@]:-} "$@" -} -########### MAIN ############################################################### -function run_pass { - local pass="${1}" - shift 1 - log_callout -e "\\n'${pass}' started at $(date)" - if "${pass}_pass" "$@" ; then - log_success "'${pass}' PASSED and completed at $(date)" - return 0 - else - log_error "FAIL: '${pass}' FAILED at $(date)" - if [ "$KEEP_GOING_SUITE" = true ]; then - return 2 - else - exit 255 - fi - fi -} - +################### MAIN ############################################################## log_callout "Starting at: $(date)" fail_flag=false - if run_pass "${PASSES}" "${@}"; then + if test_executor "e2e_test" "${@}"; then : else fail_flag=true fi if [ "$fail_flag" = true ]; then - log_error "There was FAILURE in the e2e test suite run. Look above log detail" + log_error "There was FAILURE in the e2e test suite run. Look above for log detail" exit 255 fi diff --git a/scripts/test_lib.sh b/scripts/test_lib.sh index 6f9072fad47..4e4d766a5c2 100755 --- a/scripts/test_lib.sh +++ b/scripts/test_lib.sh @@ -453,19 +453,35 @@ function git_assert_branch_in_sync { fi } -function run_pass { - local pass="${1}" +# Generic function to execute specific test functions +function test_executor { + local test_function="${1}" shift 1 - log_callout -e "\\n'${pass}' started at $(date)" - if "${pass}_pass" "$@" ; then - log_success "'${pass}' PASSED and completed at $(date)" + log_callout -e "\\n'${test_function}' started at $(date)" + if "${test_function}" "$@" ; then + log_success "'${test_function}' PASSED and completed at $(date)" return 0 else - log_error "FAIL: '${pass}' FAILED at $(date)" + log_error "FAIL: '${test_function}' FAILED at $(date)" if [ "$KEEP_GOING_SUITE" = true ]; then return 2 else exit 255 fi fi -} \ No newline at end of file +} + +# execute integration test and e2e tests +function integration_e2e_pass { + run_pass "integration" "${@}" + test_executor "e2e_test" "${@}" +} + +################Run e2e tests############################################### +function e2e_test { + # e2e tests are running pre-build binary. Settings like --race,-cover,-cpu does not have any impact. + # shellcheck disable=SC2068 + run_for_module "tests" go_test "./e2e/..." "keep_going" : -timeout="${TIMEOUT:-30m}" ${RUN_ARG[@]:-} "$@" || return $? + # shellcheck disable=SC2068 + run_for_module "tests" go_test "./common/..." "keep_going" : --tags=e2e -timeout="${TIMEOUT:-30m}" ${RUN_ARG[@]:-} "$@" +}