@Before public void startServer() throws Exception { MetaStoreTestUtils.setConfForStandloneMode(conf); MetaStoreTestUtils.startMetaStoreWithRetry(HadoopThriftAuthBridge.getBridge(), conf); } }
@BeforeClass public static void beforeTests() throws Exception { webUIPort = MetaStoreTestUtils.findFreePortExcepting( Integer.valueOf(ConfVars.HIVE_SERVER2_WEBUI_PORT.getDefaultValue())); hiveConf = new HiveConf(); } catch (Exception t) { HiveConf.setIntVar(hiveConf, HiveConf.ConfVars.HIVE_SERVER2_THRIFT_PORT, MetaStoreTestUtils.findFreePort()); HiveConf.setIntVar(hiveConf, HiveConf.ConfVars.HIVE_SERVER2_THRIFT_HTTP_PORT, MetaStoreTestUtils.findFreePort()); HiveConf.setIntVar(hiveConf, HiveConf.ConfVars.HIVE_SERVER2_WEBUI_PORT, MetaStoreTestUtils.findFreePort()); webUIPort = hiveConf.getIntVar(HiveConf.ConfVars.HIVE_SERVER2_WEBUI_PORT);
private static String getAllThreadStacksAsString() { Map<Thread, StackTraceElement[]> threadStacks = Thread.getAllStackTraces(); StringBuilder sb = new StringBuilder(); for (Map.Entry<Thread, StackTraceElement[]> entry : threadStacks.entrySet()) { Thread t = entry.getKey(); sb.append(System.lineSeparator()); sb.append("Name: ").append(t.getName()).append(" State: ").append(t.getState()); MetaStoreTestUtils.addStackString(entry.getValue(), sb); } return sb.toString(); }
@Test public void testEventListenerException() throws Throwable { System.setProperty("hive.metastore.init.hooks", ""); System.setProperty("hive.metastore.event.listeners", ErrorEventListener.class.getName()); Configuration conf = MetastoreConf.newMetastoreConf(); MetaStoreTestUtils.setConfForStandloneMode(conf); int port = MetaStoreTestUtils.findFreePort(); try { HiveMetaStore.startMetaStore(port, HadoopThriftAuthBridge.getBridge(), conf); Assert.fail(); } catch (Throwable throwable) { Assert.assertEquals(MetaException.class, throwable.getClass()); Assert.assertEquals( "Failed to instantiate listener named: " + "org.apache.hadoop.hive.metastore.TestMetaStoreListenersError$ErrorEventListener, " + "reason: java.lang.IllegalArgumentException: exception on constructor", throwable.getMessage()); } }
public static int startMetaStoreWithRetry(HadoopThriftAuthBridge bridge, Configuration conf) throws Exception { return MetaStoreTestUtils.startMetaStoreWithRetry(bridge, conf, false); }
@Test(expected = NoSuchObjectException.class) public void alterNonExistentCatalog() throws TException { String catName = "alter_no_such_catalog"; Catalog cat = new CatalogBuilder() .setName(catName) .setLocation(MetaStoreTestUtils.getTestWarehouseDir(catName)) .build(); client.alterCatalog(catName, cat); }
@Override protected IMetaStoreClient getClient() throws Exception { Configuration svrConf = new Configuration(conf); int port = MetaStoreTestUtils.startMetaStoreWithRetry(HadoopThriftAuthBridge.getBridge(), svrConf); // Only set the default catalog on the client. MetastoreConf.setVar(conf, MetastoreConf.ConfVars.THRIFT_URIS, "thrift://localhost:" + port); MetastoreConf.setVar(conf, MetastoreConf.ConfVars.CATALOG_DEFAULT, catName); IMetaStoreClient client = new HiveMetaStoreClient(conf); assert !client.isLocalMetaStore(); // Don't make any calls but catalog calls until the catalog has been created, as we just told // the client to direct all calls to a catalog that does not yet exist. catLocation = MetaStoreTestUtils.getTestWarehouseDir(catName); Catalog cat = new CatalogBuilder() .setName(catName) .setLocation(catLocation) .build(); client.createCatalog(cat); return client; }
@BeforeClass public static void beforeTests() throws Exception { llapWSPort = MetaStoreTestUtils.findFreePortExcepting( Integer.valueOf(HiveConf.ConfVars.LLAP_DAEMON_WEB_PORT.getDefaultValue())); llapWS = new LlapWebServices(llapWSPort, null, null); llapWS.init(new HiveConf()); llapWS.start(); Thread.sleep(5000); }
/** * @throws java.lang.Exception */ @BeforeClass public static void setUpBeforeClass() throws Exception { // Find a free port port = MetaStoreTestUtils.findFreePort(); hiveServer2 = new HiveServer2(); hiveConf = new HiveConf(); }
int metaStorePort = findFreePort(); MetastoreConf.setVar(conf, ConfVars.THRIFT_URIS, "thrift://localhost:" + metaStorePort); MetaStoreTestUtils.startMetaStore(metaStorePort, bridge, conf);
@Before public void setUp() throws Exception { conf = MetastoreConf.newMetastoreConf(); MetaStoreTestUtils.setConfForStandloneMode(conf); .setTableName("external_table_for_test") .addCol("test_col", "int") .setLocation(MetaStoreTestUtils.getTestWarehouseDir("/external/table_dir")) .addTableParam("EXTERNAL", "TRUE") .setType("EXTERNAL_TABLE")
@After public void dropCatalog() throws TException { MetaStoreTestUtils.dropCatalogCascade(client, catName); }
LOG.info(MetaStoreTestUtils.getAllThreadStacksAsString()); throw exc;
public static int startMetaStoreWithRetry(Configuration conf, boolean keepJdbcUri) throws Exception { return MetaStoreTestUtils.startMetaStoreWithRetry(HadoopThriftAuthBridge.getBridge(), conf, keepJdbcUri); }
String db1Location = MetaStoreTestUtils.getTestWarehouseDir(dbNames[1]); dbs[1] = new DatabaseBuilder() .setName(dbNames[1])
@Test public void testInitListenerException() throws Throwable { System.setProperty("hive.metastore.init.hooks", ErrorInitListener.class.getName()); Configuration conf = MetastoreConf.newMetastoreConf(); MetaStoreTestUtils.setConfForStandloneMode(conf); int port = MetaStoreTestUtils.findFreePort(); try { HiveMetaStore.startMetaStore(port, HadoopThriftAuthBridge.getBridge(), conf); Assert.fail(); } catch (Throwable throwable) { Assert.assertEquals(MetaException.class, throwable.getClass()); Assert.assertEquals( "Failed to instantiate listener named: " + "org.apache.hadoop.hive.metastore.TestMetaStoreListenersError$ErrorInitListener, " + "reason: java.lang.IllegalArgumentException: exception on constructor", throwable.getMessage()); } }
@BeforeClass public static void beforeTests() throws Exception { createTestDir(); createDefaultKeyStore(); String metastorePasswd = "693efe9fa425ad21886d73a0fa3fbc70"; //random md5 Integer webUIPort = MetaStoreTestUtils.findFreePortExcepting(Integer.valueOf(ConfVars.HIVE_SERVER2_WEBUI_PORT.getDefaultValue())); hiveConf = new HiveConf(); hiveConf.setBoolVar(ConfVars.HIVE_SERVER2_WEBUI_USE_PAM, true); hiveConf.setBoolVar(ConfVars.HIVE_IN_TEST, false); hiveConf.set(ConfVars.METASTOREPWD.varname, metastorePasswd); hiveConf.set(ConfVars.HIVE_SERVER2_WEBUI_PORT.varname, webUIPort.toString()); hiveConf.setVar(HiveConf.ConfVars.HIVE_AUTHORIZATION_MANAGER, "org.apache.hadoop.hive.ql.security.authorization.plugin.sqlstd.SQLStdHiveAuthorizerFactory"); }
protected static void startHiveServer2WithConf(HiveConf hiveConf) throws Exception { Exception HS2Exception = null; boolean HS2Started = false; for (int tryCount = 0; tryCount < MetaStoreTestUtils.RETRY_COUNT; tryCount++) { try { hiveServer2.init(hiveConf); hiveServer2.start(); HS2Started = true; break; } catch (Exception t) { HS2Exception = t; port = MetaStoreTestUtils.findFreePort(); hiveConf.setIntVar(ConfVars.HIVE_SERVER2_THRIFT_HTTP_PORT, port); hiveServer2 = new HiveServer2(); } } if (!HS2Started) { HS2Exception.printStackTrace(); fail(); } // Wait for startup to complete Thread.sleep(2000); System.out.println("HiveServer2 started on port " + port); }
@After public void dropCatalog() throws TException { MetaStoreTestUtils.dropCatalogCascade(catalogCapableClient, catName); catalogCapableClient.close(); }
@Before public void setUp() throws Exception { conf = MetastoreConf.newMetastoreConf(); System.setProperty(ConfVars.EVENT_LISTENERS.toString(), IpAddressListener.class.getName()); MetaStoreTestUtils.setConfForStandloneMode(conf); MetaStoreTestUtils.startMetaStoreWithRetry(HadoopThriftAuthBridge.getBridge(), conf); msc = new HiveMetaStoreClient(conf); }