-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Hive: Refactor HiveCatalog tests to use the core CatalogTests
- Loading branch information
Showing
7 changed files
with
155 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
hive-metastore/src/test/java/org/apache/iceberg/hive/HiveMetastoreSetup.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.iceberg.hive; | ||
|
||
import java.util.Map; | ||
import java.util.concurrent.TimeUnit; | ||
import org.apache.hadoop.hive.conf.HiveConf; | ||
import org.apache.hadoop.hive.metastore.HiveMetaStoreClient; | ||
import org.apache.iceberg.CatalogProperties; | ||
import org.apache.iceberg.CatalogUtil; | ||
import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap; | ||
|
||
/** | ||
* Setup HiveMetastore. It does not create any database. All the tests should create a database | ||
* accordingly. it should replace the existing setUp class {@link HiveMetastoreTest} | ||
*/ | ||
class HiveMetastoreSetup { | ||
|
||
private HiveMetaStoreClient metastoreClient; | ||
private TestHiveMetastore metastore; | ||
HiveCatalog catalog; | ||
|
||
HiveMetastoreSetup(Map<String, String> hiveConfOverride) throws Exception { | ||
metastore = new TestHiveMetastore(); | ||
HiveConf hiveConfWithOverrides = new HiveConf(TestHiveMetastore.class); | ||
if (hiveConfOverride != null) { | ||
for (Map.Entry<String, String> kv : hiveConfOverride.entrySet()) { | ||
hiveConfWithOverrides.set(kv.getKey(), kv.getValue()); | ||
} | ||
} | ||
|
||
metastore.start(hiveConfWithOverrides); | ||
metastoreClient = new HiveMetaStoreClient(hiveConfWithOverrides); | ||
catalog = | ||
(HiveCatalog) | ||
CatalogUtil.loadCatalog( | ||
HiveCatalog.class.getName(), | ||
CatalogUtil.ICEBERG_CATALOG_TYPE_HIVE, | ||
ImmutableMap.of( | ||
CatalogProperties.CLIENT_POOL_CACHE_EVICTION_INTERVAL_MS, | ||
String.valueOf(TimeUnit.SECONDS.toMillis(10))), | ||
hiveConfWithOverrides); | ||
} | ||
|
||
void stopMetastore() throws Exception { | ||
try { | ||
metastoreClient.close(); | ||
metastore.stop(); | ||
} finally { | ||
catalog = null; | ||
metastoreClient = null; | ||
metastore = null; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
hive-metastore/src/test/java/org/apache/iceberg/hive/TestHiveCatalogNew.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.apache.iceberg.hive; | ||
|
||
import java.util.Collections; | ||
import org.apache.iceberg.catalog.CatalogTests; | ||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.BeforeEach; | ||
|
||
/** | ||
* Run all the tests from abstract of {@link CatalogTests} It should replace the other tests classes | ||
* like {@link TestHiveCatalog} | ||
*/ | ||
public class TestHiveCatalogNew extends CatalogTests<HiveCatalog> { | ||
|
||
private HiveMetastoreSetup hiveMetastoreSetup; | ||
|
||
@BeforeEach | ||
public void before() throws Exception { | ||
hiveMetastoreSetup = new HiveMetastoreSetup(Collections.emptyMap()); | ||
} | ||
|
||
@AfterEach | ||
public void after() throws Exception { | ||
hiveMetastoreSetup.stopMetastore(); | ||
} | ||
|
||
@Override | ||
protected boolean requiresNamespaceCreate() { | ||
return true; | ||
} | ||
|
||
@Override | ||
protected boolean supportsNamesWithSlashes() { | ||
return false; | ||
} | ||
|
||
@Override | ||
protected boolean supportsNamesWithDot() { | ||
return false; | ||
} | ||
|
||
@Override | ||
protected HiveCatalog catalog() { | ||
return hiveMetastoreSetup.catalog; | ||
} | ||
} |