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

pnowojski pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink.git

commit 97727afa449ae1a576ad78dbb98aa42625545785
Author: Anton Kalashnikov <[email protected]>
AuthorDate: Wed Aug 4 14:01:24 2021 +0200

    [FLINK-23590][streaming] Replace System.currentTimeMillis with 
SystemClock.relativeTimeMillis() in the test
    Previously test was using System.currentTimeMillis() while production code 
effectively was using System.nanoTime(), which was causing inconsistencies 
between readings.
---
 .../org/apache/flink/streaming/runtime/tasks/StreamTaskTest.java    | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git 
a/flink-streaming-java/src/test/java/org/apache/flink/streaming/runtime/tasks/StreamTaskTest.java
 
b/flink-streaming-java/src/test/java/org/apache/flink/streaming/runtime/tasks/StreamTaskTest.java
index 6fd5114..efb1dea 100644
--- 
a/flink-streaming-java/src/test/java/org/apache/flink/streaming/runtime/tasks/StreamTaskTest.java
+++ 
b/flink-streaming-java/src/test/java/org/apache/flink/streaming/runtime/tasks/StreamTaskTest.java
@@ -1560,12 +1560,14 @@ public class StreamTaskTest extends TestLogger {
                     waitingThread::start,
                     "Start WaitingThread after Task starts processing input.");
 
-            long startTs = System.currentTimeMillis();
+            SystemClock clock = SystemClock.getInstance();
+
+            long startTs = clock.relativeTimeMillis();
             throughputCalculator.calculateThroughput();
             throughputCalculator.incomingDataSize(incomingDataSize);
             task.invoke();
             long resultThroughput = throughputCalculator.calculateThroughput();
-            long totalDuration = System.currentTimeMillis() - startTs;
+            long totalDuration = clock.relativeTimeMillis() - startTs;
 
             assertThat(
                     resultThroughput,

Reply via email to