use of org.apache.drill.test.OperatorFixture in project drill by apache.
the class TestQueryMemoryAlloc method testCustomFloor.
@Test
public void testCustomFloor() throws Exception {
OperatorFixture.Builder builder = OperatorFixture.builder(dirTestWatcher);
builder.systemOption(ExecConstants.PERCENT_MEMORY_PER_QUERY_KEY, 0.05);
builder.systemOption(ExecConstants.MAX_QUERY_MEMORY_PER_NODE_KEY, 2 * ONE_GB);
try (OperatorFixture fixture = builder.build()) {
final OptionManager optionManager = fixture.getOptionManager();
optionManager.setLocalOption(ExecConstants.PERCENT_MEMORY_PER_QUERY_KEY, 0.05);
optionManager.setLocalOption(ExecConstants.MAX_QUERY_MEMORY_PER_NODE_KEY, 2 * ONE_GB);
// Out-of-box memory, use query memory per node as floor.
long mem = MemoryAllocationUtilities.computeQueryMemory(fixture.config(), optionManager, 8 * ONE_GB);
assertEquals(2 * ONE_GB, mem);
// Up to 60 GB, query memory dominates.
mem = MemoryAllocationUtilities.computeQueryMemory(fixture.config(), optionManager, 60 * ONE_GB);
assertEquals(3 * ONE_GB, mem);
// After 60 GB, the percent dominates
mem = MemoryAllocationUtilities.computeQueryMemory(fixture.config(), optionManager, 100 * ONE_GB);
assertEquals(5 * ONE_GB, mem);
}
}
use of org.apache.drill.test.OperatorFixture in project drill by apache.
the class TestQueryMemoryAlloc method testOpMemory.
/**
* Test with default options, various memory configs.
* Since we can't change the actual CPUs on this node, use an
* option to specify the number (rather than the usual 70% of
* actual cores.)
*
* @throws Exception
*/
@Test
public void testOpMemory() throws Exception {
OperatorFixture.Builder builder = OperatorFixture.builder(dirTestWatcher);
builder.systemOption(ExecConstants.CPU_LOAD_AVERAGE_KEY, 0.7);
builder.systemOption(ExecConstants.MAX_WIDTH_PER_NODE_KEY, 10);
builder.systemOption(ExecConstants.MIN_MEMORY_PER_BUFFERED_OP_KEY, 40 * ONE_MB);
try (OperatorFixture fixture = builder.build()) {
final OptionManager optionManager = fixture.getOptionManager();
optionManager.setLocalOption(ExecConstants.CPU_LOAD_AVERAGE_KEY, 0.7);
optionManager.setLocalOption(ExecConstants.MAX_WIDTH_PER_NODE_KEY, 10);
optionManager.setLocalOption(ExecConstants.MIN_MEMORY_PER_BUFFERED_OP_KEY, 40 * ONE_MB);
// Enough memory to go above configured minimum.
long opMinMem = MemoryAllocationUtilities.computeOperatorMemory(optionManager, 4 * ONE_GB, 2);
assertEquals(4 * ONE_GB / 10 / 2, opMinMem);
// Too little memory per operator. Use configured minimum.
opMinMem = MemoryAllocationUtilities.computeOperatorMemory(optionManager, ONE_GB, 100);
assertEquals(40 * ONE_MB, opMinMem);
}
}
use of org.apache.drill.test.OperatorFixture in project drill by apache.
the class TestSortEmitOutcome method testSpillWithNoEmitOutcome.
/**
* Verifies successful spilling in absence of EMIT outcome
* @throws Exception
*/
@Test
public void testSpillWithNoEmitOutcome() throws Exception {
final OperatorFixture.Builder builder = OperatorFixture.builder(dirTestWatcher);
// Configuration that forces Sort to spill after buffering 2 incoming batches with data
builder.configBuilder().put(ExecConstants.EXTERNAL_SORT_BATCH_LIMIT, 2);
final OperatorFixture fixture_local = builder.build();
final RowSet.SingleRowSet local_nonEmptyInputRowSet1 = fixture_local.rowSetBuilder(inputSchema).addRow(3, 30, "item3").addRow(2, 20, "item2").build();
final RowSet.SingleRowSet local_nonEmptyInputRowSet2 = fixture_local.rowSetBuilder(inputSchema).addRow(1, 10, "item1").build();
final RowSet.SingleRowSet local_nonEmptyInputRowSet3 = fixture_local.rowSetBuilder(inputSchema).addRow(4, 40, "item4").build();
inputContainer.add(local_nonEmptyInputRowSet1.container());
inputContainer.add(local_nonEmptyInputRowSet2.container());
inputContainer.add(local_nonEmptyInputRowSet3.container());
inputOutcomes.add(OK_NEW_SCHEMA);
inputOutcomes.add(OK);
inputOutcomes.add(OK);
final PhysicalOperator mockPopConfig_local = new MockStorePOP(null);
final OperatorContext opContext_local = fixture_local.getFragmentContext().newOperatorContext(mockPopConfig_local);
final MockRecordBatch mockInputBatch = new MockRecordBatch(fixture_local.getFragmentContext(), opContext_local, inputContainer, inputOutcomes, local_nonEmptyInputRowSet1.container().getSchema());
final ExternalSortBatch sortBatch_local = new ExternalSortBatch(sortPopConfig, fixture_local.getFragmentContext(), mockInputBatch);
assertTrue(sortBatch_local.next() == OK_NEW_SCHEMA);
assertTrue(sortBatch_local.next() == OK_NEW_SCHEMA);
assertTrue(sortBatch_local.getRecordCount() == 4);
assertTrue(sortBatch_local.getSchema().getSelectionVectorMode() == BatchSchema.SelectionVectorMode.NONE);
assertTrue(sortBatch_local.next() == NONE);
// Release memory for row sets
local_nonEmptyInputRowSet1.clear();
local_nonEmptyInputRowSet2.clear();
local_nonEmptyInputRowSet3.clear();
sortBatch_local.close();
fixture_local.close();
}
use of org.apache.drill.test.OperatorFixture in project drill by apache.
the class PerformanceTool method main.
public static void main(String[] args) {
try (OperatorFixture fixture = OperatorFixture.standardFixture(null)) {
for (int i = 0; i < 2; i++) {
logger.info((i == 0) ? "Warmup" : "Test run");
new RequiredVectorTester(fixture).runTest();
new RequiredWriterTester(fixture).runTest();
new NullableVectorTester(fixture).runTest();
new NullableWriterTester(fixture).runTest();
new RepeatedVectorTester(fixture).runTest();
new ArrayWriterTester(fixture).runTest();
}
} catch (Exception e) {
// TODO Auto-generated catch block
logger.error("Exception", e);
}
}
use of org.apache.drill.test.OperatorFixture in project drill by apache.
the class TestClassicLocator method testBootstrap.
@Test
public void testBootstrap() throws Exception {
try (OperatorFixture fixture = OperatorFixture.standardFixture(dirTestWatcher)) {
PluginRegistryContextFixture context = new PluginRegistryContextFixture(fixture);
ConnectorLocator locator = new ClassicConnectorLocator(context);
locator.init();
StoragePlugins plugins = locator.bootstrapPlugins();
// Sanity test. Change this if the bootstrap file changes.
// No need to test contents; here we assume serialization works.
// See FormatPluginSerDeTest
assertNotNull(plugins.getConfig("dfs"));
assertNotNull(plugins.getConfig("s3"));
assertNotNull(plugins.getConfig(StoragePluginTestUtils.CP_PLUGIN_NAME));
// No-op
locator.close();
}
}
Aggregations