Search in sources :

Example 31 with ClientFixture

use of org.apache.drill.test.ClientFixture in project drill by apache.

the class TestLateralPlans method testUnnestTableAndColumnAlias.

@Test
public void testUnnestTableAndColumnAlias() throws Exception {
    String sql = "select t.c_name from cp.`lateraljoin/nested-customer.json` t, unnest(t.orders) ";
    ClusterFixtureBuilder builder = ClusterFixture.builder(dirTestWatcher).setOptionDefault(PlannerSettings.ENABLE_UNNEST_LATERAL_KEY, true);
    try (ClusterFixture cluster = builder.build();
        ClientFixture client = cluster.clientFixture()) {
        client.queryBuilder().sql(sql).run();
    } catch (UserRemoteException ex) {
        assertTrue(ex.getMessage().contains("Alias table and column name are required for UNNEST"));
    }
}
Also used : ClusterFixture(org.apache.drill.test.ClusterFixture) UserRemoteException(org.apache.drill.common.exceptions.UserRemoteException) ClientFixture(org.apache.drill.test.ClientFixture) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ClusterFixtureBuilder(org.apache.drill.test.ClusterFixtureBuilder) Test(org.junit.Test)

Example 32 with ClientFixture

use of org.apache.drill.test.ClientFixture in project drill by apache.

the class TestConfigLinkage method testSessionPrecedence.

/* Test if altering session option takes precedence over system option */
@Test
public void testSessionPrecedence() throws Exception {
    ClusterFixtureBuilder builder = ClusterFixture.builder(dirTestWatcher).systemOption(ExecConstants.SLICE_TARGET, 100000);
    try (ClusterFixture cluster = builder.build();
        ClientFixture client = cluster.clientFixture()) {
        client.queryBuilder().sql("ALTER SESSION SET `planner.slice_target` = 10000").run();
        String slice_target = client.queryBuilder().sql("SELECT val FROM sys.%s where name='planner.slice_target' and optionScope = 'SESSION'", SystemTable.OPTIONS.getTableName()).singletonString();
        assertEquals(slice_target, "10000");
    }
}
Also used : ClusterFixture(org.apache.drill.test.ClusterFixture) ClientFixture(org.apache.drill.test.ClientFixture) ClusterFixtureBuilder(org.apache.drill.test.ClusterFixtureBuilder) Test(org.junit.Test) OptionsTest(org.apache.drill.categories.OptionsTest) BaseTest(org.apache.drill.test.BaseTest) SlowTest(org.apache.drill.categories.SlowTest)

Example 33 with ClientFixture

use of org.apache.drill.test.ClientFixture in project drill by apache.

the class StatusResourcesTest method testRetrievePublicOption.

@Test
public void testRetrievePublicOption() throws Exception {
    ClusterFixtureBuilder builder = ClusterFixture.builder(dirTestWatcher).configProperty(ExecConstants.HTTP_ENABLE, true).configProperty(ExecConstants.HTTP_PORT_HUNT, true).configProperty(ExecConstants.SYS_STORE_PROVIDER_LOCAL_ENABLE_WRITE, false).systemOption(ExecConstants.SLICE_TARGET, 20);
    try (ClusterFixture cluster = builder.build();
        ClientFixture client = cluster.clientFixture();
        RestClientFixture restClientFixture = cluster.restClientFixture()) {
        Assert.assertNull(restClientFixture.getStatusInternalOption(ExecConstants.SLICE_TARGET));
        StatusResources.OptionWrapper option = restClientFixture.getStatusOption(ExecConstants.SLICE_TARGET);
        Assert.assertEquals(20, option.getValue());
        client.alterSystem(ExecConstants.SLICE_TARGET, 30);
        Assert.assertNull(restClientFixture.getStatusInternalOption(ExecConstants.SLICE_TARGET));
        option = restClientFixture.getStatusOption(ExecConstants.SLICE_TARGET);
        Assert.assertEquals(30, option.getValue());
    }
}
Also used : ClusterFixture(org.apache.drill.test.ClusterFixture) RestClientFixture(org.apache.drill.test.RestClientFixture) RestClientFixture(org.apache.drill.test.RestClientFixture) ClientFixture(org.apache.drill.test.ClientFixture) ClusterFixtureBuilder(org.apache.drill.test.ClusterFixtureBuilder) Test(org.junit.Test) BaseTest(org.apache.drill.test.BaseTest)

Example 34 with ClientFixture

use of org.apache.drill.test.ClientFixture in project drill by apache.

the class StatusResourcesTest method testRetrieveInternalOption.

@Test
public void testRetrieveInternalOption() throws Exception {
    OptionDefinition optionDefinition = createMockPropOptionDefinition();
    ClusterFixtureBuilder builder = ClusterFixture.builder(dirTestWatcher).configProperty(ExecConstants.HTTP_ENABLE, true).configProperty(ExecConstants.bootDefaultFor(MOCK_PROPERTY), "a").configProperty(ExecConstants.HTTP_PORT_HUNT, true).configProperty(ExecConstants.SYS_STORE_PROVIDER_LOCAL_ENABLE_WRITE, false).putDefinition(optionDefinition);
    try (ClusterFixture cluster = builder.build();
        ClientFixture client = cluster.clientFixture();
        RestClientFixture restClientFixture = cluster.restClientFixture()) {
        Assert.assertNull(restClientFixture.getStatusOption(MOCK_PROPERTY));
        StatusResources.OptionWrapper option = restClientFixture.getStatusInternalOption(MOCK_PROPERTY);
        Assert.assertEquals("a", option.getValueAsString());
        client.alterSystem(MOCK_PROPERTY, "c");
        Assert.assertNull(restClientFixture.getStatusOption(MOCK_PROPERTY));
        option = restClientFixture.getStatusInternalOption(MOCK_PROPERTY);
        Assert.assertEquals("c", option.getValueAsString());
    }
}
Also used : ClusterFixture(org.apache.drill.test.ClusterFixture) RestClientFixture(org.apache.drill.test.RestClientFixture) RestClientFixture(org.apache.drill.test.RestClientFixture) ClientFixture(org.apache.drill.test.ClientFixture) ClusterFixtureBuilder(org.apache.drill.test.ClusterFixtureBuilder) TestConfigLinkage.createMockPropOptionDefinition(org.apache.drill.exec.server.options.TestConfigLinkage.createMockPropOptionDefinition) OptionDefinition(org.apache.drill.exec.server.options.OptionDefinition) Test(org.junit.Test) BaseTest(org.apache.drill.test.BaseTest)

Example 35 with ClientFixture

use of org.apache.drill.test.ClientFixture in project drill by apache.

the class TestHtpasswdFileUserAuthenticator method tryCredentials.

private static void tryCredentials(String user, String password, ClusterFixture cluster, boolean shouldSucceed) throws Exception {
    try {
        ClientFixture client = cluster.clientBuilder().property(DrillProperties.USER, user).property(DrillProperties.PASSWORD, password).build();
        // Run few queries using the new client
        List<String> queries = Arrays.asList("SHOW SCHEMAS", "USE INFORMATION_SCHEMA", "SHOW TABLES", "SELECT * FROM INFORMATION_SCHEMA.`TABLES` WHERE TABLE_NAME LIKE 'COLUMNS'", "SELECT * FROM cp.`region.json` LIMIT 5");
        for (String query : queries) {
            client.queryBuilder().sql(query).run();
        }
        if (!shouldSucceed) {
            fail("Expected connect to fail because of incorrect username / password combination, but it succeeded");
        }
    } catch (IllegalStateException e) {
        if (shouldSucceed) {
            throw e;
        }
    }
}
Also used : ClientFixture(org.apache.drill.test.ClientFixture)

Aggregations

ClientFixture (org.apache.drill.test.ClientFixture)122 Test (org.junit.Test)102 ClusterFixture (org.apache.drill.test.ClusterFixture)99 ClusterFixtureBuilder (org.apache.drill.test.ClusterFixtureBuilder)89 SlowTest (org.apache.drill.categories.SlowTest)46 OptionsTest (org.apache.drill.categories.OptionsTest)36 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)28 BaseTest (org.apache.drill.test.BaseTest)20 ClusterTest (org.apache.drill.test.ClusterTest)16 QueryDataBatch (org.apache.drill.exec.rpc.user.QueryDataBatch)12 DrillTest (org.apache.drill.test.DrillTest)10 OperatorTest (org.apache.drill.categories.OperatorTest)8 UserRemoteException (org.apache.drill.common.exceptions.UserRemoteException)7 RestClientFixture (org.apache.drill.test.RestClientFixture)4 ArrayList (java.util.ArrayList)3 SchemaPath (org.apache.drill.common.expression.SchemaPath)3 RecordBatchLoader (org.apache.drill.exec.record.RecordBatchLoader)3 BigIntVector (org.apache.drill.exec.vector.BigIntVector)3 File (java.io.File)2 PlanFragment (org.apache.drill.exec.proto.BitControl.PlanFragment)2