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 4286db559b0 [Enhancement]use awaitility.await() add in schema_change 
tc #37817 (#38831)
4286db559b0 is described below

commit 4286db559b00b12a4b8e2a3262595a3da559e719
Author: Vallish Pai <vallish...@gmail.com>
AuthorDate: Tue Aug 6 19:09:47 2024 +0530

    [Enhancement]use awaitility.await() add in schema_change tc #37817 (#38831)
    
    ## Proposed changes
    
    Issue Number: close #xxx
    #37817
    use awaitility in schema_change testcases.
---
 ...e_column_with_delete_drop_column_dup_key.groovy | 123 +++++++--------------
 ...olumn_with_delete_drop_column_unique_key.groovy |  90 +++++----------
 2 files changed, 69 insertions(+), 144 deletions(-)

diff --git 
a/regression-test/suites/schema_change/test_alter_table_column_with_delete_drop_column_dup_key.groovy
 
b/regression-test/suites/schema_change/test_alter_table_column_with_delete_drop_column_dup_key.groovy
index d091d7e46ff..1f9336ae3b3 100644
--- 
a/regression-test/suites/schema_change/test_alter_table_column_with_delete_drop_column_dup_key.groovy
+++ 
b/regression-test/suites/schema_change/test_alter_table_column_with_delete_drop_column_dup_key.groovy
@@ -14,6 +14,8 @@
 // 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("test_alter_table_column_with_delete_drop_column_dup_key", 
"schema_change") {
     def tbName1 = "alter_table_column_dup_with_delete_drop_column_dup_key"
@@ -21,7 +23,6 @@ 
suite("test_alter_table_column_with_delete_drop_column_dup_key", "schema_change"
         def jobStateResult = sql """  SHOW ALTER TABLE COLUMN WHERE 
IndexName='${tableName}' ORDER BY createtime DESC LIMIT 1 """
         return jobStateResult[0][9]
     }
-
 //=========================Test Normal Schema Change
     sql "DROP TABLE IF EXISTS ${tbName1}"
     sql """
@@ -48,20 +49,15 @@ 
suite("test_alter_table_column_with_delete_drop_column_dup_key", "schema_change"
             DROP COLUMN value3;
         """
     int max_try_secs = 1200
-    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(100)
-            if (max_try_secs < 1) {
-                println "test timeout," + "state:" + res
-                assertEquals("FINISHED",res)
-            }
+            return true;
         }
-    }
+        return false;
+    });
     qt_sql "select * from ${tbName1} order by k1;"
 
      // drop value3
@@ -70,20 +66,14 @@ 
suite("test_alter_table_column_with_delete_drop_column_dup_key", "schema_change"
             ADD COLUMN value3 CHAR(100) DEFAULT 'A';
         """
     max_try_secs = 1200
-    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(100)
-            if (max_try_secs < 1) {
-                println "test timeout," + "state:" + res
-                assertEquals("FINISHED",res)
-            }
+            return true;
         }
-    }
+        return false;
+    });
     qt_sql "select * from ${tbName1} order by k1;"
 
     sql "insert into ${tbName1} values(5,5,5,'B');"
@@ -123,21 +113,14 @@ 
suite("test_alter_table_column_with_delete_drop_column_dup_key", "schema_change"
             ALTER TABLE ${tbName1} 
             DROP COLUMN value3;
         """
-    max_try_secs = 1200
-    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(100)
-            if (max_try_secs < 1) {
-                println "test timeout," + "state:" + res
-                assertEquals("FINISHED",res)
-            }
+            return true;
         }
-    }
+        return false;
+    });
     qt_sql "select * from ${tbName1} where value1=3 order by k1;"
 
     // drop value3
@@ -145,21 +128,14 @@ 
suite("test_alter_table_column_with_delete_drop_column_dup_key", "schema_change"
             ALTER TABLE ${tbName1} 
             ADD COLUMN value3 CHAR(100) DEFAULT 'A';
         """
-    max_try_secs = 1200
-    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(100)
-            if (max_try_secs < 1) {
-                println "test timeout," + "state:" + res
-                assertEquals("FINISHED",res)
-            }
+            return true;
         }
-    }
+        return false;
+    });
     qt_sql "select * from ${tbName1} where value1=4 order by k1;"
 
     sql "insert into ${tbName1} values(5,5,5,'B');"
@@ -170,21 +146,14 @@ 
suite("test_alter_table_column_with_delete_drop_column_dup_key", "schema_change"
             ALTER TABLE ${tbName1} 
             ADD COLUMN k2 CHAR(10) KEY DEFAULT 'A';
         """
-    max_try_secs = 1200
-    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(100)
-            if (max_try_secs < 1) {
-                println "test timeout," + "state:" + res
-                assertEquals("FINISHED",res)
-            }
+            return true;
         }
-    }
+        return false;
+    });
     qt_sql "select * from ${tbName1} where value1=4 order by k1;"
     sql "DROP TABLE ${tbName1} FORCE;"
 
@@ -221,21 +190,14 @@ 
suite("test_alter_table_column_with_delete_drop_column_dup_key", "schema_change"
             ALTER TABLE ${tbName1} 
             DROP COLUMN value3;
         """
-    max_try_secs = 1200
-    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(100)
-            if (max_try_secs < 1) {
-                println "test timeout," + "state:" + res
-                assertEquals("FINISHED",res)
-            }
+            return true;
         }
-    }
+        return false;
+    });
     qt_sql "select * from ${tbName1} order by k1;"
 
      // drop value3
@@ -243,21 +205,15 @@ 
suite("test_alter_table_column_with_delete_drop_column_dup_key", "schema_change"
             ALTER TABLE ${tbName1} 
             ADD COLUMN value3 CHAR(100) DEFAULT 'A';
         """
-    max_try_secs = 1200
-    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(100)
-            if (max_try_secs < 1) {
-                println "test timeout," + "state:" + res
-                assertEquals("FINISHED",res)
-            }
+            return true;
         }
-    }
+        return false;
+    });
     qt_sql "select * from ${tbName1} order by k1;"
 
     sql "insert into ${tbName1} values(5,5,5,'B');"
@@ -268,7 +224,6 @@ 
suite("test_alter_table_column_with_delete_drop_column_dup_key", "schema_change"
     sql "insert into ${tbName1} values(5,5,5,'B');"
     sql "insert into ${tbName1} values(5,5,5,'B');"
 
-    Thread.sleep(5000)
     qt_sql "select * from ${tbName1} order by k1;"
     sql "DROP TABLE ${tbName1} FORCE;"
 
diff --git 
a/regression-test/suites/schema_change/test_alter_table_column_with_delete_drop_column_unique_key.groovy
 
b/regression-test/suites/schema_change/test_alter_table_column_with_delete_drop_column_unique_key.groovy
index 9f52dd18887..2026b87c367 100644
--- 
a/regression-test/suites/schema_change/test_alter_table_column_with_delete_drop_column_unique_key.groovy
+++ 
b/regression-test/suites/schema_change/test_alter_table_column_with_delete_drop_column_unique_key.groovy
@@ -15,13 +15,15 @@
 // specific language governing permissions and limitations
 // under the License.
 
+import java.util.concurrent.TimeUnit
+import org.awaitility.Awaitility
+
 suite("test_alter_table_column_with_delete_drop_column_unique_key", 
"schema_change") {
     def tbName1 = "alter_table_column_dup_with_delete_drop_column_unique_key"
     def getJobState = { tableName ->
         def jobStateResult = sql """  SHOW ALTER TABLE COLUMN WHERE 
IndexName='${tableName}' ORDER BY createtime DESC LIMIT 1 """
         return jobStateResult[0][9]
     }
-
 //=========================Test Normal Schema Change
     sql "DROP TABLE IF EXISTS ${tbName1}"
     sql """
@@ -49,20 +51,15 @@ 
suite("test_alter_table_column_with_delete_drop_column_unique_key", "schema_chan
             DROP COLUMN value3;
         """
     int max_try_secs = 1200
-    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(100)
-            if (max_try_secs < 1) {
-                println "test timeout," + "state:" + res
-                assertEquals("FINISHED",res)
-            }
+            return true;
         }
-    }
+        return false;
+    });
     qt_sql "select * from ${tbName1} order by k1;"
 
      // drop value3
@@ -70,21 +67,15 @@ 
suite("test_alter_table_column_with_delete_drop_column_unique_key", "schema_chan
             ALTER TABLE ${tbName1} 
             ADD COLUMN value3 CHAR(100) DEFAULT 'A';
         """
-    max_try_secs = 1200
-    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(100)
-            if (max_try_secs < 1) {
-                println "test timeout," + "state:" + res
-                assertEquals("FINISHED",res)
-            }
+            return true;
         }
-    }
+        return false;
+    });
+
     qt_sql "select * from ${tbName1} order by k1;"
 
     sql "insert into ${tbName1} values(5,5,5,'B');"
@@ -124,21 +115,14 @@ 
suite("test_alter_table_column_with_delete_drop_column_unique_key", "schema_chan
             ALTER TABLE ${tbName1} 
             DROP COLUMN k2;
         """
-    max_try_secs = 1200
-    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(100)
-            if (max_try_secs < 1) {
-                println "test timeout," + "state:" + res
-                assertEquals("FINISHED",res)
-            }
+            return true;
         }
-    }
+        return false;
+    });
     qt_sql "select * from ${tbName1} where value1=3 order by k1;"
 
     // drop value3
@@ -146,21 +130,14 @@ 
suite("test_alter_table_column_with_delete_drop_column_unique_key", "schema_chan
             ALTER TABLE ${tbName1} 
             ADD COLUMN value3 CHAR(100) DEFAULT 'A';
         """
-    max_try_secs = 1200
-    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(100)
-            if (max_try_secs < 1) {
-                println "test timeout," + "state:" + res
-                assertEquals("FINISHED",res)
-            }
+            return true;
         }
-    }
+        return false;
+    });
     qt_sql "select * from ${tbName1} where value1=4 order by k1;"
 
     sql "insert into ${tbName1} values(5,5,5,'B');"
@@ -171,21 +148,14 @@ 
suite("test_alter_table_column_with_delete_drop_column_unique_key", "schema_chan
             ALTER TABLE ${tbName1} 
             ADD COLUMN k2 CHAR(10) KEY DEFAULT 'A';
         """
-    max_try_secs = 1200
-    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(100)
-            if (max_try_secs < 1) {
-                println "test timeout," + "state:" + res
-                assertEquals("FINISHED",res)
-            }
+            return true;
         }
-    }
+        return false;
+    });
     qt_sql "select * from ${tbName1} where value1=4 order by k1;"
     sql "DROP TABLE ${tbName1} FORCE;"
 


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

Reply via email to