use of org.apache.drill.test.ClientFixture in project drill by axbaretto.
the class TestConfigLinkage method testMaxWidthPerNodeSession.
/* Test if setting maxwidth at session level takes precedence */
@Test
public void testMaxWidthPerNodeSession() throws Exception {
ClusterFixtureBuilder builder = ClusterFixture.bareBuilder(dirTestWatcher).sessionOption(ExecConstants.MAX_WIDTH_PER_NODE_KEY, 2);
try (ClusterFixture cluster = builder.build();
ClientFixture client = cluster.clientFixture()) {
String maxWidth = client.queryBuilder().sql("SELECT val FROM sys.%s where name='planner.width.max_per_node' and optionScope = 'SESSION'", SystemTable.OPTION_VAL.getTableName()).singletonString();
assertEquals("2", maxWidth);
}
}
use of org.apache.drill.test.ClientFixture in project drill by axbaretto.
the class TestConfigLinkage method testScopeSystem.
/* Test if the option is set at SYSTEM scope and the scope is actually SYSTEM */
@Test
public void testScopeSystem() throws Exception {
ClusterFixtureBuilder builder = ClusterFixture.bareBuilder(dirTestWatcher).systemOption(ExecConstants.SLICE_TARGET, 10000);
try (ClusterFixture cluster = builder.build();
ClientFixture client = cluster.clientFixture()) {
String scope = client.queryBuilder().sql("SELECT optionScope from sys.%s where name='planner.slice_target'", SystemTable.OPTION_VAL.getTableName()).singletonString();
Assert.assertEquals("SYSTEM", scope);
}
}
use of org.apache.drill.test.ClientFixture in project drill by axbaretto.
the class TestConfigLinkage method testScopeAlterSession.
/* Test if the option is altered at SESSION scope and the scope is actually SESSION */
@Test
public void testScopeAlterSession() throws Exception {
ClusterFixtureBuilder builder = ClusterFixture.bareBuilder(dirTestWatcher);
try (ClusterFixture cluster = builder.build();
ClientFixture client = cluster.clientFixture()) {
client.queryBuilder().sql("ALTER SESSION set `planner.slice_target`= 10000").run();
String scope = client.queryBuilder().sql("SELECT optionScope from sys.%s where name='planner.slice_target'", SystemTable.OPTION_VAL.getTableName()).singletonString();
Assert.assertEquals("SESSION", scope);
}
}
use of org.apache.drill.test.ClientFixture in project drill by axbaretto.
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());
}
}
use of org.apache.drill.test.ClientFixture in project drill by axbaretto.
the class TestOptionsAuthEnabled method testAdminUserOptions.
@Test
public void testAdminUserOptions() throws Exception {
try (ClusterFixture cluster = ClusterFixture.standardCluster(dirTestWatcher);
ClientFixture client = cluster.clientFixture()) {
OptionManager optionManager = cluster.drillbit().getContext().getOptionManager();
// Admin Users Tests
// config file should have the 'fake' default admin user and it should be returned
// by the option manager if the option has not been set by the user
String configAdminUser = optionManager.getOption(ExecConstants.ADMIN_USERS_VALIDATOR);
assertEquals(configAdminUser, ExecConstants.ADMIN_USERS_VALIDATOR.DEFAULT_ADMIN_USERS);
// Option accessor should never return the 'fake' default from the config
String adminUser1 = ExecConstants.ADMIN_USERS_VALIDATOR.getAdminUsers(optionManager);
assertNotEquals(adminUser1, ExecConstants.ADMIN_USERS_VALIDATOR.DEFAULT_ADMIN_USERS);
// Change testAdminUser if necessary
String testAdminUser = "ronswanson";
if (adminUser1.equals(testAdminUser)) {
testAdminUser += "thefirst";
}
// Check if the admin option accessor honors a user-supplied value
client.alterSystem(ExecConstants.ADMIN_USERS_KEY, testAdminUser);
String adminUser2 = ExecConstants.ADMIN_USERS_VALIDATOR.getAdminUsers(optionManager);
assertEquals(adminUser2, testAdminUser);
// Ensure that the default admin users have admin privileges
client.resetSystem(ExecConstants.ADMIN_USERS_KEY);
client.resetSystem(ExecConstants.ADMIN_USER_GROUPS_KEY);
String systemAdminUsersList0 = ExecConstants.ADMIN_USERS_VALIDATOR.getAdminUsers(optionManager);
String systemAdminUserGroupsList0 = ExecConstants.ADMIN_USER_GROUPS_VALIDATOR.getAdminUserGroups(optionManager);
for (String user : systemAdminUsersList0.split(",")) {
assertTrue(ImpersonationUtil.hasAdminPrivileges(user, systemAdminUsersList0, systemAdminUserGroupsList0));
}
// test if admin users, set by the user, have admin privileges
// test if we can handle a user-supplied list that is not well formatted
String crummyTestAdminUsersList = " alice, bob bob, charlie ,, dave ";
client.alterSystem(ExecConstants.ADMIN_USERS_KEY, crummyTestAdminUsersList);
String[] sanitizedAdminUsers = { "alice", "bob bob", "charlie", "dave" };
// also test the CSV sanitizer
assertEquals(Joiner.on(",").join(sanitizedAdminUsers), DrillStringUtils.sanitizeCSV(crummyTestAdminUsersList));
String systemAdminUsersList1 = ExecConstants.ADMIN_USERS_VALIDATOR.getAdminUsers(optionManager);
String systemAdminUserGroupsList1 = ExecConstants.ADMIN_USER_GROUPS_VALIDATOR.getAdminUserGroups(optionManager);
for (String user : sanitizedAdminUsers) {
assertTrue(ImpersonationUtil.hasAdminPrivileges(user, systemAdminUsersList1, systemAdminUserGroupsList1));
}
// Admin User Groups Tests
// config file should have the 'fake' default admin user and it should be returned
// by the option manager if the option has not been set by the user
String configAdminUserGroups = optionManager.getOption(ExecConstants.ADMIN_USER_GROUPS_VALIDATOR);
assertEquals(configAdminUserGroups, ExecConstants.ADMIN_USER_GROUPS_VALIDATOR.DEFAULT_ADMIN_USER_GROUPS);
// Option accessor should never return the 'fake' default from the config
String adminUserGroups1 = ExecConstants.ADMIN_USER_GROUPS_VALIDATOR.getAdminUserGroups(optionManager);
assertNotEquals(adminUserGroups1, ExecConstants.ADMIN_USER_GROUPS_VALIDATOR.DEFAULT_ADMIN_USER_GROUPS);
// Change testAdminUserGroups if necessary
String testAdminUserGroups = "yakshavers";
if (adminUserGroups1.equals(testAdminUserGroups)) {
testAdminUserGroups += ",wormracers";
}
// Check if the admin option accessor honors a user-supplied values
client.alterSystem(ExecConstants.ADMIN_USER_GROUPS_KEY, testAdminUserGroups);
String adminUserGroups2 = ExecConstants.ADMIN_USER_GROUPS_VALIDATOR.getAdminUserGroups(optionManager);
assertEquals(adminUserGroups2, testAdminUserGroups);
// Test if we can handle a user-supplied admin user groups list that is not well formatted
String crummyTestAdminUserGroupsList = " g1, g 2, g4 ,, g5 ";
client.alterSystem(ExecConstants.ADMIN_USER_GROUPS_KEY, crummyTestAdminUserGroupsList);
String systemAdminUserGroupsList2 = ExecConstants.ADMIN_USER_GROUPS_VALIDATOR.getAdminUserGroups(optionManager);
// for admin privileges
for (String group : systemAdminUserGroupsList2.split(",")) {
assertTrue(group.length() != 0);
assertTrue(group.trim().equals(group));
}
}
}
Aggregations