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

yiguolei 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 34699946037 [Enhancement]use awaitility.await() replace 
thread.sleep(), neredis part (#38816)
34699946037 is described below

commit 3469994603736c699395d37161f9dbf191b91337
Author: Vallish Pai <vallish...@gmail.com>
AuthorDate: Tue Aug 6 19:09:21 2024 +0530

    [Enhancement]use awaitility.await() replace thread.sleep(), neredis part 
(#38816)
    
    ## Proposed changes
    
    Issue Number: close #xxx
    #37817
    replace thread.sleep with awaitility util in some of neredis_syntax test
    cases.
---
 .../suites/nereids_syntax_p0/rollup/agg.groovy     | 40 +++++------
 .../suites/nereids_syntax_p0/rollup/date.groovy    | 84 +++++++++-------------
 2 files changed, 49 insertions(+), 75 deletions(-)

diff --git a/regression-test/suites/nereids_syntax_p0/rollup/agg.groovy 
b/regression-test/suites/nereids_syntax_p0/rollup/agg.groovy
index da1ba1e5a62..6a213a85458 100644
--- a/regression-test/suites/nereids_syntax_p0/rollup/agg.groovy
+++ b/regression-test/suites/nereids_syntax_p0/rollup/agg.groovy
@@ -14,6 +14,9 @@
 // KIND, either express or implied.  See the License for the
 // specific language governing permissions and limitations
 // under the License.
+import java.util.concurrent.TimeUnit
+import org.awaitility.Awaitility
+
 suite("agg") {
 
     sql """set enable_nereids_planner=true"""
@@ -43,37 +46,28 @@ suite("agg") {
         """
     sql """ALTER TABLE ${tbName} ADD ROLLUP rollup_city(citycode, pv);"""
     int max_try_secs = 60
-    while (max_try_secs--) {
-        String res = getJobRollupState(tbName)
+    String res = "NOT_FINISHED"
+    Awaitility.await().atMost(max_try_secs, 
TimeUnit.SECONDS).with().pollDelay(100, TimeUnit.MILLISECONDS).await().until(() 
-> {
+        res = getJobRollupState(tbName)
         if (res == "FINISHED" || res == "CANCELLED") {
             assertEquals("FINISHED", res)
-            sleep(3000)
-            break
-        } else {
-            Thread.sleep(2000)
-            if (max_try_secs < 1) {
-                println "test timeout," + "state:" + res
-                assertEquals("FINISHED",res)
-            }
+            return true;
         }
-    }
-    Thread.sleep(2000)
+        return false;
+    });
+    assertEquals("FINISHED",res)
+
     sql "ALTER TABLE ${tbName} ADD COLUMN vv BIGINT SUM NULL DEFAULT '0' TO 
rollup_city;"
     max_try_secs = 60
-    while (max_try_secs--) {
-        String res = getJobColumnState(tbName)
+    Awaitility.await().atMost(max_try_secs, 
TimeUnit.SECONDS).with().pollDelay(100, TimeUnit.MILLISECONDS).await().until(() 
-> {
+        res = getJobColumnState(tbName)
         if (res == "FINISHED" || res == "CANCELLED") {
             assertEquals("FINISHED", res)
-            sleep(3000)
-            break
-        } else {
-            Thread.sleep(2000)
-            if (max_try_secs < 1) {
-                println "test timeout," + "state:" + res
-                assertEquals("FINISHED",res)
-            }
+            return true;
         }
-    }
+        return false;
+    });
+    assertEquals("FINISHED",res)
     sql "SHOW ALTER TABLE ROLLUP WHERE TableName='${tbName}';"
     qt_sql "DESC ${tbName} ALL;"
     sql "insert into ${tbName} values(1, 1, 'test1', 100,100,100);"
diff --git a/regression-test/suites/nereids_syntax_p0/rollup/date.groovy 
b/regression-test/suites/nereids_syntax_p0/rollup/date.groovy
index 3c064de8ac6..4fdcd4f2c83 100644
--- a/regression-test/suites/nereids_syntax_p0/rollup/date.groovy
+++ b/regression-test/suites/nereids_syntax_p0/rollup/date.groovy
@@ -14,6 +14,9 @@
 // KIND, either express or implied.  See the License for the
 // specific language governing permissions and limitations
 // under the License.
+import java.util.concurrent.TimeUnit
+import org.awaitility.Awaitility
+
 suite("date", "rollup") {
 
     sql """set enable_nereids_planner=true"""
@@ -43,72 +46,49 @@ suite("date", "rollup") {
 
     int max_try_secs = 120
     sql "CREATE materialized VIEW amt_max1 AS SELECT store_id, max(sale_date1) 
FROM ${tbName1} GROUP BY store_id;"
-    while (max_try_secs--) {
-        String res = getJobState(tbName1)
+    String res = "NOT_FINISHED"
+    Awaitility.await().atMost(max_try_secs, 
TimeUnit.SECONDS).with().pollDelay(100, TimeUnit.MILLISECONDS).await().until(() 
-> {
+        res = getJobState(tbName1)
         if (res == "FINISHED" || res == "CANCELLED") {
             assertEquals("FINISHED", res)
-            sleep(3000)
-            break
-        } else {
-            Thread.sleep(2000)
-            if (max_try_secs < 1) {
-                println "test timeout," + "state:" + res
-                assertEquals("FINISHED",res)
-            }
+            return true;
         }
-    }
-    Thread.sleep(2000)
-    max_try_secs = 120
+        return false;
+    });
+    assertEquals("FINISHED",res)
+
     sql "CREATE materialized VIEW amt_max2 AS SELECT store_id, 
max(sale_datetime1) FROM ${tbName1} GROUP BY store_id;"
-    while (max_try_secs--) {
-        String res = getJobState(tbName1)
+    Awaitility.await().atMost(max_try_secs, 
TimeUnit.SECONDS).with().pollDelay(100, TimeUnit.MILLISECONDS).await().until(() 
-> {
+        res = getJobState(tbName1)
         if (res == "FINISHED" || res == "CANCELLED") {
             assertEquals("FINISHED", res)
-            sleep(3000)
-            break
-        } else {
-            Thread.sleep(2000)
-            if (max_try_secs < 1) {
-                println "test timeout," + "state:" + res
-                assertEquals("FINISHED",res)
-            }
-        }
-    }
-    Thread.sleep(2000)
-    max_try_secs = 120
+            return true;
+        } 
+        return false;
+    });
+    assertEquals("FINISHED",res)
+
     sql "CREATE materialized VIEW amt_max3 AS SELECT store_id, 
max(sale_datetime2) FROM ${tbName1} GROUP BY store_id;"
-    while (max_try_secs--) {
-        String res = getJobState(tbName1)
+    Awaitility.await().atMost(max_try_secs, 
TimeUnit.SECONDS).with().pollDelay(100, TimeUnit.MILLISECONDS).await().until(() 
-> {
+        res = getJobState(tbName1)
         if (res == "FINISHED" || res == "CANCELLED") {
             assertEquals("FINISHED", res)
-            sleep(3000)
-            break
-        } else {
-            Thread.sleep(2000)
-            if (max_try_secs < 1) {
-                println "test timeout," + "state:" + res
-                assertEquals("FINISHED",res)
-            }
+            return true;
         }
-    }
-    Thread.sleep(2000)
-    max_try_secs = 120
+        return false;
+    });
+    assertEquals("FINISHED",res)
+
     sql "CREATE materialized VIEW amt_max4 AS SELECT store_id, 
max(sale_datetime3) FROM ${tbName1} GROUP BY store_id;"
-    while (max_try_secs--) {
-        String res = getJobState(tbName1)
+    Awaitility.await().atMost(max_try_secs, 
TimeUnit.SECONDS).with().pollDelay(100, TimeUnit.MILLISECONDS).await().until(() 
-> {
+        res = getJobState(tbName1)
         if (res == "FINISHED" || res == "CANCELLED") {
             assertEquals("FINISHED", res)
-            sleep(3000)
-            break
-        } else {
-            Thread.sleep(2000)
-            if (max_try_secs < 1) {
-                println "test timeout," + "state:" + res
-                assertEquals("FINISHED",res)
-            }
+            return true;
         }
-    }
-
+        return false;
+    });
+    assertEquals("FINISHED",res)
 
     sql "SHOW ALTER TABLE MATERIALIZED VIEW WHERE TableName='${tbName1}';"
     sql "insert into ${tbName1} values(1, 1, 1, '2020-05-30', '2020-05-30', 
'2020-05-30 11:11:11.111111', '2020-05-30 11:11:11.111111', '2020-05-30 
11:11:11.111111',100);"


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

Reply via email to