From 7e909ff2ee9e025796d357b13cf8877b01f6ca44 Mon Sep 17 00:00:00 2001 From: Roman Khachatryan Date: Thu, 24 Mar 2022 10:47:26 +0100 Subject: [PATCH] [FLINK-26809][tests] Assert histogram state after stopping the uploader There is a race condition in ChangelogStorageMetricsTest.testAttemptsPerUpload: - the assertion is made as soon as upload (future) is completed - the histogram is updated after completing the upload (on success) Moving assertion out of try/close block solves the problem. --- .../flink/changelog/fs/ChangelogStorageMetricsTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flink-dstl/flink-dstl-dfs/src/test/java/org/apache/flink/changelog/fs/ChangelogStorageMetricsTest.java b/flink-dstl/flink-dstl-dfs/src/test/java/org/apache/flink/changelog/fs/ChangelogStorageMetricsTest.java index 24280c8e8b8b2..f4a348b4b6283 100644 --- a/flink-dstl/flink-dstl-dfs/src/test/java/org/apache/flink/changelog/fs/ChangelogStorageMetricsTest.java +++ b/flink-dstl/flink-dstl-dfs/src/test/java/org/apache/flink/changelog/fs/ChangelogStorageMetricsTest.java @@ -204,12 +204,12 @@ void testAttemptsPerUpload() throws Exception { writer.append(0, new byte[] {0, 1, 2, 3}); writer.persist(from).get(); } - HistogramStatistics histogram = metrics.getAttemptsPerUpload().getStatistics(); - assertThat(histogram.getMin()).isEqualTo(maxAttempts); - assertThat(histogram.getMax()).isEqualTo(maxAttempts); } finally { storage.close(); } + HistogramStatistics histogram = metrics.getAttemptsPerUpload().getStatistics(); + assertThat(histogram.getMin()).isEqualTo(maxAttempts); + assertThat(histogram.getMax()).isEqualTo(maxAttempts); } @Test