This is an automated email from the ASF dual-hosted git repository. laiyingchun pushed a commit to branch branch-1.17.x in repository https://gitbox.apache.org/repos/asf/kudu.git
commit f27dbe4500e136a4abeb86410d8701d7d88fbe8b Author: kedeng <[email protected]> AuthorDate: Fri Aug 4 14:21:00 2023 +0800 KUDU-3432: Fix flakiness in client-test.cc The 'TestGetTableKeyRange' in 'client-test.cc' may be unstable in certain cases. Through analysis, it was determined that the split algorithm might encounter some corner cases when handling written data. To mitigate the impact of these cases on CI, I have increased the amount of data written in the unit tests and modified some logic in dance to enhance the robustness of the unit tests. Change-Id: I1e3fecc09f58d91fe9a8c6d20caa21938dd9c972 Reviewed-on: http://gerrit.cloudera.org:8080/20314 Reviewed-by: Alexey Serbin <[email protected]> Tested-by: Alexey Serbin <[email protected]> (cherry picked from commit acd1622b0c77b40280753567130a815cbcd93081) Reviewed-on: http://gerrit.cloudera.org:8080/20388 Tested-by: Kudu Jenkins Reviewed-by: Mahesh Reddy <[email protected]> Reviewed-by: Yingchun Lai <[email protected]> --- src/kudu/client/client-test.cc | 51 ++++++++++++++++++------------------------ 1 file changed, 22 insertions(+), 29 deletions(-) diff --git a/src/kudu/client/client-test.cc b/src/kudu/client/client-test.cc index f5fc102ed..dfc250348 100644 --- a/src/kudu/client/client-test.cc +++ b/src/kudu/client/client-test.cc @@ -8687,26 +8687,14 @@ class TableKeyRangeTest : public ClientTest { } static void InsertTestRowsWithStrings(KuduTable* table, KuduSession* session, int num_rows) { - vector<int> keys = { 0, 250, 500, 750 }; string str_val = "*"; - int diff_value = 120; // use to create discontinuous data in a tablet - for (int k = 0; k < keys.size(); k++) { - for (int i = keys[k]; i < keys[k] + num_rows; i++) { - unique_ptr<KuduInsert> insert(table->NewInsert()); - ASSERT_OK(insert->mutable_row()->SetInt32("key", i)); - ASSERT_OK(insert->mutable_row()->SetInt32("int_val", i * 2)); - ASSERT_OK(insert->mutable_row()->SetString("string_val", str_val)); - ASSERT_OK(session->Apply(insert.release())); - ASSERT_OK(session->Flush()); - } - for (int i = keys[k] + diff_value; i < keys[k] + diff_value + num_rows; i++) { - unique_ptr<KuduInsert> insert(table->NewInsert()); - ASSERT_OK(insert->mutable_row()->SetInt32("key", i)); - ASSERT_OK(insert->mutable_row()->SetInt32("int_val", i * 2)); - ASSERT_OK(insert->mutable_row()->SetString("string_val", str_val)); - ASSERT_OK(session->Apply(insert.release())); - ASSERT_OK(session->Flush()); - } + for (int i = 0; i < num_rows; i++) { + unique_ptr<KuduInsert> insert(table->NewInsert()); + ASSERT_OK(insert->mutable_row()->SetInt32("key", i)); + ASSERT_OK(insert->mutable_row()->SetInt32("int_val", i * 2)); + ASSERT_OK(insert->mutable_row()->SetString("string_val", str_val)); + ASSERT_OK(session->Apply(insert.release())); + ASSERT_OK(session->Flush()); } } @@ -8728,7 +8716,7 @@ TEST_F(TableKeyRangeTest, TestGetTableKeyRange) { // Should have no rows to begin with. ASSERT_EQ(0, CountRowsFromClient(table.get())); // Insert rows - NO_FATALS(InsertTestRowsWithStrings(client_table_.get(), session.get(), 100)); + NO_FATALS(InsertTestRowsWithStrings(client_table_.get(), session.get(), 1000)); NO_FATALS(CheckNoRpcOverflow()); } @@ -8744,7 +8732,7 @@ TEST_F(TableKeyRangeTest, TestGetTableKeyRange) { ASSERT_EQ(4, tokens.size()); NO_FATALS(CheckTokensInfo(tokens)); - ASSERT_EQ(800, CountRows(tokens)); + ASSERT_EQ(1000, CountRows(tokens)); } { @@ -8760,7 +8748,7 @@ TEST_F(TableKeyRangeTest, TestGetTableKeyRange) { ASSERT_EQ(4, tokens.size()); NO_FATALS(CheckTokensInfo(tokens)); - ASSERT_EQ(800, CountRows(tokens)); + ASSERT_EQ(1000, CountRows(tokens)); } uint32_t token_size_a = 0; @@ -8773,10 +8761,10 @@ TEST_F(TableKeyRangeTest, TestGetTableKeyRange) { builder.SetSplitSizeBytes(700); ASSERT_OK(builder.Build(&tokens)); token_size_a = tokens.size(); - ASSERT_LT(4, token_size_a); + ASSERT_LE(4, token_size_a); NO_FATALS(CheckTokensInfo(tokens)); - ASSERT_EQ(800, CountRows(tokens)); + ASSERT_EQ(1000, CountRows(tokens)); } uint32_t token_size_b = 0; @@ -8789,14 +8777,18 @@ TEST_F(TableKeyRangeTest, TestGetTableKeyRange) { builder.SetSplitSizeBytes(20); ASSERT_OK(builder.Build(&tokens)); token_size_b = tokens.size(); - ASSERT_LT(4, token_size_b); + ASSERT_LE(4, token_size_b); NO_FATALS(CheckTokensInfo(tokens)); - ASSERT_EQ(800, CountRows(tokens)); + ASSERT_EQ(1000, CountRows(tokens)); } - // diffferent splitSizeBytes leads to different token - ASSERT_NE(token_size_a, token_size_b); + // Different "splitSizeBytes" values typically leads to + // different numbers of tokens, although they may also + // leads to the same number of tokens. + // However, a smaller "splitSizeBytes" value will definitely + // not generate fewer tokens than a larger "splitSizeBytes" value. + ASSERT_LE(token_size_a, token_size_b); { // search from tserver @@ -8809,9 +8801,10 @@ TEST_F(TableKeyRangeTest, TestGetTableKeyRange) { ASSERT_EQ(tokens.size(), 4); NO_FATALS(CheckTokensInfo(tokens)); - ASSERT_EQ(800, CountRows(tokens)); + ASSERT_EQ(1000, CountRows(tokens)); } } + class ClientTxnManagerProxyTest : public ClientTest { public: void SetUp() override {
