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.util;
019
020import static org.junit.Assert.assertEquals;
021import static org.junit.Assert.assertFalse;
022
023import org.apache.hadoop.hbase.HBaseClassTestRule;
024import org.apache.hadoop.hbase.HBaseTestingUtil;
025import org.apache.hadoop.hbase.TableName;
026import org.apache.hadoop.hbase.replication.ReplicationStorageFactory;
027import org.apache.hadoop.hbase.testclassification.MediumTests;
028import org.apache.hadoop.hbase.testclassification.MiscTests;
029import org.apache.hadoop.hbase.util.hbck.HbckTestingUtil;
030import org.junit.After;
031import org.junit.Before;
032import org.junit.ClassRule;
033import org.junit.Test;
034import org.junit.experimental.categories.Category;
035import org.junit.rules.TestName;
036
037@Category({ MiscTests.class, MediumTests.class })
038public class TestHBaseFsckWithoutTableHbaseReplication {
039
040  @ClassRule
041  public static final HBaseClassTestRule CLASS_RULE =
042    HBaseClassTestRule.forClass(TestHBaseFsckWithoutTableHbaseReplication.class);
043
044  @ClassRule
045  public static final TestName name = new TestName();
046
047  private static final HBaseTestingUtil UTIL = new HBaseTestingUtil();
048  private static final TableName tableName =
049    TableName.valueOf("replication_" + name.getMethodName());
050
051  @Before
052  public void setUp() throws Exception {
053    UTIL.getConfiguration().setBoolean("hbase.write.hbck1.lock.file", false);
054    UTIL.getConfiguration().set(ReplicationStorageFactory.REPLICATION_QUEUE_TABLE_NAME,
055      tableName.getNameAsString());
056    UTIL.startMiniCluster(1);
057  }
058
059  @After
060  public void tearDown() throws Exception {
061    UTIL.shutdownMiniCluster();
062  }
063
064  @Test
065  public void test() throws Exception {
066    assertFalse(UTIL.getAdmin().tableExists(tableName));
067    HBaseFsck hBaseFsck = HbckTestingUtil.doFsck(UTIL.getConfiguration(), true);
068    assertEquals(0, hBaseFsck.getRetCode());
069  }
070}