use of org.apache.drill.common.config.DrillConfig in project drill by apache.
the class TestUserBitKerberosEncryption method failureOldClientEncryptionEnabled.
/**
* Test to validate that older clients are not allowed to connect to secure cluster
* with encryption enabled.
*/
@Test
public void failureOldClientEncryptionEnabled() {
try {
final Properties connectionProps = new Properties();
connectionProps.setProperty(DrillProperties.SERVICE_PRINCIPAL, krbHelper.SERVER_PRINCIPAL);
connectionProps.setProperty(DrillProperties.USER, krbHelper.CLIENT_PRINCIPAL);
connectionProps.setProperty(DrillProperties.KEYTAB, krbHelper.clientKeytab.getAbsolutePath());
connectionProps.setProperty(DrillProperties.TEST_SASL_LEVEL, "1");
newConfig = new DrillConfig(DrillConfig.create(cloneDefaultTestConfigProperties()).withValue(ExecConstants.USER_AUTHENTICATION_ENABLED, ConfigValueFactory.fromAnyRef(true)).withValue(ExecConstants.USER_AUTHENTICATOR_IMPL, ConfigValueFactory.fromAnyRef(UserAuthenticatorTestImpl.TYPE)).withValue(BootStrapContext.SERVICE_PRINCIPAL, ConfigValueFactory.fromAnyRef(krbHelper.SERVER_PRINCIPAL)).withValue(BootStrapContext.SERVICE_KEYTAB_LOCATION, ConfigValueFactory.fromAnyRef(krbHelper.serverKeytab.toString())).withValue(ExecConstants.AUTHENTICATION_MECHANISMS, ConfigValueFactory.fromIterable(Lists.newArrayList("plain", "kerberos"))).withValue(ExecConstants.USER_ENCRYPTION_SASL_ENABLED, ConfigValueFactory.fromAnyRef(true)), false);
updateTestCluster(1, newConfig, connectionProps);
fail();
} catch (Exception ex) {
assert (ex.getCause() instanceof RpcException);
System.out.println("Caught exception: " + ex.getMessage());
logger.info("Caught exception: " + ex.getMessage());
}
}
use of org.apache.drill.common.config.DrillConfig in project drill by apache.
the class TestOptionsAuthEnabled method setupCluster.
@BeforeClass
public static void setupCluster() throws Exception {
// Create a new DrillConfig which has user authentication enabled and test authenticator set
final DrillConfig config = new DrillConfig(DrillConfig.create(cloneDefaultTestConfigProperties()).withValue(ExecConstants.USER_AUTHENTICATION_ENABLED, ConfigValueFactory.fromAnyRef(true)).withValue(ExecConstants.USER_AUTHENTICATOR_IMPL, ConfigValueFactory.fromAnyRef(UserAuthenticatorTestImpl.TYPE)), false);
final Properties connectionProps = new Properties();
connectionProps.setProperty(DrillProperties.USER, PROCESS_USER);
connectionProps.setProperty(DrillProperties.PASSWORD, PROCESS_USER_PASSWORD);
updateTestCluster(1, config, connectionProps);
// Add user "admin" to admin username list
test(String.format("ALTER SYSTEM SET `%s`='%s,%s'", ExecConstants.ADMIN_USERS_KEY, ADMIN_USER, PROCESS_USER));
// Set "admingrp" to admin username list
test(String.format("ALTER SYSTEM SET `%s`='%s'", ExecConstants.ADMIN_USER_GROUPS_KEY, ADMIN_GROUP));
}
use of org.apache.drill.common.config.DrillConfig in project drill by apache.
the class CodeCompilerTestFactory method getTestCompiler.
public static CodeCompiler getTestCompiler(DrillConfig c) throws Exception {
DrillConfig config = checkNotNull(c);
LogicalPlanPersistence persistence = new LogicalPlanPersistence(config, ClassPathScanner.fromPrescan(config));
LocalPersistentStoreProvider provider = new LocalPersistentStoreProvider(config);
SystemOptionManager systemOptionManager = new SystemOptionManager(persistence, provider);
return new CodeCompiler(config, systemOptionManager.init());
}
use of org.apache.drill.common.config.DrillConfig in project drill by apache.
the class TestEvaluationVisitor method x.
@Test
public void x() throws Exception {
DrillConfig c = DrillConfig.create();
FunctionImplementationRegistry reg = new FunctionImplementationRegistry(c);
EvaluationVisitor v = new EvaluationVisitor(reg);
CodeGenerator<?> g = CodeGenerator.get(Projector.TEMPLATE_DEFINITION, reg, null);
SchemaPath path = (SchemaPath) getExpr("a.b[4][2].c[6]");
TypedFieldId id = //
TypedFieldId.newBuilder().addId(//
1).addId(//
3).remainder(//
path.getRootSegment()).intermediateType(Types.optional(MinorType.MAP)).finalType(//
Types.repeated(MinorType.MAP)).hyper().withIndex().build();
ValueVectorReadExpression e = new ValueVectorReadExpression(id);
TypedFieldId outId = //
TypedFieldId.newBuilder().addId(//
1).finalType(//
Types.repeated(MinorType.MAP)).intermediateType(//
Types.repeated(MinorType.MAP)).build();
ValueVectorWriteExpression e2 = new ValueVectorWriteExpression(outId, e, true);
v.addExpr(e2, g.getRoot());
logger.debug(g.generateAndGet());
}
use of org.apache.drill.common.config.DrillConfig in project drill by apache.
the class ReplaceMethodInvoke method main.
// private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(ReplaceMethodInvoke.class);
public static void main(String[] args) throws Exception {
final String k2 = "org/apache/drill/Pickle.class";
final URL url = Resources.getResource(k2);
final byte[] clazz = Resources.toByteArray(url);
final ClassReader cr = new ClassReader(clazz);
final ClassWriter cw = writer();
final TraceClassVisitor visitor = new TraceClassVisitor(cw, new Textifier(), new PrintWriter(System.out));
final ValueHolderReplacementVisitor v2 = new ValueHolderReplacementVisitor(visitor, true);
//| ClassReader.SKIP_DEBUG);
cr.accept(v2, ClassReader.EXPAND_FRAMES);
final byte[] output = cw.toByteArray();
Files.write(output, new File("/src/scratch/bytes/S.class"));
check(output);
final DrillConfig c = DrillConfig.forClient();
final SystemOptionManager m = new SystemOptionManager(PhysicalPlanReaderTestFactory.defaultLogicalPlanPersistence(c), new LocalPersistentStoreProvider(c));
m.init();
try (QueryClassLoader ql = new QueryClassLoader(DrillConfig.create(), m)) {
ql.injectByteCode("org.apache.drill.Pickle$OutgoingBatch", output);
Class<?> clz = ql.loadClass("org.apache.drill.Pickle$OutgoingBatch");
clz.getMethod("x").invoke(null);
}
}
Aggregations