This is an automated email from the ASF dual-hosted git repository. pnowojski pushed a commit to branch release-1.18 in repository https://gitbox.apache.org/repos/asf/flink.git
The following commit(s) were added to refs/heads/release-1.18 by this push: new 2b6c656ff31 [FLINK-27756] Refactor Async Sink send gauge test 2b6c656ff31 is described below commit 2b6c656ff31b6d84ca9b9cea4e10e96a36ceda20 Author: Ahmed Hamdy <ahmed.ha...@ververica.com> AuthorDate: Mon Jan 1 15:41:27 2024 +0000 [FLINK-27756] Refactor Async Sink send gauge test --- .../base/sink/writer/AsyncSinkWriterTest.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/flink-connectors/flink-connector-base/src/test/java/org/apache/flink/connector/base/sink/writer/AsyncSinkWriterTest.java b/flink-connectors/flink-connector-base/src/test/java/org/apache/flink/connector/base/sink/writer/AsyncSinkWriterTest.java index ac4d9447e15..774d2436143 100644 --- a/flink-connectors/flink-connector-base/src/test/java/org/apache/flink/connector/base/sink/writer/AsyncSinkWriterTest.java +++ b/flink-connectors/flink-connector-base/src/test/java/org/apache/flink/connector/base/sink/writer/AsyncSinkWriterTest.java @@ -112,16 +112,20 @@ public class AsyncSinkWriterTest { AsyncSinkWriterImpl sink = new AsyncSinkWriterImplBuilder() .context(sinkInitContext) - .maxBatchSize(4) - .delay(100) + .maxBatchSize(2) + .delay(50) .build(); - for (int i = 0; i < 4; i++) { - sink.write(String.valueOf(i)); - } + sink.write(String.valueOf(1)); + // introduce artificial delay, shouldn't be calculated in send time + Thread.sleep(50); + long sendStartTimestamp = System.currentTimeMillis(); sink.flush(true); + long sendCompleteTimestamp = System.currentTimeMillis(); + + assertThat(sinkInitContext.getCurrentSendTimeGauge().get().getValue()) + .isGreaterThanOrEqualTo(50); assertThat(sinkInitContext.getCurrentSendTimeGauge().get().getValue()) - .isGreaterThanOrEqualTo(99); - assertThat(sinkInitContext.getCurrentSendTimeGauge().get().getValue()).isLessThan(120); + .isLessThanOrEqualTo(sendCompleteTimestamp - sendStartTimestamp); } @Test