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   *
045   * @throws Exception if doing the full backup fails
046   */
047  @Test
048  public void testFullBackupSingleEmpty() throws Exception {
049    LOG.info("create full backup image on single table");
050    List<TableName> tables = Lists.newArrayList(table3);
051    LOG.info("Finished Backup " + fullTableBackup(tables));
052  }
053
054  /**
055   * Verify that full backup is created on multiple empty tables correctly.
056   *
057   * @throws Exception if doing the full backup fails
058   */
059  @Test
060  public void testFullBackupMultipleEmpty() throws Exception {
061    LOG.info("create full backup image on mulitple empty tables");
062
063    List<TableName> tables = Lists.newArrayList(table3, table4);
064    fullTableBackup(tables);
065  }
066
067  /**
068   * Verify that full backup fails on a single table that does not exist.
069   *
070   * @throws Exception if doing the full backup fails
071   */
072  @Test(expected = IOException.class)
073  public void testFullBackupSingleDNE() throws Exception {
074    LOG.info("test full backup fails on a single table that does not exist");
075    List<TableName> tables = toList("tabledne");
076    fullTableBackup(tables);
077  }
078
079  /**
080   * Verify that full backup fails on multiple tables that do not exist.
081   *
082   * @throws Exception if doing the full backup fails
083   */
084  @Test(expected = IOException.class)
085  public void testFullBackupMultipleDNE() throws Exception {
086    LOG.info("test full backup fails on multiple tables that do not exist");
087    List<TableName> tables = toList("table1dne", "table2dne");
088    fullTableBackup(tables);
089  }
090
091  /**
092   * Verify that full backup fails on tableset containing real and fake tables.
093   *
094   * @throws Exception if doing the full backup fails
095   */
096  @Test(expected = IOException.class)
097  public void testFullBackupMixExistAndDNE() throws Exception {
098    LOG.info("create full backup fails on tableset containing real and fake table");
099
100    List<TableName> tables = toList(table1.getNameAsString(), "tabledne");
101    fullTableBackup(tables);
102  }
103}