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 static org.junit.Assert.assertTrue; 021 022import java.util.List; 023import org.apache.hadoop.hbase.HBaseClassTestRule; 024import org.apache.hadoop.hbase.backup.impl.BackupSystemTable; 025import org.apache.hadoop.hbase.testclassification.LargeTests; 026import org.apache.hadoop.util.ToolRunner; 027import org.junit.ClassRule; 028import org.junit.Test; 029import org.junit.experimental.categories.Category; 030import org.slf4j.Logger; 031import org.slf4j.LoggerFactory; 032 033@Category(LargeTests.class) 034public class TestFullBackup extends TestBackupBase { 035 036 @ClassRule 037 public static final HBaseClassTestRule CLASS_RULE = 038 HBaseClassTestRule.forClass(TestFullBackup.class); 039 040 private static final Logger LOG = LoggerFactory.getLogger(TestFullBackup.class); 041 042 @Test 043 public void testFullBackupMultipleCommand() throws Exception { 044 LOG.info("test full backup on a multiple tables with data: command-line"); 045 try (BackupSystemTable table = new BackupSystemTable(TEST_UTIL.getConnection())) { 046 int before = table.getBackupHistory().size(); 047 String[] args = new String[] { "create", "full", BACKUP_ROOT_DIR, "-t", 048 table1.getNameAsString() + "," + table2.getNameAsString() }; 049 // Run backup 050 int ret = ToolRunner.run(conf1, new BackupDriver(), args); 051 assertTrue(ret == 0); 052 List<BackupInfo> backups = table.getBackupHistory(); 053 int after = table.getBackupHistory().size(); 054 assertTrue(after == before + 1); 055 for (BackupInfo data : backups) { 056 String backupId = data.getBackupId(); 057 assertTrue(checkSucceeded(backupId)); 058 } 059 } 060 LOG.info("backup complete"); 061 } 062 063}