Skip to content

Commit 9114fed

Browse files
author
S O'Donnell
committed
HDFS-17605. Reduce memory overhead of TestBPOfferService
1 parent 55a5769 commit 9114fed

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
@@ -144,8 +144,9 @@ public void setupMocks() throws Exception {
144144
mockNN2 = setupNNMock(1);
145145

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

0 commit comments

Comments
 (0)