Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,20 @@
*/
package org.apache.hadoop.hbase.backup;

import static org.apache.hadoop.hbase.backup.BackupRestoreConstants.CONTINUOUS_BACKUP_REPLICATION_PEER;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseTestingUtil;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.backup.impl.BackupAdminImpl;
import org.apache.hadoop.hbase.backup.impl.BackupManager;
import org.apache.hadoop.hbase.client.Admin;
import org.apache.hadoop.hbase.client.Connection;
import org.apache.hadoop.hbase.client.ConnectionFactory;
import org.apache.hadoop.hbase.replication.ReplicationPeerDescription;
import org.apache.yetus.audience.InterfaceAudience;

@InterfaceAudience.Private
Expand All @@ -46,10 +52,21 @@ static BackupInfo verifyBackup(Configuration conf, String backupId, BackupType e
}
}

static void enableBackup(Configuration conf) {
// Enable backup
public static void enableBackup(Configuration conf) {
conf.setBoolean(BackupRestoreConstants.BACKUP_ENABLE_KEY, true);
BackupManager.decorateMasterConfiguration(conf);
BackupManager.decorateRegionServerConfiguration(conf);
}

public static void verifyReplicationPeerSubscription(HBaseTestingUtil util, TableName tableName)
throws IOException {
try (Admin admin = util.getAdmin()) {
ReplicationPeerDescription peerDesc = admin.listReplicationPeers().stream()
.filter(peer -> peer.getPeerId().equals(CONTINUOUS_BACKUP_REPLICATION_PEER)).findFirst()
.orElseThrow(() -> new AssertionError("Replication peer not found"));

assertTrue("Table should be subscribed to the replication peer",
peerDesc.getPeerConfig().getTableCFsMap().containsKey(tableName));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
package org.apache.hadoop.hbase.backup;

import static org.apache.hadoop.hbase.backup.BackupRestoreConstants.CONF_CONTINUOUS_BACKUP_WAL_DIR;
import static org.apache.hadoop.hbase.backup.BackupRestoreConstants.CONTINUOUS_BACKUP_REPLICATION_PEER;
import static org.apache.hadoop.hbase.backup.BackupRestoreConstants.OPTION_ENABLE_CONTINUOUS_BACKUP;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
Expand All @@ -36,8 +35,6 @@
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.backup.impl.BackupManifest;
import org.apache.hadoop.hbase.backup.impl.BackupSystemTable;
import org.apache.hadoop.hbase.client.Admin;
import org.apache.hadoop.hbase.replication.ReplicationPeerDescription;
import org.apache.hadoop.hbase.testclassification.LargeTests;
import org.apache.hadoop.util.ToolRunner;
import org.junit.After;
Expand Down Expand Up @@ -114,7 +111,7 @@ public void testContinuousBackupWithFullBackup() throws Exception {
}

// Verify replication peer subscription
verifyReplicationPeerSubscription(tableName);
BackupTestUtil.verifyReplicationPeerSubscription(TEST_UTIL, tableName);

// Verify table is registered in Backup System Table
verifyTableInBackupSystemTable(tableName);
Expand Down Expand Up @@ -157,8 +154,8 @@ public void testContinuousBackupForMultipleTables() throws Exception {
}

// Verify replication peer subscription for each table
verifyReplicationPeerSubscription(tableName1);
verifyReplicationPeerSubscription(tableName2);
BackupTestUtil.verifyReplicationPeerSubscription(TEST_UTIL, tableName1);
BackupTestUtil.verifyReplicationPeerSubscription(TEST_UTIL, tableName2);

// Verify tables are registered in Backup System Table
verifyTableInBackupSystemTable(tableName1);
Expand Down Expand Up @@ -248,17 +245,6 @@ public void testContinuousBackupWithIncrementalBackup() throws Exception {
}
}

private void verifyReplicationPeerSubscription(TableName table) throws IOException {
try (Admin admin = TEST_UTIL.getAdmin()) {
ReplicationPeerDescription peerDesc = admin.listReplicationPeers().stream()
.filter(peer -> peer.getPeerId().equals(CONTINUOUS_BACKUP_REPLICATION_PEER)).findFirst()
.orElseThrow(() -> new AssertionError("Replication peer not found"));

assertTrue("Table should be subscribed to the replication peer",
peerDesc.getPeerConfig().getTableCFsMap().containsKey(table));
}
}

String[] buildBackupArgs(String backupType, TableName[] tables, boolean continuousEnabled) {
String tableNames =
Arrays.stream(tables).map(TableName::getNameAsString).collect(Collectors.joining(","));
Expand Down
7 changes: 7 additions & 0 deletions hbase-it/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-backup</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-logging</artifactId>
Expand Down
Loading