[tools] mark long-running scenarios in kudu-tool-test

I noticed that it takes very long time for kudu-tool-test to complete.
It turned out the test suite contains many scenarios that run with
HMS integration enabled and it takes a long time to start up the
HMS process.

This patch marks the scenarios that tend to run over 3 seconds
as slow, so they are skipped unless the KUDU_ALLOW_SLOW_TESTS
environment variable is set to true/yes/1.

The run time of the kudu-tool-test with this patch looks like the
following on a contemporary Linux machine:

Without KUDU_ALLOW_SLOW_TESTS:
  [==========] 128 tests from 8 test suites ran. (86355 ms total)
  [  PASSED  ] 88 tests.
  [  SKIPPED ] 40 tests, listed below:
  ...

With KUDU_ALLOW_SLOW_TESTS=1:
  [==========] 128 tests from 8 test suites ran. (842684 ms total)
  [  PASSED  ] 128 tests.

Change-Id: I1893741fada185d819128396c88f4ac99f43ed40
Reviewed-on: http://gerrit.cloudera.org:8080/18947
Reviewed-by: Mahesh Reddy <mreddy@cloudera.com>
Tested-by: Alexey Serbin <alexey@apache.org>
Reviewed-by: Yifan Zhang <chinazhangyifan@163.com>
diff --git a/src/kudu/tools/kudu-tool-test.cc b/src/kudu/tools/kudu-tool-test.cc
index da9dcdb..0c6cc29 100644
--- a/src/kudu/tools/kudu-tool-test.cc
+++ b/src/kudu/tools/kudu-tool-test.cc
@@ -1222,6 +1222,7 @@
 }
 
 TEST_F(ToolTest, TestModeHelp) {
+  SKIP_IF_SLOW_NOT_ALLOWED();
   {
     const string kCmd = "cluster";
     const vector<string> kClusterModeRegexes = {
@@ -3324,6 +3325,7 @@
 }
 
 TEST_F(ToolTest, TestLoadgenHmsEnabled) {
+  SKIP_IF_SLOW_NOT_ALLOWED();
   ExternalMiniClusterOptions opts;
   opts.hms_mode = HmsMode::ENABLE_HIVE_METASTORE;
   NO_FATALS(StartExternalMiniCluster(std::move(opts)));
@@ -3402,6 +3404,7 @@
 
 // Run the loadgen with txn-related options.
 TEST_F(ToolTest, LoadgenTxnBasics) {
+  SKIP_IF_SLOW_NOT_ALLOWED();
   {
     ExternalMiniClusterOptions opts;
     // Prefer lighter cluster to speed up testing.
@@ -3563,6 +3566,7 @@
 // Test that a non-random workload results in the behavior we would expect when
 // running against an auto-generated range partitioned table.
 TEST_F(ToolTest, TestNonRandomWorkloadLoadgen) {
+  SKIP_IF_SLOW_NOT_ALLOWED();
   {
     ExternalMiniClusterOptions opts;
     opts.num_tablet_servers = 1;
@@ -4696,6 +4700,7 @@
 }
 
 TEST_F(ToolTest, TestListTables) {
+  SKIP_IF_SLOW_NOT_ALLOWED();
   NO_FATALS(StartExternalMiniCluster());
   shared_ptr<KuduClient> client;
   ASSERT_OK(cluster_->CreateClient(nullptr, &client));
@@ -5106,6 +5111,7 @@
 }
 
 TEST_P(ToolTestCopyTableParameterized, TestCopyTable) {
+  SKIP_IF_SLOW_NOT_ALLOWED();
   for (const auto& arg : GenerateArgs()) {
     NO_FATALS(RunCopyTableCheck(arg));
   }
@@ -5797,6 +5803,7 @@
 }
 
 TEST_P(ToolTestKerberosParameterized, TestHmsDowngrade) {
+  SKIP_IF_SLOW_NOT_ALLOWED();
   ExternalMiniClusterOptions opts;
   opts.hms_mode = HmsMode::ENABLE_METASTORE_INTEGRATION;
   opts.enable_kerberos = EnableKerberos();
@@ -5857,6 +5864,7 @@
 // Test HMS inconsistencies that can be automatically fixed.
 // Kerberos is enabled in order to test the tools work in secure clusters.
 TEST_P(ToolTestKerberosParameterized, TestCheckAndAutomaticFixHmsMetadata) {
+  SKIP_IF_SLOW_NOT_ALLOWED();
   string kUsername = "alice";
   string kOtherUsername = "bob";
   string kOtherComment = "a table comment";
@@ -6285,6 +6293,7 @@
 // TODO(ghenke): Add test case for external table using the same name as
 //  an existing Kudu table.
 TEST_P(ToolTestKerberosParameterized, TestCheckAndManualFixHmsMetadata) {
+  SKIP_IF_SLOW_NOT_ALLOWED();
   string kUsername = "alice";
   ExternalMiniClusterOptions opts;
   opts.hms_mode = HmsMode::DISABLE_HIVE_METASTORE;
@@ -6418,6 +6427,7 @@
 }
 
 TEST_F(ToolTest, TestHmsIgnoresDifferentMasters) {
+  SKIP_IF_SLOW_NOT_ALLOWED();
   ExternalMiniClusterOptions opts;
   opts.num_masters = 2;
   opts.hms_mode = HmsMode::ENABLE_METASTORE_INTEGRATION;
@@ -6505,6 +6515,7 @@
 // is enabled, keeping the behavior of the tool backward-compatible even after
 // introducing the "table soft-delete" feature.
 TEST_F(ToolTest, DropTableHmsEnabled) {
+  SKIP_IF_SLOW_NOT_ALLOWED();
   ExternalMiniClusterOptions opts;
   opts.hms_mode = HmsMode::ENABLE_METASTORE_INTEGRATION;
   NO_FATALS(StartExternalMiniCluster(std::move(opts)));
@@ -6521,6 +6532,7 @@
 }
 
 TEST_F(ToolTest, TestHmsPrecheck) {
+  SKIP_IF_SLOW_NOT_ALLOWED();
   ExternalMiniClusterOptions opts;
   opts.hms_mode = HmsMode::ENABLE_HIVE_METASTORE;
   NO_FATALS(StartExternalMiniCluster(std::move(opts)));
@@ -6592,6 +6604,7 @@
 }
 
 TEST_F(ToolTest, TestHmsList) {
+  SKIP_IF_SLOW_NOT_ALLOWED();
   ExternalMiniClusterOptions opts;
   opts.hms_mode = HmsMode::ENABLE_HIVE_METASTORE;
   opts.enable_kerberos = EnableKerberos();
@@ -6659,6 +6672,7 @@
 }
 
 TEST_F(ToolTest, TestHMSAddressLog) {
+  SKIP_IF_SLOW_NOT_ALLOWED();
   ExternalMiniClusterOptions opts;
   opts.hms_mode = HmsMode::ENABLE_HIVE_METASTORE;
   opts.enable_kerberos = EnableKerberos();
@@ -6764,6 +6778,7 @@
                                             ::testing::Bool()));
 
 TEST_P(ControlShellToolTest, TestControlShell) {
+  SKIP_IF_SLOW_NOT_ALLOWED();
   constexpr auto kNumMasters = 1;
   constexpr auto kNumTservers = 3;
 
@@ -7428,6 +7443,7 @@
 }
 
 TEST_F(ToolTest, TestFsAddRemoveDataDirEndToEnd) {
+  SKIP_IF_SLOW_NOT_ALLOWED();
   const string kTableFoo = "foo";
   const string kTableBar = "bar";
 
@@ -7616,6 +7632,7 @@
 }
 
 TEST_F(ToolTest, TestReplaceTablet) {
+  SKIP_IF_SLOW_NOT_ALLOWED();
   constexpr int kNumTservers = 3;
   constexpr int kNumTablets = 3;
   constexpr int kNumRows = 1000;
@@ -7762,6 +7779,7 @@
 
 // This is a synthetic test to provide coverage for regressions of KUDU-2819.
 TEST_F(ToolTest, TabletServersWithUnusualFlags) {
+  SKIP_IF_SLOW_NOT_ALLOWED();
   // Run many tablet servers: it helps in detection of races, if any.
 #if defined(THREAD_SANITIZER)
   // In case of TSAN builds, it takes too long to wait for the start up of too
@@ -7988,6 +8006,7 @@
 
 // Test the authorization of Checksum scans via the CLI.
 TEST_F(AuthzTServerChecksumTest, TestAuthorizeChecksum) {
+  SKIP_IF_SLOW_NOT_ALLOWED();
   // First, let's create a table.
   const vector<string> loadgen_args = {
     "perf", "loadgen",
@@ -8009,6 +8028,7 @@
 
 // Regression test for KUDU-2851.
 TEST_F(ToolTest, TestFailedTableScan) {
+  SKIP_IF_SLOW_NOT_ALLOWED();
   // Create a table using the loadgen tool.
   const string kTableName = "db.table";
   NO_FATALS(RunLoadgen(/*num_tservers*/1, /*tool_args*/{},kTableName));
@@ -8032,6 +8052,7 @@
 }
 
 TEST_F(ToolTest, TestFailedTableCopy) {
+  SKIP_IF_SLOW_NOT_ALLOWED();
   // Create a table using the loadgen tool.
   const string kTableName = "db.table";
   NO_FATALS(RunLoadgen(/*num_tservers*/1, /*tool_args*/{},kTableName));
@@ -8136,6 +8157,7 @@
 }
 
 TEST_F(ToolTest, TestNonDefaultPrincipal) {
+  SKIP_IF_SLOW_NOT_ALLOWED();
   ExternalMiniClusterOptions opts;
   opts.enable_kerberos = true;
   opts.principal = "oryx";
@@ -8159,6 +8181,7 @@
 INSTANTIATE_TEST_SUITE_P(, UnregisterTServerTest, ::testing::Bool());
 
 TEST_P(UnregisterTServerTest, TestUnregisterTServer) {
+  SKIP_IF_SLOW_NOT_ALLOWED();
   bool remove_tserver_state = GetParam();
 
   // Set a short timeout that masters consider a tserver dead.
@@ -8275,6 +8298,7 @@
 }
 
 TEST_F(ToolTest, TestLocalReplicaCopyLocal) {
+  SKIP_IF_SLOW_NOT_ALLOWED();
   // TODO(abukor): Rewrite the test to make sure it works with encryption
   // enabled.
   //
@@ -8369,6 +8393,7 @@
 }
 
 TEST_F(ToolTest, TestLocalReplicaCopyRemote) {
+  SKIP_IF_SLOW_NOT_ALLOWED();
   InternalMiniClusterOptions opts;
   opts.num_tablet_servers = 2;
   NO_FATALS(StartMiniCluster(std::move(opts)));
@@ -8403,6 +8428,7 @@
 }
 
 TEST_F(ToolTest, TestRebuildTserverByLocalReplicaCopy) {
+  SKIP_IF_SLOW_NOT_ALLOWED();
   // Local copies are not supported on encrypted severs at this time.
   if (FLAGS_encrypt_data_at_rest) {
     GTEST_SKIP();