001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018package org.apache.hadoop.hbase.procedure2.store.region; 019 020import java.io.IOException; 021import org.apache.hadoop.conf.Configuration; 022import org.apache.hadoop.fs.Path; 023import org.apache.hadoop.hbase.HBaseCommonTestingUtility; 024import org.apache.hadoop.hbase.Server; 025import org.apache.hadoop.hbase.master.region.MasterRegion; 026import org.apache.hadoop.hbase.master.region.MasterRegionFactory; 027import org.apache.hadoop.hbase.procedure2.ProcedureTestingUtility.LoadCounter; 028import org.apache.hadoop.hbase.regionserver.MemStoreLAB; 029import org.apache.hadoop.hbase.util.CommonFSUtils; 030import org.junit.After; 031import org.junit.Before; 032 033/** 034 * This runs on local filesystem. hsync and hflush are not supported. May lose data! Only use where 035 * data loss is not of consequence. 036 */ 037public class RegionProcedureStoreTestBase { 038 039 protected HBaseCommonTestingUtility htu; 040 041 protected MasterRegion region; 042 043 protected RegionProcedureStore store; 044 045 @Before 046 public void setUp() throws IOException { 047 htu = new HBaseCommonTestingUtility(); 048 Configuration conf = htu.getConfiguration(); 049 conf.setBoolean(MemStoreLAB.USEMSLAB_KEY, false); 050 // Runs on local filesystem. Test does not need sync. Turn off checks. 051 conf.setBoolean(CommonFSUtils.UNSAFE_STREAM_CAPABILITY_ENFORCE, false); 052 Path testDir = htu.getDataTestDir(); 053 CommonFSUtils.setRootDir(htu.getConfiguration(), testDir); 054 Server server = RegionProcedureStoreTestHelper.mockServer(conf); 055 region = MasterRegionFactory.create(server); 056 store = RegionProcedureStoreTestHelper.createStore(server, region, new LoadCounter()); 057 } 058 059 @After 060 public void tearDown() throws IOException { 061 store.stop(true); 062 region.close(true); 063 htu.cleanupTestDir(); 064 } 065}