use of org.apache.drill.test.LogFixture in project drill by axbaretto.
the class TestHashAggrSpill method testSpill.
/**
* A template for Hash Aggr spilling tests
*
* @throws Exception
*/
private void testSpill(long maxMem, long numPartitions, long minBatches, int maxParallel, boolean fallback, boolean predict, String sql, long expectedRows, int cycle, int fromPart, int toPart) throws Exception {
LogFixture.LogFixtureBuilder logBuilder = LogFixture.builder().toConsole().logger("org.apache.drill", Level.WARN);
ClusterFixtureBuilder builder = ClusterFixture.builder(dirTestWatcher).sessionOption(ExecConstants.HASHAGG_MAX_MEMORY_KEY, maxMem).sessionOption(ExecConstants.HASHAGG_NUM_PARTITIONS_KEY, numPartitions).sessionOption(ExecConstants.HASHAGG_MIN_BATCHES_PER_PARTITION_KEY, minBatches).configProperty(ExecConstants.SYS_STORE_PROVIDER_LOCAL_ENABLE_WRITE, false).sessionOption(PlannerSettings.FORCE_2PHASE_AGGR_KEY, true).sessionOption(ExecConstants.HASHAGG_FALLBACK_ENABLED_KEY, fallback).sessionOption(ExecConstants.HASHAGG_USE_MEMORY_PREDICTION_KEY, predict).maxParallelization(maxParallel).saveProfiles();
String sqlStr = // if null then use this default query
sql != null ? // if null then use this default query
sql : "SELECT empid_s17, dept_i, branch_i, AVG(salary_i) FROM `mock`.`employee_1200K` GROUP BY empid_s17, dept_i, branch_i";
try (LogFixture logs = logBuilder.build();
ClusterFixture cluster = builder.build();
ClientFixture client = cluster.clientFixture()) {
runAndDump(client, sqlStr, expectedRows, cycle, fromPart, toPart);
}
}
use of org.apache.drill.test.LogFixture in project drill by axbaretto.
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 axbaretto.
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();
}
}
use of org.apache.drill.test.LogFixture in project drill by axbaretto.
the class TestLenientAllocation method testLenient.
/**
* Use a test-time hack to force the allocator to be lenient,
* regardless of whether we are in debug mode or not.
*/
@Test
public void testLenient() {
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);
((Accountant) allocator).forceLenient();
// Allocate most of the available memory
DrillBuf buf1 = allocator.buffer(64 * 1024);
// Oops, we did our math wrong; allocate too large a buffer.
DrillBuf buf2 = allocator.buffer(128 * 1024);
assertEquals(192 * 1024, allocator.getAllocatedMemory());
// We keep making mistakes.
DrillBuf buf3 = allocator.buffer(32 * 1024);
// Right up to the hard limit
DrillBuf buf4 = allocator.buffer(32 * 1024);
assertEquals(256 * 1024, allocator.getAllocatedMemory());
try {
allocator.buffer(8);
fail();
} catch (OutOfMemoryException e) {
// Expected
}
// Recover from our excesses
buf2.close();
buf3.close();
buf4.close();
assertEquals(64 * 1024, allocator.getAllocatedMemory());
// We're back in the good graces of the allocator,
// can allocate more.
DrillBuf buf5 = allocator.buffer(8);
// Clean up
buf1.close();
buf5.close();
allocator.close();
}
}
use of org.apache.drill.test.LogFixture in project drill by apache.
the class TestLenientAllocation method testLenient.
/**
* Use a test-time hack to force the allocator to be lenient,
* regardless of whether we are in debug mode or not.
*/
@Test
public void testLenient() {
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);
((Accountant) allocator).forceLenient();
// Allocate most of the available memory
DrillBuf buf1 = allocator.buffer(64 * 1024);
// Oops, we did our math wrong; allocate too large a buffer.
DrillBuf buf2 = allocator.buffer(128 * 1024);
assertEquals(192 * 1024, allocator.getAllocatedMemory());
// We keep making mistakes.
DrillBuf buf3 = allocator.buffer(32 * 1024);
// Right up to the hard limit
DrillBuf buf4 = allocator.buffer(32 * 1024);
assertEquals(256 * 1024, allocator.getAllocatedMemory());
try {
allocator.buffer(8);
fail();
} catch (OutOfMemoryException e) {
// Expected
}
// Recover from our excesses
buf2.close();
buf3.close();
buf4.close();
assertEquals(64 * 1024, allocator.getAllocatedMemory());
// We're back in the good graces of the allocator,
// can allocate more.
DrillBuf buf5 = allocator.buffer(8);
// Clean up
buf1.close();
buf5.close();
allocator.close();
}
}
Aggregations