@Test public void testSessionGlobalInitDir() throws Exception { doTestSessionGlobalInitFile(); }
@Test public void testSessionGlobalInitFileAndConfOverlay() throws Exception { // Test if the user session specific conf overlaying global init conf. Map<String, String> confOverlay = new HashMap<String, String>(); confOverlay.put("a", "2"); confOverlay.put("set:hiveconf:b", "2"); confOverlay.put("set:hivevar:c", "2"); SessionHandle sessionHandle = client.openSession(null, null, confOverlay); verifyInitProperty("a", "2", sessionHandle); verifyInitProperty("b", "2", sessionHandle); verifyInitProperty("c", "2", sessionHandle); client.closeSession(sessionHandle); sessionHandle = client.openSession("hive", "password", confOverlay); verifyInitProperty("a", "2", sessionHandle); client.closeSession(sessionHandle); }
/** * create session, and fetch the property set in global init file. Test if * the global init file .hiverc is loaded correctly by checking the expected * setting property. */ private void doTestSessionGlobalInitFile() throws Exception { OperationManager operationManager = service.getService().getSessionManager() .getOperationManager(); SessionHandle sessionHandle = client.openSession(null, null, null); // ensure there is no operation related object leak Assert.assertEquals("Verifying all operations used for init file are closed", 0, operationManager.getOperations().size()); verifyInitProperty("a", "1", sessionHandle); verifyInitProperty("b", "1", sessionHandle); verifyInitProperty("c", "1", sessionHandle); verifyInitProperty("hivevar:c", "1", sessionHandle); verifyInitProperty("d", "1", sessionHandle); /** * TODO: client.executeStatement do not support listing resources command * (beeline> list jar) */ // Assert.assertEquals("expected uri", api.getAddedResource("jar")); Assert.assertEquals("Verifying all operations used for checks are closed", 0, operationManager.getOperations().size()); client.closeSession(sessionHandle); }
@Test public void testSessionGlobalInitFile() throws Exception { File tmpInitFile = new File(initFile.getParent(), "hiverc"); Assert.assertTrue("Failed to rename " + initFile + " to " + tmpInitFile, initFile.renameTo(tmpInitFile)); initFile = tmpInitFile; hiveConf.setVar(HiveConf.ConfVars.HIVE_SERVER2_GLOBAL_INIT_FILE_LOCATION, initFile.getAbsolutePath()); doTestSessionGlobalInitFile(); }
@Test public void testSessionGlobalInitFileWithUser() throws Exception { //Test when the session is opened by a user. (HiveSessionImplwithUGI) SessionHandle sessionHandle = client.openSession("hive", "password", null); verifyInitProperty("a", "1", sessionHandle); client.closeSession(sessionHandle); }