use of org.apache.drill.test.LogFixture in project drill by apache.
the class TestLenientAllocation method testLenientLimit.
@Test
public void testLenientLimit() {
LogFixtureBuilder logBuilder = LogFixture.builder().logger(Accountant.class, Level.WARN);
try (LogFixture logFixture = logBuilder.build()) {
// Test can't run without assertions
assertTrue(AssertionUtil.isAssertionsEnabled());
// Create a child allocator
BufferAllocator allocator = fixture.allocator().newChildAllocator("test", 10 * ONE_MEG, 128 * ONE_MEG);
((Accountant) allocator).forceLenient();
// Allocate most of the available memory
DrillBuf buf1 = allocator.buffer(64 * ONE_MEG);
// Oops, we did our math wrong; allocate too large a buffer.
DrillBuf buf2 = allocator.buffer(128 * ONE_MEG);
try {
allocator.buffer(64 * ONE_MEG);
fail();
} catch (OutOfMemoryException e) {
// Expected
}
// Clean up
buf1.close();
buf2.close();
allocator.close();
}
}
use of org.apache.drill.test.LogFixture in project drill by apache.
the class TestLenientAllocation method testStrict.
/**
* Test that the allocator is normally strict in debug mode.
*/
@Test
public void testStrict() {
LogFixtureBuilder logBuilder = LogFixture.builder().logger(Accountant.class, Level.WARN);
try (LogFixture logFixture = logBuilder.build()) {
// Test can't run without assertions
assertTrue(AssertionUtil.isAssertionsEnabled());
// Create a child allocator
BufferAllocator allocator = fixture.allocator().newChildAllocator("test", 10 * 1024, 128 * 1024);
// Allocate most of the available memory
DrillBuf buf1 = allocator.buffer(64 * 1024);
try {
allocator.buffer(128 * 1024);
fail();
} catch (OutOfMemoryException e) {
// Expected
}
// Clean up
buf1.close();
allocator.close();
}
}
Aggregations