zabetak commented on code in PR #6371: URL: https://github.com/apache/hive/pull/6371#discussion_r3000745924
########## standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/utils/TestMetastoreUtilsParseDbName.java: ########## @@ -0,0 +1,65 @@ +/* + * 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.hadoop.hive.metastore.utils; + +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.hive.metastore.annotation.MetastoreUnitTest; +import org.apache.hadoop.hive.metastore.conf.MetastoreConf; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +import static org.apache.hadoop.hive.metastore.utils.MetaStoreUtils.parseDbName; +import static org.junit.Assert.assertArrayEquals; + +@Category(MetastoreUnitTest.class) +public class TestMetastoreUtilsParseDbName { + + @Test + public void testParseDbNameEdgeCases() { + Configuration conf = MetastoreConf.newMetastoreConf(); + MetastoreConf.setVar(conf, MetastoreConf.ConfVars.CATALOG_DEFAULT, "hive"); + + assertArrayEquals(new String[]{"hive", "@"}, parseDbName("@", conf)); + assertArrayEquals(new String[]{"hive", "@!"}, parseDbName("@!", conf)); + assertArrayEquals(new String[]{"", null}, parseDbName("@#", conf)); + assertArrayEquals(new String[]{"", "db1"}, parseDbName("@#db1", conf)); + assertArrayEquals(new String[]{"cat1", null}, parseDbName("@cat1", conf)); + assertArrayEquals(new String[]{"cat1", null}, parseDbName("@cat1#", conf)); + assertArrayEquals(new String[]{"cat1", ""}, parseDbName("@cat1#!", conf)); + assertArrayEquals(new String[]{"cat1", "@db1"}, parseDbName("@cat1#@db1", conf)); + assertArrayEquals(new String[]{"cat1", "#db1"}, parseDbName("@cat1##db1", conf)); + assertArrayEquals(new String[]{"cat1", "db1"}, parseDbName("@cat1#db1", conf)); + assertArrayEquals(new String[]{"cat1", "db1!"}, parseDbName("@cat1#db1!", conf)); + assertArrayEquals(new String[]{"cat1!", null}, parseDbName("@cat1!", conf)); + assertArrayEquals(new String[]{"hive", "#db1"}, parseDbName("#db1", conf)); + assertArrayEquals(new String[]{"hive", "#!"}, parseDbName("#!", conf)); + assertArrayEquals(new String[]{"hive", "#"}, parseDbName("#", conf)); Review Comment: All these test cases are duplicated below and some even contradict each other. This test is probably not passing as it is. As a side note keep in mind that CI resources are limited so be mindful about pushing things in the PR that are guaranteed to fail. ########## standalone-metastore/metastore-server/pom.xml: ########## @@ -492,6 +471,12 @@ <artifactId>keycloak-admin-client</artifactId> <scope>test</scope> </dependency> + <dependency> + <groupId>uk.org.webcompere</groupId> + <artifactId>system-stubs-core</artifactId> + <version>1.2.0</version> + <scope>test</scope> + </dependency> Review Comment: Please revert all the changes here or clarify why they are needed. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
