diff --git itests/src/test/resources/testconfiguration.properties itests/src/test/resources/testconfiguration.properties index fa1a4fb603..7738e799d6 100644 --- itests/src/test/resources/testconfiguration.properties +++ itests/src/test/resources/testconfiguration.properties @@ -18,7 +18,6 @@ disabled.query.files=ql_rewrite_gbtoidx.q,\ union_stats.q,\ sample2.q,\ sample4.q,\ - sample6.q,\ root_dir_external_table.q diff --git itests/util/src/main/java/org/apache/hadoop/hive/cli/control/CoreCliDriver.java itests/util/src/main/java/org/apache/hadoop/hive/cli/control/CoreCliDriver.java index a7ec4f3d25..b4176a4c19 100644 --- itests/util/src/main/java/org/apache/hadoop/hive/cli/control/CoreCliDriver.java +++ itests/util/src/main/java/org/apache/hadoop/hive/cli/control/CoreCliDriver.java @@ -72,7 +72,8 @@ public QTestUtil invokeInternal() throws Exception { new ElapsedTimeLoggingWrapper() { @Override public Void invokeInternal() throws Exception { - qt.cleanUp(); + qt.newSession(); + qt.cleanUp(); // I don't think this is neccessary... return null; } }.invoke("Initialization cleanup done.", LOG, true); @@ -100,7 +101,7 @@ public void setUp() { new ElapsedTimeLoggingWrapper() { @Override public Void invokeInternal() throws Exception { - qt.clearTestSideEffects(); + qt.newSession(); return null; } }.invoke("PerTestSetup done.", LOG, false); @@ -120,6 +121,7 @@ public void tearDown() { @Override public Void invokeInternal() throws Exception { qt.clearPostTestEffects(); + qt.clearTestSideEffects(); return null; } }.invoke("PerTestTearDown done.", LOG, false); diff --git itests/util/src/main/java/org/apache/hadoop/hive/ql/QTestUtil.java itests/util/src/main/java/org/apache/hadoop/hive/ql/QTestUtil.java index 2365fb76bd..0f0fd88123 100644 --- itests/util/src/main/java/org/apache/hadoop/hive/ql/QTestUtil.java +++ itests/util/src/main/java/org/apache/hadoop/hive/ql/QTestUtil.java @@ -247,7 +247,7 @@ private static void initSrcTablesFromSystemProperty(){ private CliDriver getCliDriver() { if(cliDriver == null){ - cliDriver = new CliDriver(); + throw new RuntimeException("no clidriver"); } return cliDriver; } @@ -1092,6 +1092,38 @@ public void clearTablesCreatedDuringTests() throws Exception { } } + public void newSession() throws Exception { + // allocate and initialize a new conf since a test can + // modify conf by using 'set' commands + conf = new HiveConf(IDriver.class); + initConf(); + initConfFromSetup(); + + // renew the metastore since the cluster type is unencrypted + db = Hive.get(conf); // propagate new conf to meta store + + HiveConf.setVar(conf, HiveConf.ConfVars.HIVE_AUTHENTICATOR_MANAGER, + "org.apache.hadoop.hive.ql.security.DummyAuthenticator"); + CliSessionState ss = new CliSessionState(conf); + assert ss != null; + ss.in = System.in; + + SessionState oldSs = SessionState.get(); + + //FIXME: canReuseSession as arg...etc + boolean canReuseSession = true; //!qNoSessionReuseQuerySet.contains(fileName); + restartSessions(canReuseSession, ss, oldSs); + + closeSession(oldSs); + + SessionState.start(ss); + + cliDriver = new CliDriver(); + + File outf = new File(logDir, "initialize.log"); + setSessionOutputs("that_shouldnt_happen_there", ss, outf); + + } /** * Clear out any side effects of running tests */ @@ -1101,34 +1133,15 @@ public void clearTestSideEffects() throws Exception { } // Remove any cached results from the previous test. + Utilities.clearWorkMap(conf); NotificationEventPoll.shutdown(); QueryResultsCache.cleanupInstance(); - - // allocate and initialize a new conf since a test can - // modify conf by using 'set' commands - conf = new HiveConf(IDriver.class); - initConf(); - initConfFromSetup(); - - // renew the metastore since the cluster type is unencrypted - db = Hive.get(conf); // propagate new conf to meta store - clearTablesCreatedDuringTests(); clearUDFsCreatedDuringTests(); clearKeysCreatedInTests(); StatsSources.clearGlobalStats(); } - protected void clearSettingsCreatedInTests() throws IOException { - getCliDriver().processLine(String.format("set hive.security.authorization.enabled=false;")); - getCliDriver().processLine(String.format("set user.name=%s;", - System.getProperty(TEST_HIVE_USER_PROPERTY, "hive_test_user"))); - - getCliDriver().processLine("set hive.metastore.partition.name.whitelist.pattern=;"); - getCliDriver().processLine("set hive.test.mode=false;"); - getCliDriver().processLine("set hive.mapred.mode=nonstrict;"); - } - protected void initConfFromSetup() throws Exception { setup.preTest(conf); } @@ -1320,20 +1333,22 @@ public String cliInit(File file, boolean recreate) throws Exception { if (recreate) { cleanUp(fileName); createSources(fileName); + throw new RuntimeException("WHY WE RECREATE?!"); } - clearSettingsCreatedInTests(); initDataSetForTest(file); - HiveConf.setVar(conf, HiveConf.ConfVars.HIVE_AUTHENTICATOR_MANAGER, - "org.apache.hadoop.hive.ql.security.DummyAuthenticator"); - Utilities.clearWorkMap(conf); - CliSessionState ss = new CliSessionState(conf); - assert ss != null; - ss.in = System.in; + CliSessionState ss = (CliSessionState) SessionState.get(); + + if (fileName.equals("init_file.q")) { + // FIXME: remove this crap; it probably unused anyway + ss.initFiles.add(AbstractCliConfig.HIVE_ROOT + "/data/scripts/test_init_file.sql"); + } + cliDriver.processInitFiles(ss); String outFileExtension = getOutFileExtension(fileName); String stdoutName = null; + if (outDir != null) { // TODO: why is this needed? File qf = new File(outDir, fileName); @@ -1341,27 +1356,8 @@ public String cliInit(File file, boolean recreate) throws Exception { } else { stdoutName = fileName + outFileExtension; } - File outf = new File(logDir, stdoutName); - setSessionOutputs(fileName, ss, outf); - - SessionState oldSs = SessionState.get(); - - boolean canReuseSession = !qNoSessionReuseQuerySet.contains(fileName); - restartSessions(canReuseSession, ss, oldSs); - - closeSession(oldSs); - - SessionState.start(ss); - - cliDriver = new CliDriver(); - - if (fileName.equals("init_file.q")) { - ss.initFiles.add(AbstractCliConfig.HIVE_ROOT + "/data/scripts/test_init_file.sql"); - } - cliDriver.processInitFiles(ss); - return outf.getAbsolutePath(); }