From 735fe61e8fbede35dd97908e501dc726bd733aa0 Mon Sep 17 00:00:00 2001 From: Peter Dillinger Date: Mon, 29 Nov 2021 09:51:50 -0800 Subject: [PATCH] Fix flaky CassandraFunctionalTest...ExpiredColumnsToTombstone (#9226) Summary: You could easily reproduce the failure by injecting sleep(11) before `store.Flush()`. Fixed by setting TTL time to approximately test timeout time. Pull Request resolved: https://github.com/facebook/rocksdb/pull/9226 Test Plan: manual Reviewed By: akankshamahajan15 Differential Revision: D32698105 Pulled By: pdillinger fbshipit-source-id: 40529af9d9f2389585988b7c81dffb120e2795a2 --- .../cassandra/cassandra_functional_test.cc | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/utilities/cassandra/cassandra_functional_test.cc b/utilities/cassandra/cassandra_functional_test.cc index bde20340a..9d1143b34 100644 --- a/utilities/cassandra/cassandra_functional_test.cc +++ b/utilities/cassandra/cassandra_functional_test.cc @@ -182,16 +182,22 @@ TEST_F(CassandraFunctionalTest, SimpleMergeTest) { ToMicroSeconds(now + 11)); } +constexpr int64_t kTestTimeoutSecs = 600; + TEST_F(CassandraFunctionalTest, CompactionShouldConvertExpiredColumnsToTombstone) { CassandraStore store(OpenDb()); int64_t now= time(nullptr); - store.Append("k1", CreateTestRowValue({ - CreateTestColumnSpec(kExpiringColumn, 0, ToMicroSeconds(now - kTtl - 20)), //expired - CreateTestColumnSpec(kExpiringColumn, 1, ToMicroSeconds(now - kTtl + 10)), // not expired - CreateTestColumnSpec(kTombstone, 3, ToMicroSeconds(now)) - })); + store.Append( + "k1", + CreateTestRowValue( + {CreateTestColumnSpec(kExpiringColumn, 0, + ToMicroSeconds(now - kTtl - 20)), // expired + CreateTestColumnSpec( + kExpiringColumn, 1, + ToMicroSeconds(now - kTtl + kTestTimeoutSecs)), // not expired + CreateTestColumnSpec(kTombstone, 3, ToMicroSeconds(now))})); ASSERT_OK(store.Flush()); @@ -210,7 +216,7 @@ TEST_F(CassandraFunctionalTest, VerifyRowValueColumns(merged.get_columns(), 0, kTombstone, 0, ToMicroSeconds(now - 10)); VerifyRowValueColumns(merged.get_columns(), 1, kExpiringColumn, 1, - ToMicroSeconds(now - kTtl + 10)); + ToMicroSeconds(now - kTtl + kTestTimeoutSecs)); VerifyRowValueColumns(merged.get_columns(), 2, kColumn, 2, ToMicroSeconds(now)); VerifyRowValueColumns(merged.get_columns(), 3, kTombstone, 3,