From df08e0de41aa9cd85c50c0f293ae6d72b997582a Mon Sep 17 00:00:00 2001 From: Stephen O'Donnell Date: Mon, 19 Aug 2024 11:35:11 +0100 Subject: [PATCH] HDFS-17605. Reduce memory overhead of TestBPOfferService (#6996) --- .../hadoop/hdfs/server/datanode/TestBPOfferService.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestBPOfferService.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestBPOfferService.java index fd1b5609b1..5de131e6e4 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestBPOfferService.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestBPOfferService.java @@ -144,8 +144,9 @@ public void setupMocks() throws Exception { mockNN2 = setupNNMock(1); // Set up a mock DN with the bare-bones configuration - // objects, etc. - mockDn = Mockito.mock(DataNode.class); + // objects, etc. Set as stubOnly to save memory and avoid Mockito holding + // references to each invocation. This can cause OOM in some runs. + mockDn = Mockito.mock(DataNode.class, Mockito.withSettings().stubOnly()); Mockito.doReturn(true).when(mockDn).shouldRun(); Configuration conf = new Configuration(); File dnDataDir = new File(new File(TEST_BUILD_DATA, "dfs"), "data");