View Javadoc

1   /**
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *     http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  
19  package org.apache.hadoop.hbase.backup;
20  
21  import java.util.List;
22  
23  import org.apache.commons.logging.Log;
24  import org.apache.commons.logging.LogFactory;
25  import org.apache.hadoop.hbase.DoNotRetryIOException;
26  import org.apache.hadoop.hbase.TableName;
27  import org.apache.hadoop.hbase.testclassification.LargeTests;
28  import org.junit.Test;
29  import org.junit.experimental.categories.Category;
30  
31  import com.google.common.collect.Lists;
32  
33  @Category(LargeTests.class)
34  public class TestBackupBoundaryTests extends TestBackupBase {
35  
36    private static final Log LOG = LogFactory.getLog(TestBackupBoundaryTests.class);
37  
38    /**
39     * Verify that full backup is created on a single empty table correctly.
40     * @throws Exception
41     */
42    @Test
43    public void testFullBackupSingleEmpty() throws Exception {
44  
45      LOG.info("create full backup image on single table");
46      List<TableName> tables = Lists.newArrayList(table3);
47      LOG.info("Finished Backup " + fullTableBackup(tables));
48    }
49  
50    /**
51     * Verify that full backup is created on multiple empty tables correctly.
52     * @throws Exception
53     */
54    @Test
55    public void testFullBackupMultipleEmpty() throws Exception {
56      LOG.info("create full backup image on mulitple empty tables");
57  
58      List<TableName> tables = Lists.newArrayList(table3, table4);
59      fullTableBackup(tables);
60    }
61  
62    /**
63     * Verify that full backup fails on a single table that does not exist.
64     * @throws Exception
65     */
66    @Test(expected = DoNotRetryIOException.class)
67    public void testFullBackupSingleDNE() throws Exception {
68  
69      LOG.info("test full backup fails on a single table that does not exist");
70      List<TableName> tables = toList("tabledne");
71      fullTableBackup(tables);
72    }
73  
74    /**
75     * Verify that full backup fails on multiple tables that do not exist.
76     * @throws Exception
77     */
78    @Test(expected = DoNotRetryIOException.class)
79    public void testFullBackupMultipleDNE() throws Exception {
80  
81      LOG.info("test full backup fails on multiple tables that do not exist");
82      List<TableName> tables = toList("table1dne", "table2dne");
83      fullTableBackup(tables);
84    }
85  
86    /**
87     * Verify that full backup fails on tableset containing real and fake tables.
88     * @throws Exception
89     */
90    @Test(expected = DoNotRetryIOException.class)
91    public void testFullBackupMixExistAndDNE() throws Exception {
92      LOG.info("create full backup fails on tableset containing real and fake table");
93  
94      List<TableName> tables = toList(table1.getNameAsString(), "tabledne");
95      fullTableBackup(tables);
96    }
97  }