taklwu commented on a change in pull request #2931: URL: https://github.com/apache/hbase/pull/2931#discussion_r585188596
########## File path: hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestPersistedStoreEngine.java ########## @@ -0,0 +1,152 @@ +/* + * 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.hbase.regionserver; + +import static org.hamcrest.core.Is.isA; +import static org.junit.Assert.assertEquals; +import java.io.IOException; +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.hbase.CellComparator; +import org.apache.hadoop.hbase.CellComparatorImpl; +import org.apache.hadoop.hbase.HBaseClassTestRule; +import org.apache.hadoop.hbase.HBaseTestingUtility; +import org.apache.hadoop.hbase.HConstants; +import org.apache.hadoop.hbase.TableName; +import org.apache.hadoop.hbase.client.RegionInfoBuilder; +import org.apache.hadoop.hbase.client.Table; +import org.apache.hadoop.hbase.client.TableDescriptor; +import org.apache.hadoop.hbase.testclassification.MediumTests; +import org.apache.hadoop.hbase.testclassification.RegionServerTests; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.ClassRule; +import org.junit.Rule; +import org.junit.Test; +import org.junit.experimental.categories.Category; +import org.junit.rules.ExpectedException; +import org.junit.rules.TestName; +import org.mockito.Mockito; + +@Category({ RegionServerTests.class, MediumTests.class }) +public class TestPersistedStoreEngine { + + @ClassRule + public static final HBaseClassTestRule CLASS_RULE = + HBaseClassTestRule.forClass(TestPersistedStoreEngine.class); + + @Rule + public TestName name = new TestName(); + + @Rule + public ExpectedException expectedException = ExpectedException.none(); + + private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility(); + private static final byte[] DEFAULT_STORE_BYTE = TEST_UTIL.fam1; + + private TableName tableName; + private Configuration conf; + private HStore store; + + @BeforeClass + public static void setUpCluster() throws Exception { + TEST_UTIL.getConfiguration().setBoolean(HConstants.STOREFILE_TRACKING_PERSIST_ENABLED, true); + TEST_UTIL.getConfiguration().set(StoreEngine.STORE_ENGINE_CLASS_KEY, + PersistedStoreEngine.class.getName()); + TEST_UTIL.startMiniCluster(); + } + + @Before + public void setup() throws Exception { + store = Mockito.mock(HStore.class); + StoreContext context = new StoreContext.Builder().build(); + + conf = TEST_UTIL.getConfiguration(); + Mockito.when(store.getStoreContext()).thenReturn(context); + Mockito.when(store.getRegionInfo()).thenReturn(RegionInfoBuilder.FIRST_META_REGIONINFO); + } + + @After + public void tearDown() throws Exception { + for (TableDescriptor htd: TEST_UTIL.getAdmin().listTableDescriptors()) { + TEST_UTIL.deleteTable(htd.getTableName()); + } + } + + @AfterClass + public static void tearDownAfterClass() throws Exception { + // use killMiniHBaseCluster before shutdownMiniCluster because shutdownMiniCluster puts a RS + // that host hbase:meta to a stopped state that prevents meta lookup the table state of + // hbase:storefile and hangs the last write to hbase:storefile when any tracking region closes. + // + // this should be rarely happened on a real cluster and RS with meta table should be the last + // to be shutdown normally. + TEST_UTIL.killMiniHBaseCluster(); Review comment: sorry, we can remove this now. it was something old from my local branch that tried to write one last record for compactedFiles to `hbase:storefile` table, but we have simplified the logic in this commit that only storefiles are being tracked. The test here has already flushed and should not have any new update to the table `hbase:storefile` when closing. if we merge into hbase:meta (will be done in HBASE-25397) , this will definitely not a issue anymore as well. ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: [email protected]
