You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by ch...@apache.org on 2018/07/16 14:49:23 UTC
[3/3] flink git commit: [FLINK-9380][tests] Do not delete logs on E2E
test failure
[FLINK-9380][tests] Do not delete logs on E2E test failure
This closes #6289.
Project: http://git-wip-us.apache.org/repos/asf/flink/repo
Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/07777536
Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/07777536
Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/07777536
Branch: refs/heads/master
Commit: 0777753614ff2fad2847ba7e7c801a706eb06bed
Parents: 010f665
Author: Deepak Sharnma <de...@gmail.com>
Authored: Mon Jul 9 15:37:58 2018 -0400
Committer: zentol <ch...@apache.org>
Committed: Mon Jul 16 14:09:42 2018 +0200
----------------------------------------------------------------------
flink-end-to-end-tests/test-scripts/common.sh | 15 ++++---
.../test-scripts/test-runner-common.sh | 41 ++++++++++++++------
2 files changed, 38 insertions(+), 18 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flink/blob/07777536/flink-end-to-end-tests/test-scripts/common.sh
----------------------------------------------------------------------
diff --git a/flink-end-to-end-tests/test-scripts/common.sh b/flink-end-to-end-tests/test-scripts/common.sh
index e5ad458..941e6d1 100644
--- a/flink-end-to-end-tests/test-scripts/common.sh
+++ b/flink-end-to-end-tests/test-scripts/common.sh
@@ -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
http://git-wip-us.apache.org/repos/asf/flink/blob/07777536/flink-end-to-end-tests/test-scripts/test-runner-common.sh
----------------------------------------------------------------------
diff --git a/flink-end-to-end-tests/test-scripts/test-runner-common.sh b/flink-end-to-end-tests/test-scripts/test-runner-common.sh
index 8758da0..fee67a4 100644
--- a/flink-end-to-end-tests/test-scripts/test-runner-common.sh
+++ b/flink-end-to-end-tests/test-scripts/test-runner-common.sh
@@ -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