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);
}
}
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);
}
}
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();
}
}
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);
}
}
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);
}
}
Aggregations