Skip to content

Commit 8e8029c

Browse files
driftxmichaelsembwever
authored andcommitted
CNDB-15447: set CQL timeout equal to server timeout in AggregationQueriesTest (#2073)
### What is the issue AggregationQueriesTest is flaky ### What does this PR fix and why was it fixed Sets the CQL timeout equal to server timeout so the client doesn't timeout before the server is done (Rebase of commit 9b3b3a3)
1 parent 0876f54 commit 8e8029c

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

test/unit/org/apache/cassandra/cql3/validation/operations/AggregationQueriesTest.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import org.junit.runner.RunWith;
3030

3131
import com.datastax.driver.core.Row;
32+
import com.datastax.driver.core.SimpleStatement;
3233
import com.datastax.driver.core.exceptions.ReadTimeoutException;
3334
import org.apache.cassandra.config.DatabaseDescriptor;
3435
import org.apache.cassandra.config.DataStorageSpec;
@@ -156,7 +157,11 @@ public void testAggregationQueryShouldNotTimeoutWhenItExceedesReadTimeout() thro
156157
logger.info("Running aggregate, multi-page query");
157158

158159
long queryStartTime = System.nanoTime();
159-
List<Row> result = executeNet("SELECT a, count(c) FROM %s group by a").all();
160+
// Use a custom read timeout that matches the aggregation timeout
161+
// This ensures the driver won't timeout before the server completes the aggregation
162+
SimpleStatement statement = new SimpleStatement(formatQuery("SELECT a, count(c) FROM %s group by a"));
163+
statement.setReadTimeoutMillis(120000); // Match the server-side aggregation timeout
164+
List<Row> result = sessionNet().execute(statement).all();
160165
long queryDuration = System.nanoTime() - queryStartTime;
161166

162167
assertEquals("Should return 4 groups", 4, result.size());
@@ -268,4 +273,4 @@ public static void delayPageRead()
268273
Uninterruptibles.sleepUninterruptibly(delay, MILLISECONDS);
269274
logger.info("Resuming page read");
270275
}
271-
}
276+
}

0 commit comments

Comments
 (0)