This is an automated email from the ASF dual-hosted git repository.

dwysakowicz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink.git

commit 5c772f0a9cb5f8ac8e3f850a0278a75c5fa059d5
Author: Dawid Wysakowicz <dwysakow...@apache.org>
AuthorDate: Thu Feb 11 12:24:29 2021 +0100

    [hotfix] Add timeout to bash scripts waiting for an event
---
 flink-end-to-end-tests/test-scripts/common.sh      | 22 ++++++++++++++++++++++
 .../test-scripts/test_stream_state_ttl.sh          |  2 +-
 2 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/flink-end-to-end-tests/test-scripts/common.sh 
b/flink-end-to-end-tests/test-scripts/common.sh
index 3c7c256..0a26c8e 100644
--- a/flink-end-to-end-tests/test-scripts/common.sh
+++ b/flink-end-to-end-tests/test-scripts/common.sh
@@ -640,6 +640,8 @@ function wait_oper_metric_num_in_records {
     JOB_NAME="${3:-General purpose test job}"
     NUM_METRICS=$(get_num_metric_samples ${OPERATOR} '${JOB_NAME}')
     OLD_NUM_METRICS=${4:-${NUM_METRICS}}
+    local timeout="${5:-600}"
+    local i=0
     # monitor the numRecordsIn metric of the state machine operator in the 
second execution
     # we let the test finish once the second restore execution has processed 
200 records
     while : ; do
@@ -654,6 +656,11 @@ function wait_oper_metric_num_in_records {
       if (( $NUM_RECORDS < $MAX_NUM_METRICS )); then
         echo "Waiting for job to process up to ${MAX_NUM_METRICS} records, 
current progress: ${NUM_RECORDS} records ..."
         sleep 1
+        ((i++))
+        if ((i > timeout)); then
+            echo "A timeout occurred waiting for job to process up to 
${MAX_NUM_METRICS} records"
+            exit 1
+        fi
       else
         break
       fi
@@ -664,6 +671,8 @@ function wait_num_of_occurence_in_logs {
     local text=$1
     local number=$2
     local logs=${3:-standalonesession}
+    local timeout="${4:-600}"
+    local i=0
 
     echo "Waiting for text ${text} to appear ${number} of times in logs..."
 
@@ -676,15 +685,23 @@ function wait_num_of_occurence_in_logs {
 
       if (( N < number )); then
         sleep 1
+        ((i++))
+        if ((i > timeout)); then
+            echo "A timeout occurred waiting for ${text} to appear ${number} 
of times in logs."
+            exit 1
+        fi
       else
         break
       fi
     done
+
 }
 
 function wait_num_checkpoints {
     JOB=$1
     NUM_CHECKPOINTS=$2
+    local timeout="${3:-600}"
+    local i=0
 
     echo "Waiting for job ($JOB) to have at least $NUM_CHECKPOINTS completed 
checkpoints ..."
 
@@ -697,6 +714,11 @@ function wait_num_checkpoints {
 
       if (( N < NUM_CHECKPOINTS )); then
         sleep 1
+        ((i++))
+        if ((i > timeout)); then
+            echo "A timeout occurred waiting for job ($JOB) to have at least 
$NUM_CHECKPOINTS completed checkpoints ."
+            exit 1
+        fi
       else
         break
       fi
diff --git a/flink-end-to-end-tests/test-scripts/test_stream_state_ttl.sh 
b/flink-end-to-end-tests/test-scripts/test_stream_state_ttl.sh
index d1e0c34..5306842 100755
--- a/flink-end-to-end-tests/test-scripts/test_stream_state_ttl.sh
+++ b/flink-end-to-end-tests/test-scripts/test_stream_state_ttl.sh
@@ -75,7 +75,7 @@ wait_oper_metric_num_in_records TtlVerifyUpdateFunction.0 
${UPDATE_NUM} "State T
 
 # if verification fails job produces failed TTL'ed state updates,
 # output would be non-empty and contains TTL verification failed:
-local EXIT_CODE=0
+EXIT_CODE=0
 check_logs_for_non_empty_out_files
 
 if [ $EXIT_CODE != 0 ]; then

Reply via email to