use of org.apache.drill.common.exceptions.DrillException in project drill by axbaretto.
the class TestSpnegoConfig method testSpnegoConfigOnlyPrincipal.
/**
* Invalid configuration with principal only and missing keytab
* @throws Exception
*/
@Test
public void testSpnegoConfigOnlyPrincipal() throws Exception {
try {
final DrillConfig newConfig = new DrillConfig(DrillConfig.create().withValue(ExecConstants.USER_AUTHENTICATION_ENABLED, ConfigValueFactory.fromAnyRef(true)).withValue(ExecConstants.AUTHENTICATION_MECHANISMS, ConfigValueFactory.fromIterable(Lists.newArrayList("plain"))).withValue(ExecConstants.HTTP_SPNEGO_PRINCIPAL, ConfigValueFactory.fromAnyRef(spnegoHelper.SERVER_PRINCIPAL)).withValue(ExecConstants.USER_AUTHENTICATOR_IMPL, ConfigValueFactory.fromAnyRef(UserAuthenticatorTestImpl.TYPE)));
final SpnegoConfig spnegoConfig = new SpnegoConfig(newConfig);
spnegoConfig.validateSpnegoConfig();
fail();
} catch (Exception ex) {
assertTrue(ex instanceof DrillException);
}
}
use of org.apache.drill.common.exceptions.DrillException in project drill by apache.
the class TestSSLConfig method testInvalidHadoopKeystore.
@Test
public void testInvalidHadoopKeystore() throws Exception {
Configuration hadoopConfig = new Configuration();
String hadoopSSLFileProp = MessageFormat.format(HADOOP_SSL_CONF_TPL_KEY, SSLConfig.Mode.SERVER.toString().toLowerCase());
hadoopConfig.set(hadoopSSLFileProp, "ssl-server-invalid.xml");
ConfigBuilder config = new ConfigBuilder();
config.put(ExecConstants.USER_SSL_ENABLED, true);
config.put(ExecConstants.SSL_USE_HADOOP_CONF, true);
SSLConfig sslv;
try {
sslv = new SSLConfigBuilder().config(config.build()).mode(SSLConfig.Mode.SERVER).initializeSSLContext(false).validateKeyStore(true).hadoopConfig(hadoopConfig).build();
fail();
} catch (Exception e) {
assertTrue(e instanceof DrillException);
}
}
use of org.apache.drill.common.exceptions.DrillException in project drill by apache.
the class TestSSLConfig method testMissingKeystorePassword.
@Test
public void testMissingKeystorePassword() throws Exception {
ConfigBuilder config = new ConfigBuilder();
config.put(ExecConstants.HTTP_KEYSTORE_PATH, "/root");
config.put(ExecConstants.HTTP_KEYSTORE_PASSWORD, "");
config.put(ExecConstants.SSL_USE_HADOOP_CONF, false);
config.put(ExecConstants.USER_SSL_ENABLED, true);
try {
SSLConfig sslv = new SSLConfigBuilder().config(config.build()).mode(SSLConfig.Mode.SERVER).initializeSSLContext(false).validateKeyStore(true).build();
fail();
// Expected
} catch (Exception e) {
assertTrue(e instanceof DrillException);
}
}
use of org.apache.drill.common.exceptions.DrillException in project drill by apache.
the class TestUnnestCorrectness method testUnnest.
// test unnest for various input conditions optionally invoking kill. if the kill or killBatch
// parameter is greater than 0 then the record batch is sent a kill after that many batches have been processed
private <T> void testUnnest(TupleMetadata[] incomingSchemas, RecordBatch.IterOutcome[] iterOutcomes, // kill unnest after every 'unnestLimit' number of values in every record
int unnestLimit, // number of batches after which to kill the execution (!)
int execKill, T[][] data, T[][] baseline) throws Exception {
// Get the incoming container with dummy data for LJ
final List<VectorContainer> incomingContainer = new ArrayList<>(data.length);
// Create data
ArrayList<RowSet.SingleRowSet> rowSets = new ArrayList<>();
int rowNumber = 0;
int batchNum = 0;
for (Object[] recordBatch : data) {
RowSetBuilder rowSetBuilder = fixture.rowSetBuilder(incomingSchemas[batchNum]);
for (Object rowData : recordBatch) {
rowSetBuilder.addRow(++rowNumber, rowData);
}
RowSet.SingleRowSet rowSet = rowSetBuilder.build();
rowSets.add(rowSet);
incomingContainer.add(rowSet.container());
batchNum++;
}
// Get the unnest POPConfig
final UnnestPOP unnestPopConfig = new UnnestPOP(null, new SchemaPath(new PathSegment.NameSegment("unnestColumn")), DrillUnnestRelBase.IMPLICIT_COLUMN);
// Get the IterOutcomes for LJ
final List<RecordBatch.IterOutcome> outcomes = new ArrayList<>(iterOutcomes.length);
for (RecordBatch.IterOutcome o : iterOutcomes) {
outcomes.add(o);
}
// Create incoming MockRecordBatch
final MockRecordBatch incomingMockBatch = new MockRecordBatch(fixture.getFragmentContext(), operatorContext, incomingContainer, outcomes, incomingContainer.get(0).getSchema());
final MockLateralJoinBatch lateralJoinBatch = new MockLateralJoinBatch(fixture.getFragmentContext(), operatorContext, incomingMockBatch);
// setup Unnest record batch
final UnnestRecordBatch unnestBatch = new UnnestRecordBatch(unnestPopConfig, fixture.getFragmentContext());
// set pointer to Lateral in unnest pop config
unnestBatch.setIncoming((LateralContract) lateralJoinBatch);
// set backpointer to lateral join in unnest
lateralJoinBatch.setUnnest(unnestBatch);
lateralJoinBatch.setUnnestLimit(unnestLimit);
// Simulate the pipeline by calling next on the incoming
List<ValueVector> results = null;
int batchesProcessed = 0;
try {
while (!isTerminal(lateralJoinBatch.next())) {
batchesProcessed++;
if (batchesProcessed == execKill) {
lateralJoinBatch.getContext().getExecutorState().fail(new DrillException("Testing failure of execution."));
lateralJoinBatch.cancel();
}
// else nothing to do
}
// Check results against baseline
results = lateralJoinBatch.getResultList();
int i = 0;
for (ValueVector vv : results) {
int valueCount = vv.getAccessor().getValueCount();
if (valueCount != baseline[i].length) {
fail("Test failed in validating unnest output. Value count mismatch.");
}
for (int j = 0; j < valueCount; j++) {
if (vv instanceof MapVector) {
if (!compareMapBaseline(baseline[i][j], vv.getAccessor().getObject(j))) {
fail("Test failed in validating unnest(Map) output. Value mismatch");
}
} else if (vv instanceof VarCharVector) {
Object val = vv.getAccessor().getObject(j);
if (((String) baseline[i][j]).compareTo(val.toString()) != 0) {
fail("Test failed in validating unnest output. Value mismatch. Baseline value[]" + i + "][" + j + "]" + ": " + baseline[i][j] + " VV.getObject(j): " + val);
}
} else {
Object val = vv.getAccessor().getObject(j);
if (!baseline[i][j].equals(val)) {
fail("Test failed in validating unnest output. Value mismatch. Baseline value[" + i + "][" + j + "]" + ": " + baseline[i][j] + " VV.getObject(j): " + val);
}
}
}
i++;
}
assertTrue(lateralJoinBatch.isCompleted());
} catch (UserException e) {
// Valid exception
throw e;
} catch (Exception e) {
fail("Test failed in validating unnest output. Exception : " + e.getMessage());
} finally {
// Close all the resources for this test case
unnestBatch.close();
lateralJoinBatch.close();
incomingMockBatch.close();
if (results != null) {
for (ValueVector vv : results) {
vv.clear();
}
}
for (RowSet.SingleRowSet rowSet : rowSets) {
rowSet.clear();
}
}
}
use of org.apache.drill.common.exceptions.DrillException in project drill by apache.
the class TestSpnegoConfig method testInvalidSpnegoConfig.
/**
* Test invalid {@link SpnegoConfig} with missing keytab and principal
* @throws Exception
*/
@Test
public void testInvalidSpnegoConfig() throws Exception {
// Invalid configuration for SPNEGO
try {
final DrillConfig newConfig = new DrillConfig(DrillConfig.create().withValue(ExecConstants.USER_AUTHENTICATION_ENABLED, ConfigValueFactory.fromAnyRef(true)).withValue(ExecConstants.AUTHENTICATION_MECHANISMS, ConfigValueFactory.fromIterable(Lists.newArrayList("plain"))).withValue(ExecConstants.USER_AUTHENTICATOR_IMPL, ConfigValueFactory.fromAnyRef(UserAuthenticatorTestImpl.TYPE)));
final SpnegoConfig spnegoConfig = new SpnegoConfig(newConfig);
spnegoConfig.validateSpnegoConfig();
fail();
} catch (Exception ex) {
assertTrue(ex instanceof DrillException);
}
}
Aggregations