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.backup;
019
020import java.io.IOException;
021import java.util.List;
022import org.apache.hadoop.hbase.HBaseClassTestRule;
023import org.apache.hadoop.hbase.TableName;
024import org.apache.hadoop.hbase.testclassification.LargeTests;
025import org.junit.ClassRule;
026import org.junit.Test;
027import org.junit.experimental.categories.Category;
028import org.slf4j.Logger;
029import org.slf4j.LoggerFactory;
030
031import org.apache.hbase.thirdparty.com.google.common.collect.Lists;
032
033@Category(LargeTests.class)
034public class TestBackupBoundaryTests extends TestBackupBase {
035
036  @ClassRule
037  public static final HBaseClassTestRule CLASS_RULE =
038    HBaseClassTestRule.forClass(TestBackupBoundaryTests.class);
039
040  private static final Logger LOG = LoggerFactory.getLogger(TestBackupBoundaryTests.class);
041
042  /**
043   * Verify that full backup is created on a single empty table correctly.
044   * @throws Exception if doing the full backup fails
045   */
046  @Test
047  public void testFullBackupSingleEmpty() throws Exception {
048    LOG.info("create full backup image on single table");
049    List<TableName> tables = Lists.newArrayList(table3);
050    LOG.info("Finished Backup " + fullTableBackup(tables));
051  }
052
053  /**
054   * Verify that full backup is created on multiple empty tables correctly.
055   * @throws Exception if doing the full backup fails
056   */
057  @Test
058  public void testFullBackupMultipleEmpty() throws Exception {
059    LOG.info("create full backup image on mulitple empty tables");
060
061    List<TableName> tables = Lists.newArrayList(table3, table4);
062    fullTableBackup(tables);
063  }
064
065  /**
066   * Verify that full backup fails on a single table that does not exist.
067   * @throws Exception if doing the full backup fails
068   */
069  @Test(expected = IOException.class)
070  public void testFullBackupSingleDNE() throws Exception {
071    LOG.info("test full backup fails on a single table that does not exist");
072    List<TableName> tables = toList("tabledne");
073    fullTableBackup(tables);
074  }
075
076  /**
077   * Verify that full backup fails on multiple tables that do not exist.
078   * @throws Exception if doing the full backup fails
079   */
080  @Test(expected = IOException.class)
081  public void testFullBackupMultipleDNE() throws Exception {
082    LOG.info("test full backup fails on multiple tables that do not exist");
083    List<TableName> tables = toList("table1dne", "table2dne");
084    fullTableBackup(tables);
085  }
086
087  /**
088   * Verify that full backup fails on tableset containing real and fake tables.
089   * @throws Exception if doing the full backup fails
090   */
091  @Test(expected = IOException.class)
092  public void testFullBackupMixExistAndDNE() throws Exception {
093    LOG.info("create full backup fails on tableset containing real and fake table");
094
095    List<TableName> tables = toList(table1.getNameAsString(), "tabledne");
096    fullTableBackup(tables);
097  }
098}