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

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


The following commit(s) were added to refs/heads/master by this push:
     new 9c4ebeb7adf [Enhancement]use awaitility.await() in schema testcases 
#37817 (#38869)
9c4ebeb7adf is described below

commit 9c4ebeb7adf8c1c40b39189b2572433cb1c3c610
Author: Vallish Pai <vallish...@gmail.com>
AuthorDate: Wed Aug 21 12:32:53 2024 +0530

    [Enhancement]use awaitility.await() in schema testcases #37817 (#38869)
    
    ## Proposed changes
    
    Issue Number: close #xxx
    #37817
    use awaitility.await() in schema testcases(part2)
    
    Co-authored-by: Xinyi Zou <zouxiny...@gmail.com>
---
 .../test_dup_keys_schema_change.groovy             | 27 ++++++--------
 .../test_dup_mv_schema_change.groovy               | 23 +++++-------
 .../test_dup_rollup_schema_change.groovy           | 23 +++++-------
 .../test_dup_vals_schema_change.groovy             | 10 ++---
 .../test_uniq_keys_schema_change.groovy            | 10 ++---
 .../test_uniq_mv_schema_change.groovy              | 26 ++++++-------
 .../test_uniq_rollup_schema_change.groovy          | 43 +++++++++-------------
 .../test_uniq_vals_schema_change.groovy            |  9 ++---
 8 files changed, 71 insertions(+), 100 deletions(-)

diff --git 
a/regression-test/suites/schema_change_p0/test_dup_keys_schema_change.groovy 
b/regression-test/suites/schema_change_p0/test_dup_keys_schema_change.groovy
index 336805df29a..19b1c96ce4b 100644
--- a/regression-test/suites/schema_change_p0/test_dup_keys_schema_change.groovy
+++ b/regression-test/suites/schema_change_p0/test_dup_keys_schema_change.groovy
@@ -16,6 +16,8 @@
 // under the License.
 
 import org.codehaus.groovy.runtime.IOGroovyMethods
+import java.util.concurrent.TimeUnit
+import org.awaitility.Awaitility
 
 suite ("test_dup_keys_schema_change") {
     def tableName = "schema_change_dup_keys_regression_test"
@@ -98,20 +100,15 @@ suite ("test_dup_keys_schema_change") {
         sql """
             ALTER TABLE ${tableName} DROP COLUMN sex
             """
-        int max_try_time = 3000
-        while (max_try_time--){
+        int max_try_time = 300
+        Awaitility.await().atMost(max_try_time, 
TimeUnit.SECONDS).with().pollDelay(100, TimeUnit.MILLISECONDS).await().until(() 
-> {
             String result = getJobState(tableName)
             if (result == "FINISHED") {
-                sleep(3000)
-                break
-            } else {
-                sleep(100)
-                if (max_try_time < 1){
-                    assertEquals(1,2)
-                }
+                return true;
             }
-        }
-        Thread.sleep(1000)
+            return false;
+        });
+
         qt_sc """ select * from ${tableName} where user_id = 3 order by 
new_column """
 
 
@@ -154,9 +151,7 @@ suite ("test_dup_keys_schema_change") {
 
         // wait for all compactions done
         for (String[] tablet in tablets) {
-                boolean running = true
-                do {
-                    Thread.sleep(100)
+                Awaitility.await().untilAsserted(() -> {
                     String tablet_id = tablet[0]
                     backend_id = tablet[2]
                     (code, out, err) = 
be_get_compaction_status(backendId_to_backendIP.get(backend_id), 
backendId_to_backendHttpPort.get(backend_id), tablet_id)
@@ -164,8 +159,8 @@ suite ("test_dup_keys_schema_change") {
                     assertEquals(code, 0)
                     def compactionStatus = parseJson(out.trim())
                     assertEquals("success", 
compactionStatus.status.toLowerCase())
-                    running = compactionStatus.run_status
-                } while (running)
+                    return compactionStatus.run_status;
+                });
         }
 
         qt_sc """ select count(*) from ${tableName} """
diff --git 
a/regression-test/suites/schema_change_p0/test_dup_mv_schema_change.groovy 
b/regression-test/suites/schema_change_p0/test_dup_mv_schema_change.groovy
index e09da2af730..2896470e2a9 100644
--- a/regression-test/suites/schema_change_p0/test_dup_mv_schema_change.groovy
+++ b/regression-test/suites/schema_change_p0/test_dup_mv_schema_change.groovy
@@ -16,6 +16,8 @@
 // under the License.
 
 import org.codehaus.groovy.runtime.IOGroovyMethods
+import java.util.concurrent.TimeUnit
+import org.awaitility.Awaitility
 
 suite ("test_dup_mv_schema_change") {
     def tableName = "schema_change_dup_mv_regression_test"
@@ -25,18 +27,13 @@ suite ("test_dup_mv_schema_change") {
     }
 
     def waitForJob =  (tbName, timeout) -> {
-        while (timeout--){
+       Awaitility.await().atMost(timeout, 
TimeUnit.SECONDS).with().pollDelay(100, TimeUnit.MILLISECONDS).await().until(() 
-> {
             String result = getJobState(tbName)
             if (result == "FINISHED") {
-                sleep(3000)
-                break
-            } else {
-                sleep(100)
-                if (timeout < 1){
-                    assertEquals(1,2)
-                }
+                return true;
             }
-        }
+            return false;
+        });
     }
     try {
         String backend_id;
@@ -164,9 +161,7 @@ suite ("test_dup_mv_schema_change") {
 
         // wait for all compactions done
         for (String[] tablet in tablets) {
-                boolean running = true
-                do {
-                    Thread.sleep(100)
+                Awaitility.await().untilAsserted(() -> {
                     String tablet_id = tablet[0]
                     backend_id = tablet[2]
                     (code, out, err) = 
be_get_compaction_status(backendId_to_backendIP.get(backend_id), 
backendId_to_backendHttpPort.get(backend_id), tablet_id)
@@ -174,8 +169,8 @@ suite ("test_dup_mv_schema_change") {
                     assertEquals(code, 0)
                     def compactionStatus = parseJson(out.trim())
                     assertEquals("success", 
compactionStatus.status.toLowerCase())
-                    running = compactionStatus.run_status
-                } while (running)
+                    return compactionStatus.run_status;
+                });
         }
 
         qt_sc """ select count(*) from ${tableName} """
diff --git 
a/regression-test/suites/schema_change_p0/test_dup_rollup_schema_change.groovy 
b/regression-test/suites/schema_change_p0/test_dup_rollup_schema_change.groovy
index eea771d400c..b97f8c78b6f 100644
--- 
a/regression-test/suites/schema_change_p0/test_dup_rollup_schema_change.groovy
+++ 
b/regression-test/suites/schema_change_p0/test_dup_rollup_schema_change.groovy
@@ -16,6 +16,8 @@
 // under the License.
 
 import org.codehaus.groovy.runtime.IOGroovyMethods
+import java.util.concurrent.TimeUnit
+import org.awaitility.Awaitility
 
 suite ("test_dup_rollup_schema_change") {
     def getMVJobState = { tableName ->
@@ -27,18 +29,13 @@ suite ("test_dup_rollup_schema_change") {
          return jobStateResult[0][9]
     }
     def waitForMVJob =  (tbName, timeout) -> {
-        while (timeout--){
+       Awaitility.await().atMost(timeout, 
TimeUnit.SECONDS).with().pollDelay(100, TimeUnit.MILLISECONDS).await().until(() 
-> {
             String result = getMVJobState(tbName)
             if (result == "FINISHED") {
-                sleep(3000)
-                break
-            } else {
-                sleep(100)
-                if (timeout < 1){
-                    assertEquals(1,2)
-                }
+                return true;
             }
-        }
+            return false;
+        });
     }
 
     def tableName = "schema_change_dup_rollup_regression_test"
@@ -182,9 +179,7 @@ suite ("test_dup_rollup_schema_change") {
 
         // wait for all compactions done
         for (String[] tablet in tablets) {
-                boolean running = true
-                do {
-                    Thread.sleep(100)
+           Awaitility.await().untilAsserted(() -> {
                     String tablet_id = tablet[0]
                     backend_id = tablet[2]
                     (code, out, err) = 
be_get_compaction_status(backendId_to_backendIP.get(backend_id), 
backendId_to_backendHttpPort.get(backend_id), tablet_id)
@@ -192,8 +187,8 @@ suite ("test_dup_rollup_schema_change") {
                     assertEquals(code, 0)
                     def compactionStatus = parseJson(out.trim())
                     assertEquals("success", 
compactionStatus.status.toLowerCase())
-                    running = compactionStatus.run_status
-                } while (running)
+                    return compactionStatus.run_status;
+                });
         }
 
         qt_sc """ select count(*) from ${tableName} """
diff --git 
a/regression-test/suites/schema_change_p0/test_dup_vals_schema_change.groovy 
b/regression-test/suites/schema_change_p0/test_dup_vals_schema_change.groovy
index c73d13d0720..db5c4bbd869 100644
--- a/regression-test/suites/schema_change_p0/test_dup_vals_schema_change.groovy
+++ b/regression-test/suites/schema_change_p0/test_dup_vals_schema_change.groovy
@@ -16,6 +16,8 @@
 // under the License.
 
 import org.codehaus.groovy.runtime.IOGroovyMethods
+import java.util.concurrent.TimeUnit
+import org.awaitility.Awaitility
 
 suite ("test_dup_vals_schema_change") {
     def tableName = "schema_change_dup_vals_regression_test"
@@ -137,9 +139,7 @@ suite ("test_dup_vals_schema_change") {
 
         // wait for all compactions done
         for (String[] tablet in tablets) {
-                boolean running = true
-                do {
-                    Thread.sleep(100)
+            Awaitility.await().untilAsserted(() -> {
                     String tablet_id = tablet[0]
                     backend_id = tablet[2]
                     (code, out, err) = 
be_get_compaction_status(backendId_to_backendIP.get(backend_id), 
backendId_to_backendHttpPort.get(backend_id), tablet_id)
@@ -147,8 +147,8 @@ suite ("test_dup_vals_schema_change") {
                     assertEquals(code, 0)
                     def compactionStatus = parseJson(out.trim())
                     assertEquals("success", 
compactionStatus.status.toLowerCase())
-                    running = compactionStatus.run_status
-                } while (running)
+                    return compactionStatus.run_status;
+                });
         }
         qt_sc """ select count(*) from ${tableName} """
 
diff --git 
a/regression-test/suites/schema_change_p0/test_uniq_keys_schema_change.groovy 
b/regression-test/suites/schema_change_p0/test_uniq_keys_schema_change.groovy
index e06c27b8abf..856f49acd2b 100644
--- 
a/regression-test/suites/schema_change_p0/test_uniq_keys_schema_change.groovy
+++ 
b/regression-test/suites/schema_change_p0/test_uniq_keys_schema_change.groovy
@@ -16,6 +16,8 @@
 // under the License.
 
 import org.codehaus.groovy.runtime.IOGroovyMethods
+import java.util.concurrent.TimeUnit
+import org.awaitility.Awaitility
 
 suite ("test_uniq_keys_schema_change") {
     def tableName = "schema_change_uniq_keys_regression_test"
@@ -132,9 +134,7 @@ suite ("test_uniq_keys_schema_change") {
 
         // wait for all compactions done
         for (String[] tablet in tablets) {
-                boolean running = true
-                do {
-                    Thread.sleep(100)
+                Awaitility.await().untilAsserted(() -> {
                     String tablet_id = tablet[0]
                     backend_id = tablet[2]
                     (code, out, err) = 
be_get_compaction_status(backendId_to_backendIP.get(backend_id), 
backendId_to_backendHttpPort.get(backend_id), tablet_id)
@@ -142,8 +142,8 @@ suite ("test_uniq_keys_schema_change") {
                     assertEquals(code, 0)
                     def compactionStatus = parseJson(out.trim())
                     assertEquals("success", 
compactionStatus.status.toLowerCase())
-                    running = compactionStatus.run_status
-                } while (running)
+                    return compactionStatus.run_status;
+                });
         }
         qt_sc """ select count(*) from ${tableName} """
 
diff --git 
a/regression-test/suites/schema_change_p0/test_uniq_mv_schema_change.groovy 
b/regression-test/suites/schema_change_p0/test_uniq_mv_schema_change.groovy
index 25230721047..54a790248b3 100644
--- a/regression-test/suites/schema_change_p0/test_uniq_mv_schema_change.groovy
+++ b/regression-test/suites/schema_change_p0/test_uniq_mv_schema_change.groovy
@@ -16,6 +16,8 @@
 // under the License.
 
 import org.codehaus.groovy.runtime.IOGroovyMethods
+import java.util.concurrent.TimeUnit
+import org.awaitility.Awaitility
 
 suite ("test_uniq_mv_schema_change") {
     def tableName = "schema_change_uniq_mv_regression_test"
@@ -24,18 +26,14 @@ suite ("test_uniq_mv_schema_change") {
          return jobStateResult[0][8]
     }
     def waitForJob =  (tbName, timeout) -> {
-        while (timeout--){
+       Awaitility.await().atMost(timeout, 
TimeUnit.SECONDS).with().pollDelay(100, TimeUnit.MILLISECONDS).await().until(() 
-> {
             String result = getMVJobState(tbName)
             if (result == "FINISHED") {
-                sleep(3000)
-                break
-            } else {
-                sleep(100)
-                if (timeout < 1){
-                    assertEquals(1,2)
-                }
-            }
-        }
+                return true;
+            } 
+            return false;
+        });
+        // when timeout awaitlity will raise a exception.
     }
 
     try {
@@ -179,9 +177,7 @@ suite ("test_uniq_mv_schema_change") {
 
     // wait for all compactions done
     for (String[] tablet in tablets) {
-            boolean running = true
-            do {
-                Thread.sleep(100)
+            Awaitility.await().untilAsserted(() -> {
                 String tablet_id = tablet[0]
                 backend_id = tablet[2]
                 (code, out, err) = 
be_get_compaction_status(backendId_to_backendIP.get(backend_id), 
backendId_to_backendHttpPort.get(backend_id), tablet_id)
@@ -189,8 +185,8 @@ suite ("test_uniq_mv_schema_change") {
                 assertEquals(code, 0)
                 def compactionStatus = parseJson(out.trim())
                 assertEquals("success", compactionStatus.status.toLowerCase())
-                running = compactionStatus.run_status
-            } while (running)
+                return compactionStatus.run_status;
+            });
     }
     qt_sc """ select count(*) from ${tableName} """
 
diff --git 
a/regression-test/suites/schema_change_p0/test_uniq_rollup_schema_change.groovy 
b/regression-test/suites/schema_change_p0/test_uniq_rollup_schema_change.groovy
index 06fa33ac1cf..1b82e913e05 100644
--- 
a/regression-test/suites/schema_change_p0/test_uniq_rollup_schema_change.groovy
+++ 
b/regression-test/suites/schema_change_p0/test_uniq_rollup_schema_change.groovy
@@ -16,6 +16,8 @@
 // under the License.
 
 import org.codehaus.groovy.runtime.IOGroovyMethods
+import java.util.concurrent.TimeUnit
+import org.awaitility.Awaitility
 
 suite ("test_uniq_rollup_schema_change") {
     def tableName = "schema_change_uniq_rollup_regression_test"
@@ -28,18 +30,14 @@ suite ("test_uniq_rollup_schema_change") {
          return jobStateResult[0][9]
     }
     def waitForMVJob =  (tbName, timeout) -> {
-        while (timeout--){
+        Awaitility.await().atMost(timeout, 
TimeUnit.SECONDS).with().pollDelay(100, TimeUnit.MILLISECONDS).await().until(() 
-> {
             String result = getMVJobState(tbName)
             if (result == "FINISHED") {
-                sleep(3000)
-                break
-            } else {
-                sleep(100)
-                if (timeout < 1){
-                    assertEquals(1,2)
-                }
-            }
-        }
+                return true;
+            } 
+            return false;
+        });
+        // when timeout awaitlity will raise a exception.
     }
 
     try {
@@ -79,7 +77,7 @@ suite ("test_uniq_rollup_schema_change") {
     //add rollup
     def rollupName = "rollup_cost"
     sql "ALTER TABLE ${tableName} ADD ROLLUP 
${rollupName}(`user_id`,`date`,`city`,`sex`, `age`,`cost`);"
-    waitForMVJob(tableName, 3000)
+    waitForMVJob(tableName, 300)
 
     sql """ INSERT INTO ${tableName} VALUES
              (2, '2017-10-01', 'Beijing', 10, 1, '2020-01-02', '2020-01-02', 
'2020-01-02', 1, 31, 21)
@@ -133,19 +131,14 @@ suite ("test_uniq_rollup_schema_change") {
           ALTER TABLE ${tableName} DROP COLUMN cost
           """
 
-    max_try_time = 3000
-    while (max_try_time--){
+    max_try_time = 300
+    Awaitility.await().atMost(max_try_time, 
TimeUnit.SECONDS).with().pollDelay(100, TimeUnit.MILLISECONDS).await().until(() 
-> {
         String result = getJobState(tableName)
         if (result == "FINISHED") {
-            sleep(3000)
-            break
-        } else {
-            sleep(100)
-            if (max_try_time < 1){
-                assertEquals(1,2)
-            }
+            return true;
         }
-    }
+        return false;
+    });
 
     qt_sc """ select * from ${tableName} where user_id = 3 """
 
@@ -187,9 +180,7 @@ suite ("test_uniq_rollup_schema_change") {
 
     // wait for all compactions done
     for (String[] tablet in tablets) {
-            boolean running = true
-            do {
-                Thread.sleep(100)
+            Awaitility.await().untilAsserted(() -> {
                 String tablet_id = tablet[0]
                 backend_id = tablet[2]
                 (code, out, err) = 
be_get_compaction_status(backendId_to_backendIP.get(backend_id), 
backendId_to_backendHttpPort.get(backend_id), tablet_id)
@@ -197,8 +188,8 @@ suite ("test_uniq_rollup_schema_change") {
                 assertEquals(code, 0)
                 def compactionStatus = parseJson(out.trim())
                 assertEquals("success", compactionStatus.status.toLowerCase())
-                running = compactionStatus.run_status
-            } while (running)
+                return compactionStatus.run_status;
+            });
     }
     qt_sc """ select count(*) from ${tableName} """
 
diff --git 
a/regression-test/suites/schema_change_p0/test_uniq_vals_schema_change.groovy 
b/regression-test/suites/schema_change_p0/test_uniq_vals_schema_change.groovy
index 016aedb1644..7dc530cecb8 100644
--- 
a/regression-test/suites/schema_change_p0/test_uniq_vals_schema_change.groovy
+++ 
b/regression-test/suites/schema_change_p0/test_uniq_vals_schema_change.groovy
@@ -16,6 +16,7 @@
 // under the License.
 
 import org.codehaus.groovy.runtime.IOGroovyMethods
+import org.awaitility.Awaitility
 
 suite ("test_uniq_vals_schema_change") {
     def tableName = "schema_change_uniq_vals_regression_test"
@@ -141,9 +142,7 @@ suite ("test_uniq_vals_schema_change") {
 
         // wait for all compactions done
         for (String[] tablet in tablets) {
-                boolean running = true
-                do {
-                    Thread.sleep(100)
+            Awaitility.await().untilAsserted(() -> {
                     String tablet_id = tablet[0]
                     backend_id = tablet[2]
                     (code, out, err) = 
be_get_compaction_status(backendId_to_backendIP.get(backend_id), 
backendId_to_backendHttpPort.get(backend_id), tablet_id)
@@ -151,8 +150,8 @@ suite ("test_uniq_vals_schema_change") {
                     assertEquals(code, 0)
                     def compactionStatus = parseJson(out.trim())
                     assertEquals("success", 
compactionStatus.status.toLowerCase())
-                    running = compactionStatus.run_status
-                } while (running)
+                    return compactionStatus.run_status;
+                });
         }
         qt_sc """ select count(*) from ${tableName} """
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to