You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by co...@apache.org on 2026/05/20 22:12:10 UTC
(tinkerpop) 01/02: Fix flaky transaction integration tests
This is an automated email from the ASF dual-hosted git repository.
Cole-Greer pushed a commit to branch fixFlakyTests
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git
commit 215b707f2246ff7033d4ad0f048a77f32a49be43
Author: Cole Greer <co...@colegreer.ca>
AuthorDate: Wed May 20 14:51:50 2026 -0700
Fix flaky transaction integration tests
shouldTrackTransactionCountAccurately was racing because commitTx()
and rollbackTx() returned without consuming the HTTP response. With
chunked transfer encoding, the client can receive response headers
before the server completes transactionManager.destroy(). Wrapping
in try-with-resources ensures the full response is read, guaranteeing
server-side processing is complete before asserting the count.
shouldTimeoutIdleTransactionWithNoOperations used a 1ms timeout,
which could expire during the beginTx() HTTP round-trip itself,
causing getFirstHeader(TRANSACTION_ID) to return null and NPE.
Increased to 500ms — still well below the 1000ms sleep that
validates timeout behavior.
---
.../server/GremlinServerHttpTransactionIntegrateTest.java | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerHttpTransactionIntegrateTest.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerHttpTransactionIntegrateTest.java
index dd61bfa1cc..ce21743c50 100644
--- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerHttpTransactionIntegrateTest.java
+++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerHttpTransactionIntegrateTest.java
@@ -96,7 +96,7 @@ public class GremlinServerHttpTransactionIntegrateTest extends AbstractGremlinSe
settings.transactionTimeout = 1000;
break;
case "shouldTimeoutIdleTransactionWithNoOperations":
- settings.transactionTimeout = 1;
+ settings.transactionTimeout = 500;
break;
case "shouldTimeoutAndRejectLateCommit":
case "shouldTrackTransactionCountAccurately":
@@ -333,7 +333,7 @@ public class GremlinServerHttpTransactionIntegrateTest extends AbstractGremlinSe
public void shouldTimeoutIdleTransactionWithNoOperations() throws Exception {
final String txId = beginTx(client, GTX);
- // wait for the transaction to timeout (configured at 1ms)
+ // wait for the transaction to timeout (configured at 500ms)
Thread.sleep(1000);
// the transaction should be gone
@@ -382,12 +382,16 @@ public class GremlinServerHttpTransactionIntegrateTest extends AbstractGremlinSe
assertEquals(3, txManager.getActiveTransactionCount());
- // commit one
- commitTx(client, txId1, GTX);
+ // commit one - must close response to ensure server-side processing completes
+ try (final CloseableHttpResponse r = commitTx(client, txId1, GTX)) {
+ assertEquals(200, r.getStatusLine().getStatusCode());
+ }
assertEquals(2, txManager.getActiveTransactionCount());
// rollback one
- rollbackTx(client, txId2, GTX);
+ try (final CloseableHttpResponse r = rollbackTx(client, txId2, GTX)) {
+ assertEquals(200, r.getStatusLine().getStatusCode());
+ }
assertEquals(1, txManager.getActiveTransactionCount());
// let the third one timeout