This is an automated email from the ASF dual-hosted git repository.

ycai pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/cassandra-analytics.git


The following commit(s) were added to refs/heads/trunk by this push:
     new bbfca46  CASSANDRA-19198: Flaky test in SSTableInputStreamTests
bbfca46 is described below

commit bbfca46129992e83055ba9b0b4f836871eef0990
Author: Yifan Cai <[email protected]>
AuthorDate: Tue Dec 12 23:45:41 2023 +0800

    CASSANDRA-19198: Flaky test in SSTableInputStreamTests
    
    Patch by Yifan Cai; Reviewed by Francisco Guerrero for CASSANDRA-19198
---
 .../apache/cassandra/spark/utils/SSTableInputStreamTests.java | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git 
a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/utils/SSTableInputStreamTests.java
 
b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/utils/SSTableInputStreamTests.java
index 0f2551c..8034a0a 100644
--- 
a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/utils/SSTableInputStreamTests.java
+++ 
b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/utils/SSTableInputStreamTests.java
@@ -220,20 +220,21 @@ public class SSTableInputStreamTests
                 });
             }
         }, timeout);
+        SSTableInputStream<SSTable> inputStream = new 
SSTableInputStream<>(source, STATS);
         try
         {
-            readStreamFully(new SSTableInputStream<>(source, STATS));
+            readStreamFully(inputStream);
             fail("Should not reach here, should throw TimeoutException");
         }
         catch (IOException exception)
         {
             assertTrue(exception.getCause() instanceof TimeoutException);
         }
-        Duration duration = Duration.ofNanos(System.nanoTime() - startTime);
-        Duration maxAcceptable = 
timeout.plus(Duration.ofMillis(sleepTimeInMillis));
-        assertTrue(duration.minus(maxAcceptable).toMillis() < 100,
+        long readAndTimeoutTotal = 
TimeUnit.NANOSECONDS.toMillis(inputStream.timeBlockedNanos()) + 
timeout.toMillis();
+        Duration clientTimeoutTotal = Duration.ofNanos(System.nanoTime() - 
startTime);
+        assertTrue(clientTimeoutTotal.toMillis() >= readAndTimeoutTotal,
                    "Timeout didn't account for activity time. "
-                   + "Took " + duration.toMillis() + "ms should have taken at 
most " + maxAcceptable.toMillis() + "ms");
+                   + "Took " + clientTimeoutTotal.toMillis() + "ms should have 
taken at least " + readAndTimeoutTotal + "ms");
     }
 
     @Test


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to