View Javadoc

1   /**
2    * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
3    * agreements. See the NOTICE file distributed with this work for additional information regarding
4    * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the
5    * "License"); you may not use this file except in compliance with the License. You may obtain a
6    * copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable
7    * law or agreed to in writing, software distributed under the License is distributed on an "AS IS"
8    * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
9    * for the specific language governing permissions and limitations under the License.
10   */
11  
12  package org.apache.hadoop.hbase.backup;
13  
14  import static org.junit.Assert.assertTrue;
15  
16  import org.apache.commons.logging.Log;
17  import org.apache.commons.logging.LogFactory;
18  import org.apache.hadoop.hbase.TableName;
19  import org.apache.hadoop.hbase.client.HBaseAdmin;
20  import org.apache.hadoop.hbase.testclassification.LargeTests;
21  import org.junit.Test;
22  import org.junit.experimental.categories.Category;
23  
24  @Category(LargeTests.class)
25  public class TestRemoteRestore extends TestBackupBase {
26  
27    private static final Log LOG = LogFactory.getLog(TestRemoteRestore.class);
28  
29    /**
30     * Verify that a remote restore on a single table is successful.
31     * @throws Exception
32     */
33    @Test
34    public void testFullRestoreRemote() throws Exception {
35  
36      LOG.info("test remote full backup on a single table");
37      String backupId = backupTables(BackupType.FULL, toList(table1.getNameAsString()),
38        BACKUP_REMOTE_ROOT_DIR);
39      LOG.info("backup complete");
40      TableName[] tableset = new TableName[] { table1 };
41      TableName[] tablemap = new TableName[] { table1_restore };
42      getBackupAdmin().restore(createRestoreRequest(BACKUP_REMOTE_ROOT_DIR, backupId, false, tableset,
43        tablemap, false));
44      HBaseAdmin hba = TEST_UTIL.getHBaseAdmin();
45      assertTrue(hba.tableExists(table1_restore));
46      TEST_UTIL.deleteTable(table1_restore);
47      hba.close();
48    }
49  
50  }