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 2c34b6cf2b optimization the result check for test_json_load (#11160)
2c34b6cf2b is described below

commit 2c34b6cf2bc145f0afb9e9e72e04e1cb121cb9ed
Author: carlvinhust2012 <huchengha...@126.com>
AuthorDate: Tue Jul 26 17:58:30 2022 +0800

    optimization the result check for test_json_load (#11160)
    
    Co-authored-by: hucheng01 <huchen...@baidu.com>
---
 .../data/load/stream_load/test_json_load.out       | 117 +++++++++++++++++
 .../suites/load/stream_load/test_json_load.groovy  | 142 +++++----------------
 2 files changed, 148 insertions(+), 111 deletions(-)

diff --git a/regression-test/data/load/stream_load/test_json_load.out 
b/regression-test/data/load/stream_load/test_json_load.out
new file mode 100644
index 0000000000..d53bd5bd1b
--- /dev/null
+++ b/regression-test/data/load/stream_load/test_json_load.out
@@ -0,0 +1,117 @@
+-- This file is automatically generated. You should know what you did if you 
want to edit this
+-- !select --
+1      beijing 2345671
+2      shanghai        2345672
+3      guangzhou       2345673
+4      shenzhen        2345674
+5      hangzhou        2345675
+6      nanjing 2345676
+7      wuhan   2345677
+8      chengdu 2345678
+9      xian    2345679
+10     hefei   23456710
+200    changsha        3456789
+
+-- !select --
+10     beijing 2345671
+20     shanghai        2345672
+30     guangzhou       2345673
+40     shenzhen        2345674
+50     hangzhou        2345675
+60     nanjing 2345676
+70     wuhan   2345677
+80     chengdu 2345678
+90     xian    2345679
+100    hefei   23456710
+200    changsha        3456789
+
+-- !select --
+1      2345671
+2      2345672
+3      2345673
+4      2345674
+5      2345675
+6      2345676
+7      2345677
+8      2345678
+9      2345679
+10     23456710
+200    755
+
+-- !select --
+1      210
+2      220
+3      230
+4      240
+5      250
+6      260
+7      270
+8      280
+9      290
+10     300
+200    755
+
+-- !select --
+1      1454547
+2      1244264
+3      528369
+4      594201
+5      594201
+6      2345672
+7      2345673
+8      2345674
+9      2345675
+10     2345676
+200    755
+
+-- !select --
+10     1454547
+20     1244264
+30     528369
+40     594201
+50     594201
+60     2345672
+70     2345673
+80     2345674
+90     2345675
+100    2345676
+200    755
+
+-- !select --
+60     2345672
+70     2345673
+80     2345674
+90     2345675
+100    2345676
+200    755
+
+-- !select --
+60     2345672
+70     2345673
+80     2345674
+90     2345675
+100    2345676
+200    755
+
+-- !select --
+10     beijing 2345671
+20     shanghai        2345672
+200    changsha        3456789
+
+-- !select --
+2      shanghai        2345672
+3      guangzhou       2345673
+4      shenzhen        2345674
+5      hangzhou        2345675
+6      nanjing 2345676
+7      wuhan   2345677
+8      chengdu 2345678
+9      xian    2345679
+200    changsha        3456789
+
+-- !select --
+2      shanghai        2345672
+3      guangzhou       2345673
+4      shenzhen        2345674
+200    changsha        3456789
+
diff --git a/regression-test/suites/load/stream_load/test_json_load.groovy 
b/regression-test/suites/load/stream_load/test_json_load.groovy
index 305de78eac..914f1c227f 100644
--- a/regression-test/suites/load/stream_load/test_json_load.groovy
+++ b/regression-test/suites/load/stream_load/test_json_load.groovy
@@ -130,6 +130,23 @@ suite("test_json_load", "load") {
         assertTrue(result1[0][0] == 0, "Query OK, 0 rows affected")
     }
 
+    def check_load_result = {checklabel, testTablex ->
+        max_try_milli_secs = 10000
+        while(max_try_milli_secs) {
+            result = sql "show load where label = '${checklabel}'"
+            if(result[0][2] == "FINISHED") {
+                qt_select "select * from ${testTablex} order by id"
+                break
+            } else {
+                sleep(1000) // wait 1 second every time
+                max_try_milli_secs -= 1000
+                if(max_try_milli_secs <= 0) {
+                    assertEquals(1, 2)
+                }
+            }
+        }
+    }
+
     // case1: import simple json
     try {
         sql "DROP TABLE IF EXISTS ${testTable}"
@@ -138,17 +155,7 @@ suite("test_json_load", "load") {
 
         load_json_data.call('true', '', 'json', '', '', '', '', '', 
'simple_json.json')
 
-        // select the table and check whether the data is correct
-        def result3 = sql "select * from test_json_load order by id"
-        assertTrue(result3.size() == 11)
-        assertTrue(result3[0].size() == 3)
-        assertTrue(result3[0][0] == 1)
-        assertTrue(result3[0][1] == "beijing")
-        assertTrue(result3[0][2] == 2345671)
-        assertTrue(result3[9].size() == 3)
-        assertTrue(result3[9][0] == 10)
-        assertTrue(result3[9][1] == "hefei")
-        assertTrue(result3[9][2] == 23456710)
+        qt_select "select * from ${testTable} order by id"
 
     } finally {
         try_sql("DROP TABLE IF EXISTS ${testTable}")
@@ -162,16 +169,7 @@ suite("test_json_load", "load") {
 
         load_json_data.call('true', '', 'json', 'id= id * 10', '', '', '', '', 
'simple_json.json')
 
-        def result3 = sql "select * from test_json_load order by id"
-        assertTrue(result3.size() == 11)
-        assertTrue(result3[0].size() == 3)
-        assertTrue(result3[0][0] == 10)
-        assertTrue(result3[0][1] == "beijing")
-        assertTrue(result3[0][2] == 2345671)
-        assertTrue(result3[9].size() == 3)
-        assertTrue(result3[9][0] == 100)
-        assertTrue(result3[9][1] == "hefei")
-        assertTrue(result3[9][2] == 23456710)
+        qt_select "select * from ${testTable} order by id"
 
     } finally {
         try_sql("DROP TABLE IF EXISTS ${testTable}")
@@ -186,14 +184,7 @@ suite("test_json_load", "load") {
         load_json_data.call('true', '', 'json', '', '[\"$.id\", \"$.code\"]',
                             '', '', '', 'simple_json.json')
 
-        def result3 = sql "select * from test_json_load order by id"
-        assertTrue(result3.size() == 11)
-        assertTrue(result3[0].size() == 2)
-        assertTrue(result3[0][0] == 1)
-        assertTrue(result3[0][1] == 2345671)
-        assertTrue(result3[9].size() == 2)
-        assertTrue(result3[9][0] == 10)
-        assertTrue(result3[9][1] == 23456710)
+        qt_select "select * from ${testTable} order by id"
 
     } finally {
         try_sql("DROP TABLE IF EXISTS ${testTable}")
@@ -208,14 +199,7 @@ suite("test_json_load", "load") {
         load_json_data.call('true', '', 'json', 'code = id * 10 + 200', 
'[\"$.id\"]',
                             '', '', '', 'simple_json.json')
 
-        def result3 = sql "select * from test_json_load order by id"
-        assertTrue(result3.size() == 11)
-        assertTrue(result3[0].size() == 2)
-        assertTrue(result3[0][0] == 1)
-        assertTrue(result3[0][1] == 210)
-        assertTrue(result3[9].size() == 2)
-        assertTrue(result3[9][0] == 10)
-        assertTrue(result3[9][1] == 300)
+        qt_select "select * from ${testTable} order by id"
 
     } finally {
         try_sql("DROP TABLE IF EXISTS ${testTable}")
@@ -230,14 +214,7 @@ suite("test_json_load", "load") {
         load_json_data.call('true', 'true', 'json', '', '[\"$.id\", 
\"$.code\"]',
                             '', '', '', 'multi_line_json.json')
         
-        def result3 = sql "select * from test_json_load order by id"
-        assertTrue(result3.size() == 11)
-        assertTrue(result3[0].size() == 2)
-        assertTrue(result3[0][0] == 1)
-        assertTrue(result3[0][1] == 1454547)
-        assertTrue(result3[9].size() == 2)
-        assertTrue(result3[9][0] == 10)
-        assertTrue(result3[9][1] == 2345676)
+        qt_select "select * from ${testTable} order by id"
 
     } finally {
         try_sql("DROP TABLE IF EXISTS ${testTable}")
@@ -252,14 +229,7 @@ suite("test_json_load", "load") {
         load_json_data.call('true', 'true', 'json', 'id= id * 10', '[\"$.id\", 
\"$.code\"]',
                             '', '', '', 'multi_line_json.json')
 
-        def result3 = sql "select * from test_json_load order by id"
-        assertTrue(result3.size() == 11)
-        assertTrue(result3[0].size() == 2)
-        assertTrue(result3[0][0] == 10)
-        assertTrue(result3[0][1] == 1454547)
-        assertTrue(result3[9].size() == 2)
-        assertTrue(result3[9][0] == 100)
-        assertTrue(result3[9][1] == 2345676)
+        qt_select "select * from ${testTable} order by id"
 
     } finally {
         try_sql("DROP TABLE IF EXISTS ${testTable}")
@@ -274,17 +244,8 @@ suite("test_json_load", "load") {
         load_json_data.call('true', 'true', 'json', 'id= id * 10', '[\"$.id\", 
\"$.code\"]',
                             '', 'id > 50', '', 'multi_line_json.json')
 
-        def result3 = sql "select * from test_json_load order by id"
-        assertTrue(result3.size() == 6)
-        assertTrue(result3[0].size() == 2)
-        assertTrue(result3[0][0] == 60)
-        assertTrue(result3[0][1] == 2345672)
-        assertTrue(result3[4].size() == 2)
-        assertTrue(result3[4][0] == 100)
-        assertTrue(result3[4][1] == 2345676)
-        assertTrue(result3[5].size() == 2)
-        assertTrue(result3[5][0] == 200)
-        assertTrue(result3[5][1] == 755)
+        qt_select "select * from ${testTable} order by id"
+
     } finally {
         try_sql("DROP TABLE IF EXISTS ${testTable}")
     }
@@ -298,17 +259,8 @@ suite("test_json_load", "load") {
         load_json_data.call('true', 'true', 'json', 'id= id * 10', '[\"$.id\", 
\"$.code\"]',
                             '', 'id > 50', 'true', 'multi_line_json.json')
 
-        def result3 = sql "select * from test_json_load order by id"
-        assertTrue(result3.size() == 6)
-        assertTrue(result3[0].size() == 2)
-        assertTrue(result3[0][0] == 60)
-        assertTrue(result3[0][1] == 2345672)
-        assertTrue(result3[4].size() == 2)
-        assertTrue(result3[4][0] == 100)
-        assertTrue(result3[4][1] == 2345676)
-        assertTrue(result3[5].size() == 2)
-        assertTrue(result3[5][0] == 200)
-        assertTrue(result3[5][1] == 755)
+        qt_select "select * from ${testTable} order by id"
+
     } finally {
         try_sql("DROP TABLE IF EXISTS ${testTable}")
     }
@@ -322,16 +274,8 @@ suite("test_json_load", "load") {
         load_json_data.call('', 'true', 'json', 'id= id * 10', '',
                             '$.item', '', 'true', 'nest_json.json')
 
-        def result3 = sql "select * from test_json_load order by id"
-        assertTrue(result3.size() == 3)
-        assertTrue(result3[0].size() == 3)
-        assertTrue(result3[0][0] == 10)
-        assertTrue(result3[0][1] == "beijing")
-        assertTrue(result3[0][2] == 2345671)
-        assertTrue(result3[1].size() == 3)
-        assertTrue(result3[1][0] == 20)
-        assertTrue(result3[1][1] == "shanghai")
-        assertTrue(result3[1][2] == 2345672)
+        qt_select "select * from ${testTable} order by id"
+
     } finally {
         try_sql("DROP TABLE IF EXISTS ${testTable}")
     }
@@ -355,19 +299,7 @@ suite("test_json_load", "load") {
             load_from_hdfs1.call(testTable, test_load_label, hdfs_file_path, 
format,
                                 brokerName, hdfsUser, hdfsPasswd)
             
-            // wait to load finished
-            sleep(5000)
-    
-            def result3 = sql "select * from test_json_load order by id"
-            assertTrue(result3.size() == 9)
-            assertTrue(result3[0].size() == 3)
-            assertTrue(result3[0][0] == 2)
-            assertTrue(result3[0][1] == "shanghai")
-            assertTrue(result3[0][2] == 2345672)
-            assertTrue(result3[7].size() == 3)
-            assertTrue(result3[7][0] == 9)
-            assertTrue(result3[7][1] == "xian")
-            assertTrue(result3[7][2] == 2345679)
+            check_load_result.call(test_load_label, testTable)
         } finally {
             try_sql("DROP TABLE IF EXISTS ${testTable}")
         }
@@ -382,19 +314,7 @@ suite("test_json_load", "load") {
             load_from_hdfs2.call(testTable, test_load_label, hdfs_file_path, 
format,
                                 brokerName, hdfsUser, hdfsPasswd)
             
-            // wait to load finished
-            sleep(5000)
-    
-            def result3 = sql "select * from test_json_load order by id"
-            assertTrue(result3.size() == 4)
-            assertTrue(result3[0].size() == 3)
-            assertTrue(result3[0][0] == 2)
-            assertTrue(result3[0][1] == "shanghai")
-            assertTrue(result3[0][2] == 2345672)
-            assertTrue(result3[2].size() == 3)
-            assertTrue(result3[2][0] == 4)
-            assertTrue(result3[2][1] == "shenzhen")
-            assertTrue(result3[2][2] == 2345674)
+            check_load_result.call(test_load_label, testTable)
         } finally {
             try_sql("DROP TABLE IF EXISTS ${testTable}")
         }


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

Reply via email to