Skip to content

Commit 1912da3

Browse files
authored
CPP-943: Fix intermittent failures of SchemaAgreementUnitTest.Simple (#512)
The test stops cluster nodes and then performs queries. It is possible for that query to start being executed before the session detects the connection going down, resulting in test failures. https://datastax-oss.atlassian.net/browse/CPP-943
1 parent 151f398 commit 1912da3

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

tests/src/unit/tests/test_schema_agreement.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ class SchemaAgreementUnitTest : public LoopTest {
5555
static void execute(Session* session, const String& query) {
5656
Future::Ptr request_future(session->execute(QueryRequest::ConstPtr(new QueryRequest(query))));
5757
EXPECT_TRUE(request_future->wait_for(WAIT_FOR_TIME));
58-
EXPECT_FALSE(request_future->error());
58+
EXPECT_FALSE(request_future->error()) << cass_error_desc(request_future->error()->code) << ": "
59+
<< request_future->error()->message;
5960
}
6061

6162
struct SchemaVersionCheckCounts {
@@ -191,12 +192,16 @@ TEST_F(SchemaAgreementUnitTest, Simple) {
191192
EXPECT_EQ(logging_criteria_count(), 1);
192193

193194
cluster.stop(2);
195+
// Give time for the session to see and react to the socket close, otherwise the next
196+
// query can wind up getting a "Request timed out" error if the close happens mid-flight
197+
test::Utils::msleep(100);
194198
execute(&session, "DROP TABLE tbl");
195199
EXPECT_EQ(check_counts.local_count.load(), 2);
196200
EXPECT_EQ(check_counts.peers_count.load(), 2);
197201
EXPECT_EQ(logging_criteria_count(), 2);
198202

199203
cluster.stop(3);
204+
test::Utils::msleep(100);
200205
execute(&session, "CREATE TABLE tbl (key text PRIMARY KEY, value text)");
201206
EXPECT_EQ(check_counts.local_count.load(), 3);
202207
EXPECT_EQ(check_counts.peers_count.load(), 3);

0 commit comments

Comments
 (0)