1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.hadoop.hbase.backup;
20
21 import static org.junit.Assert.assertTrue;
22
23 import java.util.List;
24
25 import org.apache.commons.logging.Log;
26 import org.apache.commons.logging.LogFactory;
27 import org.apache.hadoop.hbase.TableName;
28 import org.apache.hadoop.hbase.client.HBaseAdmin;
29 import org.apache.hadoop.hbase.testclassification.LargeTests;
30 import org.junit.Test;
31 import org.junit.experimental.categories.Category;
32
33 @Category(LargeTests.class)
34 public class TestRestoreBoundaryTests extends TestBackupBase {
35
36 private static final Log LOG = LogFactory.getLog(TestRestoreBoundaryTests.class);
37
38
39
40
41
42 @Test
43 public void testFullRestoreSingleEmpty() throws Exception {
44 LOG.info("test full restore on a single table empty table");
45 String backupId = fullTableBackup(toList(table1.getNameAsString()));
46 LOG.info("backup complete");
47 TableName[] tableset = new TableName[] { table1 };
48 TableName[] tablemap = new TableName[] { table1_restore };
49 getBackupAdmin().restore(createRestoreRequest(BACKUP_ROOT_DIR, backupId, false, tableset, tablemap,
50 false));
51 HBaseAdmin hba = TEST_UTIL.getHBaseAdmin();
52 assertTrue(hba.tableExists(table1_restore));
53 TEST_UTIL.deleteTable(table1_restore);
54 }
55
56
57
58
59
60 @Test
61 public void testFullRestoreMultipleEmpty() throws Exception {
62 LOG.info("create full backup image on multiple tables");
63
64 List<TableName> tables = toList(table2.getNameAsString(), table3.getNameAsString());
65 String backupId = fullTableBackup(tables);
66 TableName[] restore_tableset = new TableName[] { table2, table3};
67 TableName[] tablemap = new TableName[] { table2_restore, table3_restore };
68 getBackupAdmin().restore(createRestoreRequest(BACKUP_ROOT_DIR, backupId, false, restore_tableset,
69 tablemap,
70 false));
71 HBaseAdmin hba = TEST_UTIL.getHBaseAdmin();
72 assertTrue(hba.tableExists(table2_restore));
73 assertTrue(hba.tableExists(table3_restore));
74 TEST_UTIL.deleteTable(table2_restore);
75 TEST_UTIL.deleteTable(table3_restore);
76 }
77 }