Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions itests/util/src/main/java/org/apache/hadoop/hive/ql/QTestUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@
import org.apache.hadoop.hive.common.io.QTestFetchConverter;
import org.apache.hadoop.hive.conf.HiveConf;
import org.apache.hadoop.hive.conf.HiveConf.ConfVars;
import org.apache.hadoop.hive.metastore.api.Database;
import org.apache.hadoop.hive.metastore.api.DatabaseType;
import org.apache.hadoop.hive.metastore.api.GetDatabaseObjectsRequest;
import org.apache.hadoop.hive.metastore.api.GetDatabaseObjectsResponse;
import org.apache.hadoop.hive.ql.metadata.HiveMetaStoreClientWithLocalCache;
import org.apache.hadoop.hive.metastore.conf.MetastoreConf;
import org.apache.hadoop.hive.ql.QTestMiniClusters.FsType;
Expand Down Expand Up @@ -355,6 +359,31 @@ public void clearUDFsCreatedDuringTests() throws Exception {
}
}

public void clearConnectorsCreatedInTests() throws Exception {
if (System.getenv(QTEST_LEAVE_FILES) != null) {
return;
}
conf.set("hive.metastore.filter.hook", "org.apache.hadoop.hive.metastore.DefaultMetaStoreFilterHookImpl");
db = Hive.get(conf);

GetDatabaseObjectsRequest request = new GetDatabaseObjectsRequest();
request.setPattern("*");
GetDatabaseObjectsResponse response = db.getMSC().get_databases_req(request);
if (response != null && response.getDatabasesSize() > 0) {
for (Database database : response.getDatabases()) {
if (database.getType() == DatabaseType.REMOTE) {
db.dropDatabase(database.getName(), true, true);
}
}
}
List<String> connectors = db.getAllDataConnectorNames();
if (connectors != null) {
for (String connectorName : connectors) {
db.dropDataConnector(connectorName, true);
}
}
}

/**
* Clear out any side effects of running tests
*/
Expand Down Expand Up @@ -482,6 +511,7 @@ public void clearTestSideEffects() throws Exception {
Utilities.clearWorkMap(conf);
NotificationEventPoll.shutdown();
QueryResultsCache.cleanupInstance();
clearConnectorsCreatedInTests();
clearTablesCreatedDuringTests();
clearUDFsCreatedDuringTests();
clearKeysCreatedInTests();
Expand Down
Loading
Loading