public static void main(String[] args) throws Exception { Configuration conf = HBaseConfiguration.create(); Path hbasedir = FSUtils.getRootDir(conf); URI defaultFs = hbasedir.getFileSystem(conf).getUri(); FSUtils.setFsDefault(conf, new Path(defaultFs)); int ret = ToolRunner.run(conf, new RestoreDriver(), args); System.exit(ret); }
@Test public void testRestoreDriverUnrecognizedOption() throws Exception { ByteArrayOutputStream baos = new ByteArrayOutputStream(); System.setOut(new PrintStream(baos)); String[] args = new String[] { "-xx" }; ToolRunner.run(conf, new RestoreDriver(), args); String output = baos.toString(); System.out.println(baos.toString()); assertTrue(output.indexOf(USAGE_RESTORE) >= 0); }
@Test public void testRestoreDriverHelp() throws Exception { ByteArrayOutputStream baos = new ByteArrayOutputStream(); System.setOut(new PrintStream(baos)); String[] args = new String[] { "-help" }; ToolRunner.run(conf, new RestoreDriver(), args); String output = baos.toString(); System.out.println(baos.toString()); assertTrue(output.indexOf(USAGE_RESTORE) >= 0); assertTrue(output.indexOf(BackupRestoreConstants.OPTION_TABLE_LIST_DESC) > 0); baos = new ByteArrayOutputStream(); System.setOut(new PrintStream(baos)); args = new String[] { "-h" }; ToolRunner.run(conf, new RestoreDriver(), args); output = baos.toString(); System.out.println(baos.toString()); assertTrue(output.indexOf(USAGE_RESTORE) >= 0); assertTrue(output.indexOf(BackupRestoreConstants.OPTION_TABLE_LIST_DESC) > 0); }
/** * Verify that restore fails on multiple tables that do not exist. * * @throws Exception if doing the backup or restoring it fails */ @Test public void testFullRestoreMultipleDNECommand() throws Exception { LOG.info("test restore fails on multiple tables that do not exist: command-line"); List<TableName> tables = Lists.newArrayList(table2, table3); String backupId = fullTableBackup(tables); assertTrue(checkSucceeded(backupId)); TableName[] restore_tableset = new TableName[] { TableName.valueOf("faketable1"), TableName.valueOf("faketable2") }; TableName[] tablemap = new TableName[] { table2_restore, table3_restore }; String[] args = new String[] { BACKUP_ROOT_DIR, backupId, StringUtils.join(restore_tableset, ","), "-m", StringUtils.join(tablemap, ",") }; // Run restore int ret = ToolRunner.run(conf1, new RestoreDriver(), args); assertTrue(ret != 0); } }
/** * Verify that restore fails on a single table that does not exist. * * @throws Exception if doing the backup or restoring it fails */ @Test public void testFullRestoreSingleDNECommand() throws Exception { LOG.info("test restore fails on a single table that does not exist: command-line"); List<TableName> tables = Lists.newArrayList(table1); String backupId = fullTableBackup(tables); assertTrue(checkSucceeded(backupId)); LOG.info("backup complete"); TableName[] tableset = new TableName[] { TableName.valueOf("faketable") }; TableName[] tablemap = new TableName[] { table1_restore }; String[] args = new String[] { BACKUP_ROOT_DIR, backupId, StringUtils.join(tableset, ","), "-m", StringUtils.join(tablemap, ",") }; // Run restore int ret = ToolRunner.run(conf1, new RestoreDriver(), args); assertTrue(ret != 0); }
/** * Verify that a single table is restored using overwrite. * * @throws Exception if doing the backup or an operation on the tables fails */ @Test public void testFullRestoreSingleOverwriteCommand() throws Exception { LOG.info("test full restore on a single table empty table: command-line"); List<TableName> tables = Lists.newArrayList(table1); String backupId = fullTableBackup(tables); assertTrue(checkSucceeded(backupId)); LOG.info("backup complete"); TableName[] tableset = new TableName[] { table1 }; // restore <backup_root_path> <backup_id> <tables> [tableMapping] String[] args = new String[] { BACKUP_ROOT_DIR, backupId, "-t", StringUtils.join(tableset, ","), "-o" }; // Run restore int ret = ToolRunner.run(conf1, new RestoreDriver(), args); assertTrue(ret == 0); HBaseAdmin hba = TEST_UTIL.getHBaseAdmin(); assertTrue(hba.tableExists(table1)); hba.close(); }
@Test public void testFullRestoreCheckCommand() throws Exception { LOG.info("test full restore on a single table: command-line, check only"); List<TableName> tables = Lists.newArrayList(table1); String backupId = fullTableBackup(tables); LOG.info("backup complete"); assertTrue(checkSucceeded(backupId)); // restore <backup_root_path> <backup_id> <tables> [tableMapping] String[] args = new String[] { BACKUP_ROOT_DIR, backupId, "-t", table1.getNameAsString(), "-m", table1_restore.getNameAsString(), "-c" }; // Run backup int ret = ToolRunner.run(conf1, new RestoreDriver(), args); assertTrue(ret == 0); //Verify that table has not been restored HBaseAdmin hba = TEST_UTIL.getHBaseAdmin(); assertFalse(hba.tableExists(table1_restore)); }
@Test public void testFullRestoreSingleCommand() throws Exception { LOG.info("test full restore on a single table empty table: command-line"); List<TableName> tables = Lists.newArrayList(table1); String backupId = fullTableBackup(tables); LOG.info("backup complete"); assertTrue(checkSucceeded(backupId)); // restore <backup_root_path> <backup_id> <tables> [tableMapping] String[] args = new String[] { BACKUP_ROOT_DIR, backupId, "-t", table1.getNameAsString(), "-m", table1_restore.getNameAsString() }; // Run backup int ret = ToolRunner.run(conf1, new RestoreDriver(), args); assertTrue(ret == 0); HBaseAdmin hba = TEST_UTIL.getHBaseAdmin(); assertTrue(hba.tableExists(table1_restore)); TEST_UTIL.deleteTable(table1_restore); hba.close(); }
/** * Verify that multiple tables are restored to new tables using overwrite. * * @throws Exception if doing the backup or an operation on the tables fails */ @Test public void testFullRestoreMultipleOverwriteCommand() throws Exception { LOG.info("create full backup image on multiple tables: command-line"); List<TableName> tables = Lists.newArrayList(table2, table3); String backupId = fullTableBackup(tables); assertTrue(checkSucceeded(backupId)); TableName[] restore_tableset = new TableName[] { table2, table3 }; // restore <backup_root_path> <backup_id> <tables> [tableMapping] String[] args = new String[] { BACKUP_ROOT_DIR, backupId, "-t", StringUtils.join(restore_tableset, ","), "-o" }; // Run backup int ret = ToolRunner.run(conf1, new RestoreDriver(), args); assertTrue(ret == 0); HBaseAdmin hba = TEST_UTIL.getHBaseAdmin(); assertTrue(hba.tableExists(table2)); assertTrue(hba.tableExists(table3)); hba.close(); }
/** * Verify that multiple tables are restored to new tables. * * @throws Exception if doing the backup, restoring it or an operation on the tables fails */ @Test public void testFullRestoreMultipleCommand() throws Exception { LOG.info("create full backup image on multiple tables: command-line"); List<TableName> tables = Lists.newArrayList(table2, table3); String backupId = fullTableBackup(tables); assertTrue(checkSucceeded(backupId)); TableName[] restore_tableset = new TableName[] { table2, table3 }; TableName[] tablemap = new TableName[] { table2_restore, table3_restore }; // restore <backup_root_path> <backup_id> <tables> [tableMapping] String[] args = new String[] { BACKUP_ROOT_DIR, backupId, "-t", StringUtils.join(restore_tableset, ","), "-m", StringUtils.join(tablemap, ",") }; // Run backup int ret = ToolRunner.run(conf1, new RestoreDriver(), args); assertTrue(ret == 0); HBaseAdmin hba = TEST_UTIL.getHBaseAdmin(); assertTrue(hba.tableExists(table2_restore)); assertTrue(hba.tableExists(table3_restore)); TEST_UTIL.deleteTable(table2_restore); TEST_UTIL.deleteTable(table3_restore); hba.close(); }
ret = ToolRunner.run(conf1, new RestoreDriver(), args); assertTrue(ret == 0); HBaseAdmin hba = TEST_UTIL.getHBaseAdmin();
table1_restore.getNameAsString(), "-o" }; ret = ToolRunner.run(conf1, new RestoreDriver(), args); assertTrue(ret == 0); HBaseAdmin hba = TEST_UTIL.getHBaseAdmin();
table1_restore.getNameAsString(), "-o" }; ret = ToolRunner.run(conf1, new RestoreDriver(), args); assertTrue(ret == 0); HBaseAdmin hba = TEST_UTIL.getHBaseAdmin();