From 96dd426229968b715e5c117bf0b35474ee0f05ec Mon Sep 17 00:00:00 2001 From: qinyuren <1476659627@qq.com> Date: Wed, 19 Jan 2022 12:42:33 +0800 Subject: [PATCH] HDFS-16426. Fix nextBlockReportTime when trigger full block report force (#3887) (cherry picked from commit fcb1076699bd1360c109c18df0261897afea05ba) --- .../datanode/TestBpServiceActorScheduler.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestBpServiceActorScheduler.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestBpServiceActorScheduler.java index 438be89be92..02b3f03699b 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestBpServiceActorScheduler.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestBpServiceActorScheduler.java @@ -136,6 +136,23 @@ public class TestBpServiceActorScheduler { } } + /** + * force trigger full block report multi times, the next block report + * must be scheduled in the range (now + BLOCK_REPORT_INTERVAL_SEC). + */ + @Test + public void testScheduleNextBlockReport4() { + for (final long now : getTimestamps()) { + Scheduler scheduler = makeMockScheduler(now); + for (int i = 0; i < getTimestamps().size(); ++i) { + scheduler.forceFullBlockReportNow(); + scheduler.scheduleNextBlockReport(); + } + assertTrue(scheduler.getNextBlockReportTime() - now >= 0); + assertTrue(scheduler.getNextBlockReportTime() - now <= BLOCK_REPORT_INTERVAL_MS); + } + } + @Test public void testScheduleHeartbeat() { for (final long now : getTimestamps()) {