use of org.apache.hadoop.hbase.HBaseTestingUtility in project beam by apache.
the class HBaseIOTest method beforeClass.
@BeforeClass
public static void beforeClass() throws Exception {
conf.setInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER, 1);
// Try to bind the hostname to localhost to solve an issue when it is not configured or
// no DNS resolution available.
conf.setStrings("hbase.master.hostname", "localhost");
conf.setStrings("hbase.regionserver.hostname", "localhost");
htu = new HBaseTestingUtility(conf);
htu.startMiniCluster(1, 4);
admin = htu.getHBaseAdmin();
}
use of org.apache.hadoop.hbase.HBaseTestingUtility in project phoenix by apache.
the class ConnectionUtilIT method setUp.
@BeforeClass
public static void setUp() throws Exception {
hbaseTestUtil = new HBaseTestingUtility();
conf = hbaseTestUtil.getConfiguration();
setUpConfigForMiniCluster(conf);
conf.set(HConstants.ZOOKEEPER_ZNODE_PARENT, "/hbase-test");
hbaseTestUtil.startMiniCluster();
Class.forName(PhoenixDriver.class.getName());
}
use of org.apache.hadoop.hbase.HBaseTestingUtility in project phoenix by apache.
the class ContextClassloaderIT method setUpBeforeClass.
@BeforeClass
public static void setUpBeforeClass() throws Exception {
Configuration conf = HBaseConfiguration.create();
setUpConfigForMiniCluster(conf);
hbaseTestUtil = new HBaseTestingUtility(conf);
hbaseTestUtil.startMiniCluster();
String clientPort = hbaseTestUtil.getConfiguration().get(QueryServices.ZOOKEEPER_PORT_ATTRIB);
String url = JDBC_PROTOCOL + JDBC_PROTOCOL_SEPARATOR + LOCALHOST + JDBC_PROTOCOL_SEPARATOR + clientPort + JDBC_PROTOCOL_TERMINATOR + PHOENIX_TEST_DRIVER_URL_PARAM;
driver = initAndRegisterTestDriver(url, ReadOnlyProps.EMPTY_PROPS);
Connection conn = DriverManager.getConnection(url);
Statement stmt = conn.createStatement();
stmt.execute("CREATE TABLE test (ID INTEGER NOT NULL PRIMARY KEY, NAME VARCHAR)");
stmt.execute("UPSERT INTO test VALUES (1, 'name1')");
stmt.execute("UPSERT INTO test VALUES (2, 'name2')");
stmt.close();
conn.commit();
conn.close();
badContextClassloader = new URLClassLoader(new URL[] { File.createTempFile("invalid", ".jar").toURI().toURL() }, null);
}
use of org.apache.hadoop.hbase.HBaseTestingUtility in project phoenix by apache.
the class Sandbox method main.
public static void main(String[] args) throws Exception {
System.out.println("Starting Phoenix sandbox");
Configuration conf = HBaseConfiguration.create();
BaseTest.setUpConfigForMiniCluster(conf, new ReadOnlyProps(ImmutableMap.<String, String>of()));
final HBaseTestingUtility testUtil = new HBaseTestingUtility(conf);
testUtil.startMiniCluster();
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
try {
if (testUtil != null) {
testUtil.shutdownMiniCluster();
}
} catch (Exception e) {
LOG.error("Exception caught when shutting down mini cluster", e);
}
}
});
int clientPort = testUtil.getZkCluster().getClientPort();
System.out.println("\n\n\tPhoenix Sandbox is started\n\n");
System.out.printf("\tYou can now connect with url 'jdbc:phoenix:localhost:%d'\n" + "\tor connect via sqlline with 'bin/sqlline.py localhost:%d'\n\n", clientPort, clientPort);
Thread.sleep(Long.MAX_VALUE);
}
use of org.apache.hadoop.hbase.HBaseTestingUtility in project phoenix by apache.
the class SystemTablePermissionsIT method testNamespaceMappedSystemTables.
@Test
public void testNamespaceMappedSystemTables() throws Exception {
testUtil = new HBaseTestingUtility();
clientProperties = new Properties();
Configuration conf = testUtil.getConfiguration();
setCommonConfigProperties(conf);
testUtil.getConfiguration().set(QueryServices.IS_NAMESPACE_MAPPING_ENABLED, "true");
clientProperties.setProperty(QueryServices.IS_NAMESPACE_MAPPING_ENABLED, "true");
testUtil.startMiniCluster(1);
final UserGroupInformation superUser = UserGroupInformation.createUserForTesting(SUPERUSER, new String[0]);
final UserGroupInformation regularUser = UserGroupInformation.createUserForTesting("user", new String[0]);
superUser.doAs(new PrivilegedExceptionAction<Void>() {
@Override
public Void run() throws Exception {
createTable();
readTable();
return null;
}
});
Set<String> tables = getHBaseTables();
assertTrue("HBase tables do not include expected Phoenix tables: " + tables, tables.containsAll(PHOENIX_NAMESPACE_MAPPED_SYSTEM_TABLES));
// Grant permission to the system tables for the unprivileged user
// An unprivileged user should only need to be able to Read and eXecute on them.
superUser.doAs(new PrivilegedExceptionAction<Void>() {
@Override
public Void run() throws Exception {
try {
grantPermissions(regularUser.getShortUserName(), PHOENIX_NAMESPACE_MAPPED_SYSTEM_TABLES, Action.EXEC, Action.READ);
grantPermissions(regularUser.getShortUserName(), Collections.singleton(TABLE_NAME), Action.READ);
} catch (Throwable e) {
if (e instanceof Exception) {
throw (Exception) e;
} else {
throw new Exception(e);
}
}
return null;
}
});
regularUser.doAs(new PrivilegedExceptionAction<Void>() {
@Override
public Void run() throws Exception {
// We expect this to not throw an error
readTable();
return null;
}
});
}
Aggregations