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 2025/03/26 15:01:22 UTC
(kudu) 03/04: KUDU-3653 fix flaky test in ts_tablet_manager-test
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
commit 110352d0163fa390ac25f4d69232886f84fb85dd
Author: Alexey Serbin <al...@apache.org>
AuthorDate: Mon Mar 24 13:45:19 2025 -0700
KUDU-3653 fix flaky test in ts_tablet_manager-test
Before this patch, the TestCreateAndDifferentModeDeleteMetrics scenario
of TestCreateAndDeleteMetrics in ts_tablet_manager-test would usually
fail once in every 30 runs. With this patch, not a single failure
has been detected in more than 500 runs of the test scenario.
Change-Id: Iec7832d24e94247b0788c6eca7c85deedce54e4e
Reviewed-on: http://gerrit.cloudera.org:8080/22659
Tested-by: Alexey Serbin <al...@apache.org>
Reviewed-by: Yifan Zhang <ch...@163.com>
---
src/kudu/tserver/ts_tablet_manager-test.cc | 33 ++++++++++++++++--------------
1 file changed, 18 insertions(+), 15 deletions(-)
diff --git a/src/kudu/tserver/ts_tablet_manager-test.cc b/src/kudu/tserver/ts_tablet_manager-test.cc
index a3bf78889..930729f2f 100644
--- a/src/kudu/tserver/ts_tablet_manager-test.cc
+++ b/src/kudu/tserver/ts_tablet_manager-test.cc
@@ -198,28 +198,31 @@ INSTANTIATE_TEST_SUITE_P(Params, TestCreateAndDeleteMetrics,
TabletDataState::TABLET_DATA_TOMBSTONED));
TEST_P(TestCreateAndDeleteMetrics, TestCreateAndDifferentModeDeleteMetrics) {
- TabletDataState data_state = GetParam();
- scoped_refptr<Histogram> create_tablet_run_time =
- METRIC_create_tablet_run_time.Instantiate(mini_server_->server()->metric_entity());
- ASSERT_EQ(0, create_tablet_run_time->TotalCount());
-
- scoped_refptr<Histogram> delete_tablet_run_time =
- METRIC_delete_tablet_run_time.Instantiate(mini_server_->server()->metric_entity());
- ASSERT_EQ(0, delete_tablet_run_time->TotalCount());
-
- string test_tablet = "ffffffffffffffffffffffffffffffff";
+ static const string kTestTablet = "ffffffffffffffffffffffffffffffff";
+ const TabletDataState data_state = GetParam();
scoped_refptr<TabletReplica> test_replica;
+ scoped_refptr<Histogram> create_tablet_run_time =
+ METRIC_create_tablet_run_time.Instantiate(mini_server_->server()->metric_entity());
+ ASSERT_EQ(0, create_tablet_run_time->TotalCount());
// Create a new tablet.
- ASSERT_OK(CreateNewTablet(test_tablet, schema_, true, nullopt, nullopt, &test_replica));
- ASSERT_EQ(test_tablet, test_replica->tablet()->tablet_id());
+ ASSERT_OK(CreateNewTablet(kTestTablet, schema_, true, nullopt, nullopt, &test_replica));
+ ASSERT_EQ(kTestTablet, test_replica->tablet()->tablet_id());
// Metrics should be incremented.
ASSERT_EQ(1, create_tablet_run_time->TotalCount());
+ // Wait for the tablet state transition to complete, otherwise there will be
+ // an error reported by TSTabletManager::StartTabletStateTransitionUnlocked().
+ ASSERT_EVENTUALLY([&] () {
+ ASSERT_OK(tablet_manager_->WaitForNoTransitionsForTests(
+ MonoDelta::FromSeconds(1)));
+ });
+
+ scoped_refptr<Histogram> delete_tablet_run_time =
+ METRIC_delete_tablet_run_time.Instantiate(mini_server_->server()->metric_entity());
ASSERT_EQ(0, delete_tablet_run_time->TotalCount());
- ASSERT_OK(tablet_manager_->DeleteTablet(test_tablet,
- data_state,
- nullopt));
+ // Delete the newly created tablet.
+ ASSERT_OK(tablet_manager_->DeleteTablet(kTestTablet, data_state, nullopt));
// Metrics should be incremented.
ASSERT_EQ(1, delete_tablet_run_time->TotalCount());
}