You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by al...@apache.org on 2023/03/22 15:34:44 UTC

[kudu] branch master updated: [ut] make a checking command of 'TestTServerListState' more meaningful

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

alexey pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kudu.git


The following commit(s) were added to refs/heads/master by this push:
     new 71e0ed731 [ut] make a checking command of 'TestTServerListState' more meaningful
71e0ed731 is described below

commit 71e0ed7311e955fd421692cc41011debba709081
Author: duyuqi <sh...@gmail.com>
AuthorDate: Mon Mar 13 11:18:58 2023 +0800

    [ut] make a checking command of 'TestTServerListState' more meaningful
    
    This patch is not important. An useless checking command found
    when I review codes, because the checking command is always true
    So, improve it.
    
    Change-Id: I2cc3c16cba812eaaa8786cea37659fd5e9267fd3
    Reviewed-on: http://gerrit.cloudera.org:8080/19611
    Tested-by: Kudu Jenkins
    Reviewed-by: Yingchun Lai <la...@apache.org>
    Reviewed-by: Alexey Serbin <al...@apache.org>
---
 src/kudu/tools/kudu-tool-test.cc | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/src/kudu/tools/kudu-tool-test.cc b/src/kudu/tools/kudu-tool-test.cc
index 92719b6f1..8cee955c6 100644
--- a/src/kudu/tools/kudu-tool-test.cc
+++ b/src/kudu/tools/kudu-tool-test.cc
@@ -4872,7 +4872,10 @@ TEST_F(ToolTest, TestTserverListLocationNotAssigned) {
 }
 
 TEST_F(ToolTest, TestTServerListState) {
-  NO_FATALS(StartExternalMiniCluster());
+  constexpr const int kTServerNum = 3;
+  ExternalMiniClusterOptions options;
+  options.num_tablet_servers = kTServerNum;
+  NO_FATALS(StartExternalMiniCluster(options));
   string master_addr = cluster_->master()->bound_rpc_addr().ToString();
   const string ts_uuid = cluster_->tablet_server(0)->uuid();
 
@@ -4880,15 +4883,17 @@ TEST_F(ToolTest, TestTServerListState) {
   NO_FATALS(RunActionStdoutNone(Substitute("tserver state enter_maintenance $0 $1",
                                            master_addr, ts_uuid)));
 
-  // If the state isn't requested, we shouldn't see any.
   string out;
   NO_FATALS(RunActionStdoutString(
-        Substitute("tserver list $0 --columns=uuid --format=csv", master_addr), &out));
-  ASSERT_STR_NOT_CONTAINS(out, Substitute("$0,$1", ts_uuid, "MAINTENANCE_MODE"));
+        Substitute("tserver list $0 --columns=uuid,state --format=csv", master_addr), &out));
+
+  for (int i = 1; i < kTServerNum; i++) {
+    // If a ts isn't requested, we shouldn't see its maintenance state.
+    const string ts_uuid_noop = cluster_->tablet_server(i)->uuid();
+    ASSERT_STR_NOT_CONTAINS(out, Substitute("$0,$1", ts_uuid_noop, "MAINTENANCE_MODE"));
+  }
 
   // If it is requested, we should see the state.
-  NO_FATALS(RunActionStdoutString(
-        Substitute("tserver list $0 --columns=uuid,state --format=csv", master_addr), &out));
   ASSERT_STR_CONTAINS(out, Substitute("$0,$1", ts_uuid, "MAINTENANCE_MODE"));
 
   // Ksck should show a table showing the state.