Skip to content

Commit

Permalink
scripts: Remove PASSES in test-e2e.sh
Browse files Browse the repository at this point in the history
Signed-off-by: sharath sivakumar <[email protected]>
  • Loading branch information
sharath sivakumar committed Nov 30, 2023
1 parent f4238aa commit 060cd29
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 40 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ function robustness_pass {

function integration_e2e_pass {
run_pass "integration" "${@}"
run_pass "e2e" "${@}"
test_executor "e2e_test" "${@}"
}

# generic_checker [cmd...]
Expand Down
32 changes: 3 additions & 29 deletions scripts/test_e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
Expand Down Expand Up @@ -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

Expand Down
30 changes: 23 additions & 7 deletions scripts/test_lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

# 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[@]:-} "$@"
}

0 comments on commit 060cd29

Please sign in to comment.