diff --git standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/MetaStoreFactoryForTests.java standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/MetaStoreFactoryForTests.java index e2b1a68..e723f60 100644 --- standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/MetaStoreFactoryForTests.java +++ standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/MetaStoreFactoryForTests.java @@ -34,9 +34,11 @@ * {@link org.apache.hadoop.hive.metastore.minihms.AbstractMetaStoreService} implementations for * tests. */ -public class MetaStoreFactoryForTests { +public final class MetaStoreFactoryForTests { private static final int DEFAULT_LIMIT_PARTITION_REQUEST = 100; + private MetaStoreFactoryForTests() {} + /** * We would like to run the tests with 2 MetaStore configurations * - Embedded - Where the MetaStore is running in the same thread, and does not use Thrift @@ -94,7 +96,7 @@ .setConf(conf) .setType(MiniHMS.MiniHMSType.EMBEDDED) .build(); - metaStores.add(new Object[] { "Embedded", embedded}); + metaStores.add(new Object[] {"Embedded", embedded}); // Create Remote MetaStore conf.set("javax.jdo.option.ConnectionURL", @@ -104,7 +106,7 @@ .setConf(conf) .setType(MiniHMS.MiniHMSType.REMOTE) .build(); - metaStores.add(new Object[] { "Remote", remote}); + metaStores.add(new Object[] {"Remote", remote}); return metaStores; } diff --git standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestDatabases.java standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestDatabases.java index fe7e0e4..db80072 100644 --- standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestDatabases.java +++ standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/TestDatabases.java @@ -52,6 +52,9 @@ import java.util.Set; import java.util.stream.Collectors; +/** + * Test class for IMetaStoreClient API. Testing the Database related functions. + */ @RunWith(Parameterized.class) public class TestDatabases { private static final Logger LOG = LoggerFactory.getLogger(TestDatabases.class); @@ -408,7 +411,7 @@ public void testDropDatabaseWithFunctionCascade() throws Exception { } /** - * Creates an index in the given database for testing purposes + * Creates an index in the given database for testing purposes. * @param databaseName The database name in which the index should be creatd * @throws TException If there is an error during the index creation */ diff --git standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/package-info.java standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/package-info.java new file mode 100644 index 0000000..6adc7b8 --- /dev/null +++ standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/client/package-info.java @@ -0,0 +1,22 @@ +/* + * 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. + */ + +/** + * This package contains test and utility classes for IMetaStoreClient API tests. + */ +package org.apache.hadoop.hive.metastore.client; diff --git standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/minihms/AbstractMetaStoreService.java standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/minihms/AbstractMetaStoreService.java index ef74dd7..3246877 100644 --- standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/minihms/AbstractMetaStoreService.java +++ standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/minihms/AbstractMetaStoreService.java @@ -38,7 +38,7 @@ * configurations. */ public abstract class AbstractMetaStoreService { - protected Configuration configuration; + private Configuration configuration; private Warehouse warehouse; private FileSystem warehouseRootFs; private Path trashDir; @@ -48,6 +48,14 @@ public AbstractMetaStoreService(Configuration configuration) { } /** + * Returns the actual configuration of the MetaStore. + * @return The actual configuration + */ + protected Configuration getConfiguration() { + return configuration; + } + + /** * Starts the MetaStoreService. Be aware, as the current MetaStore does not implement clean * shutdown, starting MetaStoreService is possible only once per test. * @@ -72,8 +80,7 @@ public void start() throws Exception { * @throws Exception if any Exception occurs */ public void start(Map metastoreOverlay, - Map configurationOverlay) throws Exception - { + Map configurationOverlay) throws Exception { // Set metastoreOverlay parameters for (Map.Entry entry : metastoreOverlay.entrySet()) { MetastoreConf.setVar(configuration, entry.getKey(), entry.getValue()); diff --git standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/minihms/EmbeddedMetaStoreForTests.java standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/minihms/EmbeddedMetaStoreForTests.java index 1fafe97..518a65c 100644 --- standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/minihms/EmbeddedMetaStoreForTests.java +++ standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/minihms/EmbeddedMetaStoreForTests.java @@ -30,4 +30,4 @@ public EmbeddedMetaStoreForTests(Configuration configuration) { super(configuration); } -} \ No newline at end of file +} diff --git standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/minihms/MiniHMS.java standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/minihms/MiniHMS.java index 88db493..0b2e4d1 100644 --- standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/minihms/MiniHMS.java +++ standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/minihms/MiniHMS.java @@ -31,12 +31,18 @@ * so the same tests could be run against a real cluster */ public class MiniHMS { + /** + * The possible MetaStore types. + */ public enum MiniHMSType { EMBEDDED, REMOTE, CLUSTER } + /** + * Builder for creating a Mini MetaStore object. + */ public static class Builder { private Configuration metaStoreConf = MetastoreConf.newMetastoreConf(); private MiniHMSType miniHMSType = MiniHMSType.EMBEDDED; @@ -56,14 +62,14 @@ public Builder setType(MiniHMSType type) { public AbstractMetaStoreService build() throws Exception { switch (miniHMSType) { - case REMOTE: - return new RemoteMetaStoreForTests(metaStoreConf); - case EMBEDDED: - return new EmbeddedMetaStoreForTests(metaStoreConf); - case CLUSTER: - return new ClusterMetaStoreForTests(metaStoreConf); - default: - throw new IllegalArgumentException("Unexpected miniHMSType: " + miniHMSType); + case REMOTE: + return new RemoteMetaStoreForTests(metaStoreConf); + case EMBEDDED: + return new EmbeddedMetaStoreForTests(metaStoreConf); + case CLUSTER: + return new ClusterMetaStoreForTests(metaStoreConf); + default: + throw new IllegalArgumentException("Unexpected miniHMSType: " + miniHMSType); } } } diff --git standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/minihms/RemoteMetaStoreForTests.java standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/minihms/RemoteMetaStoreForTests.java index 5752414..4249991 100644 --- standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/minihms/RemoteMetaStoreForTests.java +++ standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/minihms/RemoteMetaStoreForTests.java @@ -35,9 +35,11 @@ public RemoteMetaStoreForTests(Configuration configuration) { } public void start() throws Exception { - MetastoreConf.setBoolVar(configuration, MetastoreConf.ConfVars.EXECUTE_SET_UGI, false); - int port = MetaStoreTestUtils.startMetaStore(HadoopThriftAuthBridge.getBridge(), configuration); - MetastoreConf.setVar(configuration, MetastoreConf.ConfVars.THRIFT_URIS, "thrift://localhost:" + port); + MetastoreConf.setBoolVar(getConfiguration(), MetastoreConf.ConfVars.EXECUTE_SET_UGI, false); + int port = MetaStoreTestUtils.startMetaStore(HadoopThriftAuthBridge.getBridge(), + getConfiguration()); + MetastoreConf.setVar(getConfiguration(), MetastoreConf.ConfVars.THRIFT_URIS, + "thrift://localhost:" + port); super.start(); } -} \ No newline at end of file +} diff --git standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/minihms/package-info.java standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/minihms/package-info.java new file mode 100644 index 0000000..9e05d31 --- /dev/null +++ standalone-metastore/src/test/java/org/apache/hadoop/hive/metastore/minihms/package-info.java @@ -0,0 +1,23 @@ +/* + * 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. + */ + +/** + * This package contains test and utility classes for creating MetaStore instances for test + * purposes. + */ +package org.apache.hadoop.hive.metastore.minihms;