Skip to content

Commit 78f50fd

Browse files
authored
HIVE-29452: Split get table from HMSHandler (#6427)
1 parent 9ce0fc1 commit 78f50fd

File tree

6 files changed

+731
-522
lines changed

6 files changed

+731
-522
lines changed

itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/TestDatabaseTableDefault.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ public void setUp() throws Exception {
9898
TestTxnDbUtil.prepDb(hiveConf);
9999

100100
SessionState.start(new SessionState(hiveConf));
101+
MetastoreConf.setBoolVar(hiveConf, ConfVars.HIVE_IN_TEST, false);
101102
d = DriverFactory.newDriver(hiveConf);
102103

103104
wh = new File(System.getProperty("java.io.tmpdir") + File.separator +
@@ -110,7 +111,6 @@ public void setUp() throws Exception {
110111

111112
MetastoreConf.setVar(hiveConf, ConfVars.METASTORE_METADATA_TRANSFORMER_CLASS,
112113
"org.apache.hadoop.hive.metastore.MetastoreDefaultTransformer");
113-
MetastoreConf.setBoolVar(hiveConf, ConfVars.HIVE_IN_TEST, false);
114114
MetastoreConf.setVar(hiveConf, ConfVars.WAREHOUSE, wh.getCanonicalPath());
115115
MetastoreConf.setVar(hiveConf, ConfVars.WAREHOUSE_EXTERNAL, ext_wh.getCanonicalPath());
116116
MetastoreConf.setBoolVar(hiveConf, MetastoreConf.ConfVars.CREATE_TABLES_AS_ACID, true);

itests/util/src/main/java/org/apache/hadoop/hive/ql/QTestUtil.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@
5555
import org.apache.hadoop.hive.common.io.QTestFetchConverter;
5656
import org.apache.hadoop.hive.conf.HiveConf;
5757
import org.apache.hadoop.hive.conf.HiveConf.ConfVars;
58+
import org.apache.hadoop.hive.metastore.api.Database;
59+
import org.apache.hadoop.hive.metastore.api.DatabaseType;
60+
import org.apache.hadoop.hive.metastore.api.GetDatabaseObjectsRequest;
61+
import org.apache.hadoop.hive.metastore.api.GetDatabaseObjectsResponse;
5862
import org.apache.hadoop.hive.ql.metadata.HiveMetaStoreClientWithLocalCache;
5963
import org.apache.hadoop.hive.metastore.conf.MetastoreConf;
6064
import org.apache.hadoop.hive.ql.QTestMiniClusters.FsType;
@@ -355,6 +359,31 @@ public void clearUDFsCreatedDuringTests() throws Exception {
355359
}
356360
}
357361

362+
public void clearConnectorsCreatedInTests() throws Exception {
363+
if (System.getenv(QTEST_LEAVE_FILES) != null) {
364+
return;
365+
}
366+
conf.set("hive.metastore.filter.hook", "org.apache.hadoop.hive.metastore.DefaultMetaStoreFilterHookImpl");
367+
db = Hive.get(conf);
368+
369+
GetDatabaseObjectsRequest request = new GetDatabaseObjectsRequest();
370+
request.setPattern("*");
371+
GetDatabaseObjectsResponse response = db.getMSC().get_databases_req(request);
372+
if (response != null && response.getDatabasesSize() > 0) {
373+
for (Database database : response.getDatabases()) {
374+
if (database.getType() == DatabaseType.REMOTE) {
375+
db.dropDatabase(database.getName(), true, true);
376+
}
377+
}
378+
}
379+
List<String> connectors = db.getAllDataConnectorNames();
380+
if (connectors != null) {
381+
for (String connectorName : connectors) {
382+
db.dropDataConnector(connectorName, true);
383+
}
384+
}
385+
}
386+
358387
/**
359388
* Clear out any side effects of running tests
360389
*/
@@ -482,6 +511,7 @@ public void clearTestSideEffects() throws Exception {
482511
Utilities.clearWorkMap(conf);
483512
NotificationEventPoll.shutdown();
484513
QueryResultsCache.cleanupInstance();
514+
clearConnectorsCreatedInTests();
485515
clearTablesCreatedDuringTests();
486516
clearUDFsCreatedDuringTests();
487517
clearKeysCreatedInTests();

0 commit comments

Comments
 (0)