Skip to content

Commit 5a23f48

Browse files
committed
[yugabyte#5039] Increase timeout in CQL tests
Summary: In CppCassandraDriverTest.Rejection we spam server with batch statements and check how queries are being delayed because of artificial rejection. Currently we use timeout of 12 seconds and wait half of timeout to interpret such query as pending. And expect that at most 1/3 of queries are being in this state. But since this test is generates significant load on server sometimes we get more queries marked as pending. Increased timeout to 20s to fix this issue. Test Plan: ybd --gtest_filter CppCassandraDriverTest.Rejection -n 40 Reviewers: timur Reviewed By: timur Subscribers: ybase Differential Revision: https://phabricator.dev.yugabyte.com/D12247
1 parent 4cf9242 commit 5a23f48

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

src/yb/integration-tests/cassandra_cpp_driver-test.cc

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2945,20 +2945,25 @@ TEST_F_EX(CppCassandraDriverTest, Rejection, CppCassandraDriverRejectionTest) {
29452945
thread_holder.AddThreadFunctor(
29462946
[this, &stop = thread_holder.stop_flag(), &table, &key, &pending_writes,
29472947
&max_pending_writes] {
2948-
SetFlagOnExit set_flag_on_exit(&stop);
29492948
auto session = ASSERT_RESULT(EstablishSession());
2950-
while (!stop.load()) {
2951-
CassandraBatch batch(CassBatchType::CASS_BATCH_TYPE_LOGGED);
2952-
auto prepared = table.PrepareInsert(&session);
2953-
if (!prepared.ok()) {
2949+
CassandraPrepared prepared;
2950+
ASSERT_OK(WaitFor([&table, &session, &prepared] {
2951+
auto prepared_result = table.PrepareInsert(&session);
2952+
if (!prepared_result.ok()) {
29542953
// Prepare could be failed because cluster has heavy load.
29552954
// It is ok to just retry in this case, because we expect total number of writes.
2956-
continue;
2955+
LOG(INFO) << "Prepare failed: " << prepared_result.status();
2956+
return false;
29572957
}
2958+
prepared = std::move(*prepared_result);
2959+
return true;
2960+
}, kCassandraTimeOut * 5, "Prepare statement"));
2961+
while (!stop.load()) {
2962+
CassandraBatch batch(CassBatchType::CASS_BATCH_TYPE_LOGGED);
29582963
for (int i = 0; i != kBatchSize; ++i) {
29592964
auto current_key = key++;
29602965
ColumnsType tuple(current_key, -current_key);
2961-
auto statement = prepared->Bind();
2966+
auto statement = prepared.Bind();
29622967
table.BindInsert(&statement, tuple);
29632968
batch.Add(&statement);
29642969
}
@@ -2969,8 +2974,6 @@ TEST_F_EX(CppCassandraDriverTest, Rejection, CppCassandraDriverRejectionTest) {
29692974
auto mpw = max_pending_writes.load();
29702975
while (pw > mpw) {
29712976
if (max_pending_writes.compare_exchange_weak(mpw, pw)) {
2972-
// Assert that we don't have too many pending writers.
2973-
ASSERT_LE(pw, kWriters / 3);
29742977
break;
29752978
}
29762979
}
@@ -2986,6 +2989,8 @@ TEST_F_EX(CppCassandraDriverTest, Rejection, CppCassandraDriverRejectionTest) {
29862989

29872990
thread_holder.WaitAndStop(30s);
29882991
LOG(INFO) << "Max pending writes: " << max_pending_writes.load();
2992+
// Assert that we don't have too many pending writers.
2993+
ASSERT_LE(max_pending_writes.load(), kWriters / 3);
29892994
}
29902995

29912996
TEST_F(CppCassandraDriverTest, BigQueryExpr) {

src/yb/integration-tests/cql_test_util.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ CassandraStatement CassandraPrepared::Bind() {
421421
return CassandraStatement(cass_prepared_bind(prepared_.get()));
422422
}
423423

424-
const MonoDelta kCassandraTimeOut = RegularBuildVsSanitizers(12s, 60s);
424+
const MonoDelta kCassandraTimeOut = 20s * kTimeMultiplier;
425425

426426
CppCassandraDriver::CppCassandraDriver(
427427
const std::vector<std::string>& hosts, uint16_t port,

0 commit comments

Comments
 (0)