HBASE-18632 TestMultiParallel#testFlushCommitsWithAbort fails in master branch
[hbase.git] / hbase-server / src / test / java / org / apache / hadoop / hbase / backup / TestBackupStatusProgress.java
blob73d8d9fd300ba4593a410736faa9dd40c6457931
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
10 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 package org.apache.hadoop.hbase.backup;
21 import static org.junit.Assert.assertTrue;
23 import java.io.ByteArrayOutputStream;
24 import java.io.PrintStream;
25 import java.util.List;
27 import org.apache.commons.logging.Log;
28 import org.apache.commons.logging.LogFactory;
29 import org.apache.hadoop.hbase.TableName;
30 import org.apache.hadoop.hbase.backup.BackupInfo.BackupState;
31 import org.apache.hadoop.hbase.testclassification.LargeTests;
32 import org.apache.hadoop.util.ToolRunner;
33 import org.junit.Test;
34 import org.junit.experimental.categories.Category;
36 import org.apache.hadoop.hbase.shaded.com.google.common.collect.Lists;
38 @Category(LargeTests.class)
39 public class TestBackupStatusProgress extends TestBackupBase {
41 private static final Log LOG = LogFactory.getLog(TestBackupStatusProgress.class);
43 /**
44 * Verify that full backup is created on a single table with data correctly.
45 * @throws Exception
47 @Test
48 public void testBackupStatusProgress() throws Exception {
50 LOG.info("test backup status/progress on a single table with data");
52 List<TableName> tableList = Lists.newArrayList(table1);
53 String backupId = fullTableBackup(tableList);
54 LOG.info("backup complete");
55 assertTrue(checkSucceeded(backupId));
57 BackupInfo info = getBackupAdmin().getBackupInfo(backupId);
58 assertTrue(info.getState() == BackupState.COMPLETE);
60 LOG.debug(info.getShortDescription());
61 assertTrue(info.getProgress() > 0);
65 @Test
66 public void testBackupStatusProgressCommand() throws Exception {
68 LOG.info("test backup status/progress on a single table with data: command-line");
70 List<TableName> tableList = Lists.newArrayList(table1);
71 String backupId = fullTableBackup(tableList);
72 LOG.info("backup complete");
73 assertTrue(checkSucceeded(backupId));
74 ByteArrayOutputStream baos = new ByteArrayOutputStream();
75 System.setOut(new PrintStream(baos));
77 String[] args = new String[] { "describe", backupId };
78 int ret = ToolRunner.run(conf1, new BackupDriver(), args);
79 assertTrue(ret == 0);
80 String responce = baos.toString();
81 assertTrue(responce.indexOf(backupId) > 0);
82 assertTrue(responce.indexOf("COMPLETE") > 0);
84 baos = new ByteArrayOutputStream();
85 System.setOut(new PrintStream(baos));
87 args = new String[] { "progress", backupId };
88 ret = ToolRunner.run(conf1, new BackupDriver(), args);
89 assertTrue(ret == 0);
90 responce = baos.toString();
91 assertTrue(responce.indexOf(backupId) >= 0);
92 assertTrue(responce.indexOf("progress") > 0);
93 assertTrue(responce.indexOf("100") > 0);