You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by ga...@apache.org on 2019/07/23 19:25:36 UTC

[flink] 02/03: [hotfix][tests] Improve wait_job_terminal_state() function

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

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

commit 0d5d0eed68c9fcc03ecad5aa3855038114fcfde2
Author: Gary Yao <ga...@apache.org>
AuthorDate: Tue Jul 9 15:05:03 2019 +0200

    [hotfix][tests] Improve wait_job_terminal_state() function
    
    Always terminate script if job is in globally terminal state. Assert that
    expected terminal state matches actual state.
---
 flink-end-to-end-tests/test-scripts/common.sh | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/flink-end-to-end-tests/test-scripts/common.sh b/flink-end-to-end-tests/test-scripts/common.sh
index 10061d1..714150c 100644
--- a/flink-end-to-end-tests/test-scripts/common.sh
+++ b/flink-end-to-end-tests/test-scripts/common.sh
@@ -450,17 +450,23 @@ function wait_job_running {
 
 function wait_job_terminal_state {
   local job=$1
-  local terminal_state=$2
+  local expected_terminal_state=$2
 
-  echo "Waiting for job ($job) to reach terminal state $terminal_state ..."
+  echo "Waiting for job ($job) to reach terminal state $expected_terminal_state ..."
 
   while : ; do
-    N=$(grep -o "Job $job reached globally terminal state $terminal_state" $FLINK_DIR/log/*standalonesession*.log | tail -1 || true)
-
+    local N=$(grep -o "Job $job reached globally terminal state .*" $FLINK_DIR/log/*standalonesession*.log | tail -1 || true)
     if [[ -z $N ]]; then
       sleep 1
     else
-      break
+      local actual_terminal_state=$(echo $N | sed -n 's/.*state \([A-Z]*\).*/\1/p')
+      if [[ -z $expected_terminal_state ]] || [[ "$expected_terminal_state" == "$actual_terminal_state" ]]; then
+        echo "Job ($job) reached terminal state $actual_terminal_state"
+        break
+      else
+        echo "Job ($job) is in state $actual_terminal_state but expected $expected_terminal_state"
+        exit 1
+      fi
     fi
   done
 }