Skip to content

Commit d7165f2

Browse files
committed
add logging
1 parent a7ff308 commit d7165f2

File tree

1 file changed

+37
-4
lines changed

1 file changed

+37
-4
lines changed

integration-tests/src/test/java/com/datastax/oss/driver/core/cql/PreparedStatementCachingIT.java

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@
7272
@Category(IsolatedTests.class)
7373
public class PreparedStatementCachingIT {
7474

75+
private static final Logger LOG = LoggerFactory.getLogger(PreparedStatementCachingIT.class);
76+
7577
private CustomCcmRule ccmRule = CustomCcmRule.builder().build();
7678

7779
private SessionRule<CqlSession> sessionRule =
@@ -266,15 +268,46 @@ private void invalidationTestInner(
266268
// alter test_type_caching_2 to trigger cache invalidation and above events
267269
session.execute("ALTER TYPE test_type_caching_2 add i blob");
268270

271+
// Give a small delay to allow the schema change to propagate before checking agreement
272+
Uninterruptibles.sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
269273
session.checkSchemaAgreement();
270274

271275
// wait for latches and fail if they don't reach zero before timeout
272-
assertThat(
273-
Uninterruptibles.awaitUninterruptibly(
274-
preparedStmtCacheRemoveLatch, 120, TimeUnit.SECONDS))
276+
// Use longer timeout for cache removal as it depends on complex event chain
277+
boolean cacheRemovalSuccess =
278+
Uninterruptibles.awaitUninterruptibly(
279+
preparedStmtCacheRemoveLatch, 180, TimeUnit.SECONDS);
280+
boolean typeChangeSuccess =
281+
Uninterruptibles.awaitUninterruptibly(typeChangeEventLatch, 60, TimeUnit.SECONDS);
282+
283+
// Provide detailed diagnostics if either latch fails
284+
if (!cacheRemovalSuccess || !typeChangeSuccess) {
285+
String diagnostics =
286+
String.format(
287+
"Test failure diagnostics:\n"
288+
+ " - Cache removal latch success: %s (count: %d)\n"
289+
+ " - Type change latch success: %s (count: %d)\n"
290+
+ " - Current cache size: %d\n"
291+
+ " - Changed types detected: %s\n"
292+
+ " - Removed query IDs: %s\n"
293+
+ " - Type change errors: %s\n"
294+
+ " - Removal event errors: %s",
295+
cacheRemovalSuccess,
296+
preparedStmtCacheRemoveLatch.getCount(),
297+
typeChangeSuccess,
298+
typeChangeEventLatch.getCount(),
299+
getPreparedCacheSize(session),
300+
changedTypes.keySet(),
301+
removedQueryIds.get(),
302+
typeChangeEventError.get(),
303+
removedQueryEventError.get());
304+
LOG.error("Prepared statement cache invalidation test failed: {}", diagnostics);
305+
}
306+
307+
assertThat(cacheRemovalSuccess)
275308
.withFailMessage("preparedStmtCacheRemoveLatch did not trigger before timeout")
276309
.isTrue();
277-
assertThat(Uninterruptibles.awaitUninterruptibly(typeChangeEventLatch, 20, TimeUnit.SECONDS))
310+
assertThat(typeChangeSuccess)
278311
.withFailMessage("typeChangeEventLatch did not trigger before timeout")
279312
.isTrue();
280313

0 commit comments

Comments
 (0)