Search in sources :

Example 11 with DrillConfig

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());
    }
}
Also used : DrillConfig(org.apache.drill.common.config.DrillConfig) RpcException(org.apache.drill.exec.rpc.RpcException) NonTransientRpcException(org.apache.drill.exec.rpc.NonTransientRpcException) Properties(java.util.Properties) DrillProperties(org.apache.drill.common.config.DrillProperties) RpcException(org.apache.drill.exec.rpc.RpcException) NonTransientRpcException(org.apache.drill.exec.rpc.NonTransientRpcException) Test(org.junit.Test)

Example 12 with DrillConfig

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));
}
Also used : DrillConfig(org.apache.drill.common.config.DrillConfig) Properties(java.util.Properties) DrillProperties(org.apache.drill.common.config.DrillProperties) BeforeClass(org.junit.BeforeClass)

Example 13 with DrillConfig

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());
}
Also used : DrillConfig(org.apache.drill.common.config.DrillConfig) LocalPersistentStoreProvider(org.apache.drill.exec.store.sys.store.provider.LocalPersistentStoreProvider) SystemOptionManager(org.apache.drill.exec.server.options.SystemOptionManager) LogicalPlanPersistence(org.apache.drill.common.config.LogicalPlanPersistence)

Example 14 with DrillConfig

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());
}
Also used : ValueVectorReadExpression(org.apache.drill.exec.expr.ValueVectorReadExpression) EvaluationVisitor(org.apache.drill.exec.expr.EvaluationVisitor) DrillConfig(org.apache.drill.common.config.DrillConfig) SchemaPath(org.apache.drill.common.expression.SchemaPath) TypedFieldId(org.apache.drill.exec.record.TypedFieldId) ValueVectorWriteExpression(org.apache.drill.exec.expr.ValueVectorWriteExpression) FunctionImplementationRegistry(org.apache.drill.exec.expr.fn.FunctionImplementationRegistry) Test(org.junit.Test)

Example 15 with DrillConfig

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);
    }
}
Also used : LocalPersistentStoreProvider(org.apache.drill.exec.store.sys.store.provider.LocalPersistentStoreProvider) SystemOptionManager(org.apache.drill.exec.server.options.SystemOptionManager) Textifier(org.objectweb.asm.util.Textifier) URL(java.net.URL) ClassWriter(org.objectweb.asm.ClassWriter) QueryClassLoader(org.apache.drill.exec.compile.QueryClassLoader) TraceClassVisitor(org.objectweb.asm.util.TraceClassVisitor) DrillConfig(org.apache.drill.common.config.DrillConfig) ClassReader(org.objectweb.asm.ClassReader) File(java.io.File) PrintWriter(java.io.PrintWriter)

Aggregations

DrillConfig (org.apache.drill.common.config.DrillConfig)57 Test (org.junit.Test)35 Properties (java.util.Properties)19 DrillProperties (org.apache.drill.common.config.DrillProperties)15 Drillbit (org.apache.drill.exec.server.Drillbit)8 RemoteServiceSet (org.apache.drill.exec.server.RemoteServiceSet)8 BeforeClass (org.junit.BeforeClass)8 ScanResult (org.apache.drill.common.scanner.persistence.ScanResult)7 ExecTest (org.apache.drill.exec.ExecTest)7 LogicalPlanPersistence (org.apache.drill.common.config.LogicalPlanPersistence)6 RpcException (org.apache.drill.exec.rpc.RpcException)6 DrillbitEndpoint (org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint)5 NonTransientRpcException (org.apache.drill.exec.rpc.NonTransientRpcException)5 DrillTest (org.apache.drill.test.DrillTest)5 SchemaPath (org.apache.drill.common.expression.SchemaPath)4 BufferAllocator (org.apache.drill.exec.memory.BufferAllocator)4 DrillBuf (io.netty.buffer.DrillBuf)3 File (java.io.File)3 IOException (java.io.IOException)3 Field (java.lang.reflect.Field)3