浏览代码

HDFS-17605. Reduce memory overhead of TestBPOfferService (#6996)

Stephen O'Donnell 11 月之前
父节点
当前提交
df08e0de41

+ 3 - 2
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestBPOfferService.java

@@ -144,8 +144,9 @@ public class TestBPOfferService {
     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");