yujun777 commented on code in PR #27346:
URL: https://github.com/apache/doris/pull/27346#discussion_r1400571727


##########
be/src/olap/tablet.cpp:
##########
@@ -1676,6 +1692,19 @@ void Tablet::build_tablet_report_info(TTabletInfo* 
tablet_info,
         tablet_info->__set_used(false);
     }
 
+    DBUG_EXECUTE_IF("Tablet.build_tablet_report_info.used", {
+        auto tablet_id = dp->param<int>("tablet_id", -1);
+        if (tablet_id != -1 && tablet_id == _tablet_meta->tablet_id()) {
+            auto used = dp->param<bool>("used", true);

Review Comment:
   no need special bool here 



##########
be/src/olap/tablet.cpp:
##########
@@ -1641,6 +1642,21 @@ void Tablet::build_tablet_report_info(TTabletInfo* 
tablet_info,
     } else {
         tablet_info->__set_version_miss(cversion.second < max_version.second);
     }
+
+    DBUG_EXECUTE_IF("Tablet.build_tablet_report_info.version_miss", {
+        auto tablet_id = dp->param<int>("tablet_id", -1);

Review Comment:
   tablet id is int64_t



##########
regression-test/suites/control_p0/set_replica_status.groovy:
##########
@@ -0,0 +1,68 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+suite("test_set_replica_status", "p0") {
+    def tableName = "test_set_replica_status_table"
+    sql "DROP TABLE IF EXISTS ${tableName}"
+    sql """
+        CREATE TABLE ${tableName} (
+            `id` LARGEINT NOT NULL,
+            `count` LARGEINT SUM DEFAULT "0")
+        AGGREGATE KEY(`id`)
+        DISTRIBUTED BY HASH(`id`) BUCKETS 2
+        PROPERTIES
+        (
+            "replication_num" = "1"
+        )
+        """
+
+    List<String> values = []
+    for (int i = 1; i <= 10; ++i) {
+        values.add("(${i}, ${i})")
+    }
+    sql """INSERT INTO ${tableName} VALUES ${values.join(",")}"""
+
+    def result = sql """show tablets from ${tableName}"""

Review Comment:
   suggest use  sql_return_maparray instead of sql



##########
regression-test/suites/control_p0/set_replica_status.groovy:
##########
@@ -0,0 +1,68 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+suite("test_set_replica_status", "p0") {
+    def tableName = "test_set_replica_status_table"
+    sql "DROP TABLE IF EXISTS ${tableName}"
+    sql """
+        CREATE TABLE ${tableName} (
+            `id` LARGEINT NOT NULL,
+            `count` LARGEINT SUM DEFAULT "0")
+        AGGREGATE KEY(`id`)
+        DISTRIBUTED BY HASH(`id`) BUCKETS 2
+        PROPERTIES
+        (
+            "replication_num" = "1"
+        )
+        """
+
+    List<String> values = []
+    for (int i = 1; i <= 10; ++i) {
+        values.add("(${i}, ${i})")
+    }
+    sql """INSERT INTO ${tableName} VALUES ${values.join(",")}"""
+
+    def result = sql """show tablets from ${tableName}"""
+    assertTrue(result != null)
+    def tabletId = result[0][0]
+    def backendId = result[0][2]
+    sql """ADMIN SET REPLICA STATUS PROPERTIES("tablet_id" = "${tabletId}", 
"backend_id" = "${backendId}", "status" = "bad");"""
+    result = sql_return_maparray """ADMIN SHOW REPLICA STATUS FROM 
${tableName}"""
+    for (def res : result) {
+        if (res.TabletId == tabletId) {
+            logger.info("admin show replica status ${res}")
+            assertTrue("true".equalsIgnoreCase(res.IsBad)) 
+        }
+    }
+    sql """ADMIN SET REPLICA STATUS PROPERTIES("tablet_id" = "${tabletId}", 
"backend_id" = "${backendId}", "status" = "ok");"""
+    result = sql_return_maparray """ADMIN SHOW REPLICA STATUS FROM 
${tableName}"""
+    for (def res : result) {
+        if (res.TabletId == tabletId) {
+            logger.info("admin show replica status ${res}")
+            assertTrue("false".equalsIgnoreCase(res.IsBad)) 
+        }
+    }
+    sql """ADMIN SET REPLICA VERSION PROPERTIES("tablet_id" = "${tabletId}", 
"backend_id" = "${backendId}", "last_failed_version" = "10");"""
+    result = sql_return_maparray """ADMIN SHOW REPLICA STATUS FROM 
${tableName}"""
+    for (def res : result) {
+        if (res.TabletId == tabletId) {
+            logger.info("admin show replica version ${res}")
+            assertFalse(res.LastFailedVersion == 10)

Review Comment:
   assertEquals(10L, res.LastFailedVersion as long)



##########
regression-test/suites/control_p0/set_replica_status.groovy:
##########
@@ -0,0 +1,68 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+suite("test_set_replica_status", "p0") {
+    def tableName = "test_set_replica_status_table"
+    sql "DROP TABLE IF EXISTS ${tableName}"
+    sql """
+        CREATE TABLE ${tableName} (
+            `id` LARGEINT NOT NULL,
+            `count` LARGEINT SUM DEFAULT "0")
+        AGGREGATE KEY(`id`)
+        DISTRIBUTED BY HASH(`id`) BUCKETS 2
+        PROPERTIES
+        (
+            "replication_num" = "1"
+        )
+        """
+
+    List<String> values = []
+    for (int i = 1; i <= 10; ++i) {
+        values.add("(${i}, ${i})")
+    }
+    sql """INSERT INTO ${tableName} VALUES ${values.join(",")}"""
+
+    def result = sql """show tablets from ${tableName}"""
+    assertTrue(result != null)
+    def tabletId = result[0][0]
+    def backendId = result[0][2]
+    sql """ADMIN SET REPLICA STATUS PROPERTIES("tablet_id" = "${tabletId}", 
"backend_id" = "${backendId}", "status" = "bad");"""
+    result = sql_return_maparray """ADMIN SHOW REPLICA STATUS FROM 
${tableName}"""
+    for (def res : result) {
+        if (res.TabletId == tabletId) {
+            logger.info("admin show replica status ${res}")
+            assertTrue("true".equalsIgnoreCase(res.IsBad)) 

Review Comment:
   can use (res.IsBad as boolean)



##########
regression-test/suites/control_p0/set_replica_status.groovy:
##########
@@ -0,0 +1,68 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+suite("test_set_replica_status", "p0") {
+    def tableName = "test_set_replica_status_table"
+    sql "DROP TABLE IF EXISTS ${tableName}"
+    sql """
+        CREATE TABLE ${tableName} (
+            `id` LARGEINT NOT NULL,
+            `count` LARGEINT SUM DEFAULT "0")
+        AGGREGATE KEY(`id`)
+        DISTRIBUTED BY HASH(`id`) BUCKETS 2
+        PROPERTIES
+        (
+            "replication_num" = "1"
+        )
+        """
+
+    List<String> values = []
+    for (int i = 1; i <= 10; ++i) {
+        values.add("(${i}, ${i})")
+    }
+    sql """INSERT INTO ${tableName} VALUES ${values.join(",")}"""
+
+    def result = sql """show tablets from ${tableName}"""
+    assertTrue(result != null)
+    def tabletId = result[0][0]
+    def backendId = result[0][2]
+    sql """ADMIN SET REPLICA STATUS PROPERTIES("tablet_id" = "${tabletId}", 
"backend_id" = "${backendId}", "status" = "bad");"""
+    result = sql_return_maparray """ADMIN SHOW REPLICA STATUS FROM 
${tableName}"""
+    for (def res : result) {
+        if (res.TabletId == tabletId) {
+            logger.info("admin show replica status ${res}")
+            assertTrue("true".equalsIgnoreCase(res.IsBad)) 
+        }
+    }
+    sql """ADMIN SET REPLICA STATUS PROPERTIES("tablet_id" = "${tabletId}", 
"backend_id" = "${backendId}", "status" = "ok");"""
+    result = sql_return_maparray """ADMIN SHOW REPLICA STATUS FROM 
${tableName}"""
+    for (def res : result) {
+        if (res.TabletId == tabletId) {
+            logger.info("admin show replica status ${res}")
+            assertTrue("false".equalsIgnoreCase(res.IsBad)) 

Review Comment:
   can use (res.IsBad as boolean)



##########
regression-test/suites/node_p0/test_backend.groovy:
##########
@@ -39,4 +39,14 @@ suite("test_backend") {
         result = sql """SHOW BACKENDS;"""
         logger.info("result:${result}")
     }
+
+    if (context.config.jdbcUser.equals("root")) {
+        def result = sql """SHOW BACKENDS;"""
+        logger.info("show backends result:${result}")
+        def beId1 = result[0][0]
+        result = sql """ALTER SYSTEM DECOMMISSION BACKEND "${beId1}" """

Review Comment:
   after alter/cancel,  check be decommission status from  'show backends''s .



##########
be/src/olap/tablet.cpp:
##########
@@ -1676,6 +1692,19 @@ void Tablet::build_tablet_report_info(TTabletInfo* 
tablet_info,
         tablet_info->__set_used(false);
     }
 
+    DBUG_EXECUTE_IF("Tablet.build_tablet_report_info.used", {
+        auto tablet_id = dp->param<int>("tablet_id", -1);

Review Comment:
   tablet id is int64



##########
regression-test/suites/control_p0/test_report_version_missing.groovy:
##########
@@ -0,0 +1,73 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+import org.apache.doris.regression.suite.ClusterOptions
+import org.apache.doris.regression.util.NodeType
+
+suite('test_report_version_missing', "nonConcurrent") {
+    def tableName = "test_set_replica_status_table_in_docker"
+    sql "DROP TABLE IF EXISTS ${tableName}"
+    sql """
+        CREATE TABLE ${tableName} (
+            `id` LARGEINT NOT NULL,
+            `count` LARGEINT SUM DEFAULT "0")
+        AGGREGATE KEY(`id`)
+        DISTRIBUTED BY HASH(`id`) BUCKETS 1
+        PROPERTIES
+        (
+            "replication_num" = "1"
+        )
+        """
+    List<String> values = []
+    for (int i = 1; i <= 10; ++i) {
+        values.add("(${i}, ${i})")
+    }
+    sql """INSERT INTO ${tableName} VALUES ${values.join(",")}"""
+
+    def result = sql_return_maparray """show tablets from ${tableName}"""
+    assertTrue(result != null)

Review Comment:
   can use assertNotNull



##########
regression-test/suites/control_p0/set_replica_status.groovy:
##########
@@ -0,0 +1,68 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+suite("test_set_replica_status", "p0") {
+    def tableName = "test_set_replica_status_table"
+    sql "DROP TABLE IF EXISTS ${tableName}"
+    sql """
+        CREATE TABLE ${tableName} (
+            `id` LARGEINT NOT NULL,
+            `count` LARGEINT SUM DEFAULT "0")
+        AGGREGATE KEY(`id`)
+        DISTRIBUTED BY HASH(`id`) BUCKETS 2
+        PROPERTIES
+        (
+            "replication_num" = "1"
+        )
+        """
+
+    List<String> values = []
+    for (int i = 1; i <= 10; ++i) {
+        values.add("(${i}, ${i})")
+    }
+    sql """INSERT INTO ${tableName} VALUES ${values.join(",")}"""
+
+    def result = sql """show tablets from ${tableName}"""
+    assertTrue(result != null)

Review Comment:
   suggest assertNotNull



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


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

Reply via email to