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

yiguolei pushed a commit to branch branch-2.1
in repository https://gitbox.apache.org/repos/asf/doris.git

commit 48d7c1b1eddd70b2cdb349dd6b36306874296fb8
Author: shuke <37901441+shuke...@users.noreply.github.com>
AuthorDate: Wed Jan 17 17:06:09 2024 +0800

    [test](regression-test) fix case, compatible with 3 replicas. (#29905)
---
 .../org/apache/doris/regression/suite/Suite.groovy | 27 +++++++++++++++++++++-
 .../test_index_change_with_compaction.groovy       | 13 ++++++++++-
 .../test_index_compaction_dup_keys.groovy          | 10 +++++++-
 .../test_index_compaction_unique_keys.groovy       | 10 +++++++-
 ...dex_compaction_with_multi_index_segments.groovy | 10 +++++++-
 .../stream_load/test_load_to_single_tablet.groovy  |  4 +++-
 .../select_tablets/select_with_tablets.groovy      |  3 +++
 7 files changed, 71 insertions(+), 6 deletions(-)

diff --git 
a/regression-test/framework/src/main/groovy/org/apache/doris/regression/suite/Suite.groovy
 
b/regression-test/framework/src/main/groovy/org/apache/doris/regression/suite/Suite.groovy
index f276e29a530..41a99abe7a7 100644
--- 
a/regression-test/framework/src/main/groovy/org/apache/doris/regression/suite/Suite.groovy
+++ 
b/regression-test/framework/src/main/groovy/org/apache/doris/regression/suite/Suite.groovy
@@ -932,5 +932,30 @@ class Suite implements GroovyInterceptable {
         }
         Assert.assertEquals(true, !createdTableName.isEmpty())
     }
-}
 
+    String[][] deduplicate_tablets(String[][] tablets) {
+        def result = [:]
+
+        tablets.each { row ->
+            def tablet_id = row[0]
+            if (!result.containsKey(tablet_id)) {
+                result[tablet_id] = row
+            }
+        }
+
+        return result.values().toList()
+    }
+
+    ArrayList deduplicate_tablets(ArrayList tablets) {
+        def result = [:]
+
+        tablets.each { row ->
+            def tablet_id = row[0]
+            if (!result.containsKey(tablet_id)) {
+                result[tablet_id] = row
+            }
+        }
+
+        return result.values().toList()
+    }
+}
diff --git 
a/regression-test/suites/inverted_index_p0/index_change/test_index_change_with_compaction.groovy
 
b/regression-test/suites/inverted_index_p0/index_change/test_index_change_with_compaction.groovy
index b4a42aba237..924ab0a9f4e 100644
--- 
a/regression-test/suites/inverted_index_p0/index_change/test_index_change_with_compaction.groovy
+++ 
b/regression-test/suites/inverted_index_p0/index_change/test_index_change_with_compaction.groovy
@@ -226,7 +226,18 @@ suite("test_index_change_with_compaction") {
                 rowCount += Integer.parseInt(rowset.split(" ")[1])
             }
         }
-        assert (rowCount <= 8)
+
+        String[][] dedup_tablets = deduplicate_tablets(tablets)
+
+        // In the p0 testing environment, there are no expected operations 
such as scaling down BE (backend) services
+        // if tablets or dedup_tablets is empty, exception is thrown, and case 
fail
+        int replicaNum = Math.floor(tablets.size() / dedup_tablets.size())
+        if (replicaNum != 1 && replicaNum != 3)
+        {
+            assert(false);
+        }
+
+        assert (rowCount <= 8*replicaNum)
         qt_select_default2 """ SELECT * FROM ${tableName} t ORDER BY 
user_id,date,city,age,sex,last_visit_date,last_update_date,last_visit_date_not_null,cost,max_dwell_time,min_dwell_time;
 """
     } finally {
         // try_sql("DROP TABLE IF EXISTS ${tableName}")
diff --git 
a/regression-test/suites/inverted_index_p0/index_compaction/test_index_compaction_dup_keys.groovy
 
b/regression-test/suites/inverted_index_p0/index_compaction/test_index_compaction_dup_keys.groovy
index cd98f58ce4f..8bbedb97794 100644
--- 
a/regression-test/suites/inverted_index_p0/index_compaction/test_index_compaction_dup_keys.groovy
+++ 
b/regression-test/suites/inverted_index_p0/index_compaction/test_index_compaction_dup_keys.groovy
@@ -164,8 +164,16 @@ suite("test_index_compaction_dup_keys", "p0") {
 
         
//TabletId,ReplicaId,BackendId,SchemaHash,Version,LstSuccessVersion,LstFailedVersion,LstFailedTime,LocalDataSize,RemoteDataSize,RowCount,State,LstConsistencyCheckTime,CheckVersion,VersionCount,PathHash,MetaUrl,CompactionStatus
         String[][] tablets = sql """ show tablets from ${tableName}; """
+        String[][] dedup_tablets = deduplicate_tablets(tablets)
+
+        // In the p0 testing environment, there are no expected operations 
such as scaling down BE (backend) services
+        // if tablets or dedup_tablets is empty, exception is thrown, and case 
fail
+        int replicaNum = Math.floor(tablets.size() / dedup_tablets.size())
+        if (replicaNum != 1 && replicaNum != 3)
+        {
+            assert(false);
+        }
 
-        int replicaNum = 1
         // before full compaction, there are 7 rowsets.
         int rowsetCount = get_rowset_count.call(tablets);
         assert (rowsetCount == 7 * replicaNum)
diff --git 
a/regression-test/suites/inverted_index_p0/index_compaction/test_index_compaction_unique_keys.groovy
 
b/regression-test/suites/inverted_index_p0/index_compaction/test_index_compaction_unique_keys.groovy
index f4f2afb78d6..64d2ee21647 100644
--- 
a/regression-test/suites/inverted_index_p0/index_compaction/test_index_compaction_unique_keys.groovy
+++ 
b/regression-test/suites/inverted_index_p0/index_compaction/test_index_compaction_unique_keys.groovy
@@ -168,8 +168,16 @@ suite("test_index_compaction_unique_keys", "p0") {
 
         
//TabletId,ReplicaId,BackendId,SchemaHash,Version,LstSuccessVersion,LstFailedVersion,LstFailedTime,LocalDataSize,RemoteDataSize,RowCount,State,LstConsistencyCheckTime,CheckVersion,VersionCount,PathHash,MetaUrl,CompactionStatus
         String[][] tablets = sql """ show tablets from ${tableName}; """
+        String[][] dedup_tablets = deduplicate_tablets(tablets)
+
+        // In the p0 testing environment, there are no expected operations 
such as scaling down BE (backend) services
+        // if tablets or dedup_tablets is empty, exception is thrown, and case 
fail
+        int replicaNum = Math.floor(tablets.size() / dedup_tablets.size())
+        if (replicaNum != 1 && replicaNum != 3)
+        {
+            assert(false);
+        }
 
-        int replicaNum = 1
         // before full compaction, there are 7 rowsets.
         int rowsetCount = get_rowset_count.call(tablets);
         assert (rowsetCount == 7 * replicaNum)
diff --git 
a/regression-test/suites/inverted_index_p0/index_compaction/test_index_compaction_with_multi_index_segments.groovy
 
b/regression-test/suites/inverted_index_p0/index_compaction/test_index_compaction_with_multi_index_segments.groovy
index 25ed93aec51..dd6e91e53b7 100644
--- 
a/regression-test/suites/inverted_index_p0/index_compaction/test_index_compaction_with_multi_index_segments.groovy
+++ 
b/regression-test/suites/inverted_index_p0/index_compaction/test_index_compaction_with_multi_index_segments.groovy
@@ -194,8 +194,16 @@ suite("test_index_compaction_with_multi_index_segments", 
"p0") {
 
         
//TabletId,ReplicaId,BackendId,SchemaHash,Version,LstSuccessVersion,LstFailedVersion,LstFailedTime,LocalDataSize,RemoteDataSize,RowCount,State,LstConsistencyCheckTime,CheckVersion,VersionCount,PathHash,MetaUrl,CompactionStatus
         String[][] tablets = sql """ show tablets from ${tableName}; """
+        String[][] dedup_tablets = deduplicate_tablets(tablets)
+
+        // In the p0 testing environment, there are no expected operations 
such as scaling down BE (backend) services
+        // if tablets or dedup_tablets is empty, exception is thrown, and case 
fail
+        int replicaNum = Math.floor(tablets.size() / dedup_tablets.size())
+        if (replicaNum != 1 && replicaNum != 3)
+        {
+            assert(false);
+        }
 
-        int replicaNum = 1
         // before full compaction, there are 3 rowsets.
         int rowsetCount = get_rowset_count.call(tablets)
         assert (rowsetCount == 3 * replicaNum)
diff --git 
a/regression-test/suites/load_p0/stream_load/test_load_to_single_tablet.groovy 
b/regression-test/suites/load_p0/stream_load/test_load_to_single_tablet.groovy
index c35500267b9..80b25bd34c3 100644
--- 
a/regression-test/suites/load_p0/stream_load/test_load_to_single_tablet.groovy
+++ 
b/regression-test/suites/load_p0/stream_load/test_load_to_single_tablet.groovy
@@ -55,7 +55,8 @@ suite("test_load_to_single_tablet", "p0") {
     sql "sync"
     def totalCount = sql "select count() from ${tableName}"
     assertEquals(10, totalCount[0][0])
-    def res = sql "show tablets from ${tableName}"
+    String[][] res = sql "show tablets from ${tableName}"
+    res = deduplicate_tablets(res)
     def tablet1 = res[0][0]
     def tablet2 = res[1][0]
     def tablet3 = res[2][0]
@@ -150,6 +151,7 @@ suite("test_load_to_single_tablet", "p0") {
     totalCount = sql "select count() from ${tableName}"
     assertEquals(10, totalCount[0][0])
     res = sql "show tablets from ${tableName} partitions(p20231011, p20231012)"
+    res = deduplicate_tablets(res)
     tablet1 = res[0][0]
     tablet2 = res[1][0]
     tablet3 = res[2][0]
diff --git 
a/regression-test/suites/nereids_p0/select_tablets/select_with_tablets.groovy 
b/regression-test/suites/nereids_p0/select_tablets/select_with_tablets.groovy
index f2c2546b024..86bc846a110 100644
--- 
a/regression-test/suites/nereids_p0/select_tablets/select_with_tablets.groovy
+++ 
b/regression-test/suites/nereids_p0/select_tablets/select_with_tablets.groovy
@@ -45,6 +45,7 @@ suite("select_with_tablets") {
     order_qt_select1 """ SELECT * FROM ${table_name1} """
 
     def res = sql """ show tablets from ${table_name1} where version = 2 """
+    res = deduplicate_tablets(res)
     assertTrue(res.size() == 1)
     assertTrue(res[0].size() == 21)
     assertEquals("2", res[0][4])
@@ -65,6 +66,7 @@ suite("select_with_tablets") {
     order_qt_select11 """ SELECT * FROM ${table_name1} PARTITION between_20_70 
where id < 2"""
 
     res = sql """ show tablets from ${table_name1} where version = 1 """
+    res = deduplicate_tablets(res)
     assertTrue(res.size() == 2)
     assertEquals("1", res[0][4])
     assertEquals("1", res[1][4])
@@ -93,6 +95,7 @@ suite("select_with_tablets") {
     order_qt_no_partition_1 """ SELECT * FROM ${table_no_partition} """
 
     res = sql """ show tablets from ${table_no_partition} where version = 2 """
+    res = deduplicate_tablets(res)
 
     order_qt_no_partition_2 """ SELECT * FROM ${table_no_partition} 
TABLET(${res[0][0]}) """
     order_qt_no_partition_3 """ SELECT * FROM ${table_no_partition} 
TABLET(${res[1][0]}) """


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

Reply via email to