HDDS-2168. TestOzoneManagerDoubleBufferWithOMResponse sometimes fails with out of memory error (#1509)

This commit is contained in:
Vivek Ratnavel Subramanian 2019-09-24 16:28:25 -07:00 committed by Bharat Viswanadham
parent 6917754ba7
commit a3463812ef

View File

@ -84,8 +84,9 @@ public class TestOzoneManagerDoubleBufferWithOMResponse {
public TemporaryFolder folder = new TemporaryFolder();
@Before
public void setup() throws IOException {
ozoneManager = Mockito.mock(OzoneManager.class);
public void setup() throws IOException {
ozoneManager = Mockito.mock(OzoneManager.class,
Mockito.withSettings().stubOnly());
omMetrics = OMMetrics.create();
OzoneConfiguration ozoneConfiguration = new OzoneConfiguration();
ozoneConfiguration.set(OMConfigKeys.OZONE_OM_DB_DIRS,
@ -125,7 +126,7 @@ public void testDoubleBuffer() throws Exception {
testDoubleBuffer(1, 10);
testDoubleBuffer(10, 100);
testDoubleBuffer(100, 100);
testDoubleBuffer(1000, 100);
testDoubleBuffer(1000, 500);
}
/**
@ -373,14 +374,15 @@ public void testDoubleBuffer(int iterations, int bucketCount)
setup();
for (int i = 0; i < iterations; i++) {
Daemon d1 = new Daemon(() ->
doTransactions(RandomStringUtils.randomAlphabetic(5), bucketCount));
doTransactions(RandomStringUtils.randomAlphabetic(5),
bucketCount));
d1.start();
}
// We are doing +1 for volume transaction.
long expectedTransactions = (bucketCount + 1) * iterations;
GenericTestUtils.waitFor(() -> lastAppliedIndex == expectedTransactions,
100, 120000);
100, 500000);
Assert.assertEquals(expectedTransactions,
doubleBuffer.getFlushedTransactionCount()
@ -428,15 +430,6 @@ public void doTransactions(String volumeName, int bucketCount) {
for (int i=0; i< bucketCount; i++) {
createBucket(volumeName, UUID.randomUUID().toString(),
trxId.incrementAndGet());
// For every 100 buckets creation adding 100ms delay
if (i % 100 == 0) {
try {
Thread.sleep(100);
} catch (Exception ex) {
}
}
}
}