Skip to content

Commit be5950f

Browse files
sodonnelsteveloughran
authored andcommitted
CDPD-73234: HDFS-17605. Reduce memory overhead of TestBPOfferService (apache#6996)
1 parent bacc4b6 commit be5950f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,9 @@ public void setupMocks() throws Exception {
143143
mockNN2 = setupNNMock(1);
144144

145145
// Set up a mock DN with the bare-bones configuration
146-
// objects, etc.
147-
mockDn = Mockito.mock(DataNode.class);
146+
// objects, etc. Set as stubOnly to save memory and avoid Mockito holding
147+
// references to each invocation. This can cause OOM in some runs.
148+
mockDn = Mockito.mock(DataNode.class, Mockito.withSettings().stubOnly());
148149
Mockito.doReturn(true).when(mockDn).shouldRun();
149150
Configuration conf = new Configuration();
150151
File dnDataDir = new File(new File(TEST_BUILD_DATA, "dfs"), "data");

0 commit comments

Comments
 (0)