提交 07777536 编写于 作者: D Deepak Sharnma 提交者: zentol

[FLINK-9380][tests] Do not delete logs on E2E test failure

This closes #6289.
上级 010f6654
......@@ -37,16 +37,11 @@ export EXIT_CODE=0
echo "Flink dist directory: $FLINK_DIR"
TEST_ROOT=`pwd`
TEST_INFRA_DIR="$0"
TEST_INFRA_DIR=`dirname "$TEST_INFRA_DIR"`
TEST_INFRA_DIR="$END_TO_END_DIR/test-scripts/"
cd $TEST_INFRA_DIR
TEST_INFRA_DIR=`pwd`
cd $TEST_ROOT
# used to randomize created directories
export TEST_DATA_DIR=$TEST_INFRA_DIR/temp-test-directory-$(date +%S%N)
echo "TEST_DATA_DIR: $TEST_DATA_DIR"
function print_mem_use_osx {
declare -a mem_types=("active" "inactive" "wired down")
used=""
......@@ -280,6 +275,12 @@ function check_logs_for_non_empty_out_files {
fi
}
function shutdown_all {
stop_cluster
tm_kill_all
jm_kill_all
}
function stop_cluster {
"$FLINK_DIR"/bin/stop-cluster.sh
......@@ -536,10 +537,12 @@ function end_timer {
function clean_stdout_files {
rm ${FLINK_DIR}/log/*.out
echo "Deleted all stdout files under ${FLINK_DIR}/log/"
}
function clean_log_files {
rm ${FLINK_DIR}/log/*
echo "Deleted all files under ${FLINK_DIR}/log/"
}
# Expect a string to appear in the log files of the task manager before a given timeout
......
......@@ -32,6 +32,11 @@ function run_test {
printf "\n==============================================================================\n"
printf "Running '${description}'\n"
printf "==============================================================================\n"
# used to randomize created directories
export TEST_DATA_DIR=$TEST_INFRA_DIR/temp-test-directory-$(date +%S%N)
echo "TEST_DATA_DIR: $TEST_DATA_DIR"
start_timer
${command}
exit_code="$?"
......@@ -41,8 +46,8 @@ function run_test {
check_logs_for_exceptions
check_logs_for_non_empty_out_files
cleanup
# Investigate exit_code for failures of test executable as well as EXIT_CODE for failures of the test.
# Do not clean up if either fails.
if [[ ${exit_code} == 0 ]]; then
if [[ ${EXIT_CODE} != 0 ]]; then
printf "\n[FAIL] '${description}' failed after ${time_elapsed}! Test exited with exit code 0 but the logs contained errors, exceptions or non-empty .out files\n\n"
......@@ -58,20 +63,32 @@ function run_test {
fi
fi
if [[ ${exit_code} != 0 ]]; then
if [[ ${exit_code} == 0 ]]; then
cleanup
else
exit "${exit_code}"
fi
}
# Shuts down the cluster and cleans up all temporary folders and files. Make sure to clean up even in case of failures.
# Shuts down cluster and reverts changes to cluster configs
function cleanup_proc {
shutdown_all
revert_default_config
}
# Cleans up all temporary folders and files
function cleanup_tmp_files {
clean_log_files
rm -rf ${TEST_DATA_DIR} 2> /dev/null
echo "Deleted ${TEST_DATA_DIR}"
}
# Shuts down the cluster and cleans up all temporary folders and files.
function cleanup {
stop_cluster
tm_kill_all
jm_kill_all
rm -rf $TEST_DATA_DIR 2> /dev/null
revert_default_config
clean_log_files
clean_stdout_files
cleanup_proc
cleanup_tmp_files
}
trap cleanup EXIT
trap cleanup SIGINT
trap cleanup_proc EXIT
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册