soumyakanti3578 commented on code in PR #6636: URL: https://github.com/apache/hive/pull/6636#discussion_r3686723864
########## standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/tools/schematool/TestRebuildIndexesScriptConsistency.java: ########## @@ -0,0 +1,174 @@ +/* + * 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.tools.schematool; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.hive.metastore.IMetaStoreSchemaInfo; +import org.apache.hadoop.hive.metastore.MetaStoreSchemaInfoFactory; +import org.apache.hadoop.hive.metastore.annotation.MetastoreUnitTest; +import org.junit.Test; +import org.junit.experimental.categories.Category; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +@Category(MetastoreUnitTest.class) +@RunWith(Parameterized.class) +public class TestRebuildIndexesScriptConsistency { Review Comment: Yes, that is exactly what's being tested in `rebuildScriptMatchesInitScript()` ``` Pattern pattern = PATTERNS.get(dbType); Set<String> initIndexes = extractIndexNames(schemaScript, pattern); Set<String> rebuildIndexes = extractIndexNames(rebuildScript, pattern); Set<String> missing = new HashSet<>(initIndexes); missing.removeAll(rebuildIndexes); Set<String> extra = new HashSet<>(rebuildIndexes); extra.removeAll(initIndexes); assertTrue("Indexes in init script missing from rebuild script: " + missing, missing.isEmpty()); assertTrue("Indexes in rebuild script not found in init script: " + extra, extra.isEmpty()); ``` and it tests extra indexes in the rebuild scripts too, so devs can remember to remove them if we ever remove an index from the schema file. -- 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]
