Search in sources :

Example 91 with ClientFixture

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

the class TestConfigLinkage method testScopeAlterSystem.

/* Test if the option is altered at SYSTEM scope and the scope is actually SYSTEM */
@Test
public void testScopeAlterSystem() throws Exception {
    ClusterFixtureBuilder builder = ClusterFixture.bareBuilder(dirTestWatcher);
    try (ClusterFixture cluster = builder.build();
        ClientFixture client = cluster.clientFixture()) {
        client.queryBuilder().sql("ALTER SYSTEM set `planner.slice_target`= 10000").run();
        String scope = client.queryBuilder().sql("SELECT optionScope from sys.%s where name='planner.slice_target'", SystemTable.OPTIONS.getTableName()).singletonString();
        Assert.assertEquals("SYSTEM", scope);
    }
}
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 92 with ClientFixture

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

the class TestConfigLinkage method testInternalSystemOption.

@Test
public void testInternalSystemOption() throws Exception {
    OptionDefinition optionDefinition = createMockPropOptionDefinition();
    ClusterFixtureBuilder builder = ClusterFixture.builder(dirTestWatcher).putDefinition(optionDefinition).configProperty(ExecConstants.bootDefaultFor(MOCK_PROPERTY), "a").systemOption(MOCK_PROPERTY, "blah");
    try (ClusterFixture cluster = builder.build();
        ClientFixture client = cluster.clientFixture()) {
        String mockProp = client.queryBuilder().sql("SELECT string_val FROM sys.%s where name='%s'", SystemTable.INTERNAL_OPTIONS_OLD.getTableName(), MOCK_PROPERTY).singletonString();
        String mockProp2 = client.queryBuilder().sql("SELECT val FROM sys.%s where name='%s'", SystemTable.INTERNAL_OPTIONS.getTableName(), MOCK_PROPERTY).singletonString();
        assertEquals("blah", mockProp);
        assertEquals("blah", mockProp2);
    }
}
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 93 with ClientFixture

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

the class TestAliasSubstitution method testStorageUserAndPublicAliasPriority.

@Test
public void testStorageUserAndPublicAliasPriority() throws Exception {
    try {
        ClientFixture client = cluster.clientBuilder().property(DrillProperties.USER, TEST_USER_2).property(DrillProperties.PASSWORD, TEST_USER_2_PASSWORD).build();
        storageAliasesRegistry.createUserAliases(TEST_USER_2);
        storageAliasesRegistry.getUserAliases(TEST_USER_2).put("`foobar`", "`cp`", false);
        storageAliasesRegistry.createPublicAliases();
        storageAliasesRegistry.getPublicAliases().put("`foobar`", "`dfs`", false);
        // user alias wins
        String sql = "SELECT * FROM foobar.`tpch/lineitem.parquet` limit 1";
        long recordCount = client.queryBuilder().sql(sql).run().recordCount();
        assertEquals(1, recordCount);
    } finally {
        storageAliasesRegistry.deleteUserAliases(TEST_USER_2);
        storageAliasesRegistry.deletePublicAliases();
    }
}
Also used : ClientFixture(org.apache.drill.test.ClientFixture) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ClusterTest(org.apache.drill.test.ClusterTest) Test(org.junit.Test)

Example 94 with ClientFixture

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

the class TestAliasSystemTables method testTableAliasesTable.

@Test
public void testTableAliasesTable() throws Exception {
    try {
        ClientFixture client = cluster.clientBuilder().property(DrillProperties.USER, TEST_USER_1).property(DrillProperties.PASSWORD, TEST_USER_1_PASSWORD).build();
        tableAliasesRegistry.createPublicAliases();
        tableAliasesRegistry.getPublicAliases().put("`t1`", "`cp`.`tpch/lineitem.parquet`", false);
        tableAliasesRegistry.getPublicAliases().put("`t2`", "`cp`.`tpch/lineitem.parquet`", false);
        tableAliasesRegistry.createUserAliases(TEST_USER_1);
        tableAliasesRegistry.getUserAliases(TEST_USER_1).put("`t3`", "`cp`.`tpch/lineitem.parquet`", false);
        tableAliasesRegistry.createUserAliases(TEST_USER_2);
        tableAliasesRegistry.getUserAliases(TEST_USER_2).put("`t3`", "`cp`.`tpch/lineitem.parquet`", false);
        String sql = "SELECT * FROM sys.table_aliases";
        client.testBuilder().sqlQuery(sql).unOrdered().baselineColumns("alias", "name", "user", "isPublic").baselineValues("`t1`", "`cp`.`tpch/lineitem.parquet`", null, true).baselineValues("`t2`", "`cp`.`tpch/lineitem.parquet`", null, true).baselineValues("`t3`", "`cp`.`tpch/lineitem.parquet`", TEST_USER_1, false).baselineValues("`t3`", "`cp`.`tpch/lineitem.parquet`", TEST_USER_2, false).go();
    } finally {
        tableAliasesRegistry.deletePublicAliases();
        tableAliasesRegistry.deleteUserAliases(TEST_USER_1);
        tableAliasesRegistry.deleteUserAliases(TEST_USER_2);
    }
}
Also used : ClientFixture(org.apache.drill.test.ClientFixture) ClusterTest(org.apache.drill.test.ClusterTest) Test(org.junit.Test)

Example 95 with ClientFixture

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

the class TestAliasCommands method testDropAllPublicAliasesWithNonAdminUser.

@Test
public void testDropAllPublicAliasesWithNonAdminUser() throws Exception {
    try {
        ClientFixture client = cluster.clientBuilder().property(DrillProperties.USER, TEST_USER_2).property(DrillProperties.PASSWORD, TEST_USER_2_PASSWORD).build();
        String sql = "DROP ALL PUBLIC ALIASES for storage";
        client.queryBuilder().sql(sql).run();
        fail();
    } catch (UserRemoteException e) {
        MatcherAssert.assertThat(e.getVerboseMessage(), containsString("PERMISSION ERROR: Not authorized to perform operations on public aliases."));
    } finally {
        storageAliasesRegistry.deleteUserAliases(TEST_USER_2);
    }
}
Also used : UserRemoteException(org.apache.drill.common.exceptions.UserRemoteException) ClientFixture(org.apache.drill.test.ClientFixture) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ClusterTest(org.apache.drill.test.ClusterTest) Test(org.junit.Test)

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