hgromer commented on code in PR #6370:
URL: https://github.com/apache/hbase/pull/6370#discussion_r1922974600
##########
hbase-backup/src/test/java/org/apache/hadoop/hbase/backup/TestIncrementalBackup.java:
##########
@@ -100,142 +141,227 @@ public void TestIncBackupRestore() throws Exception {
.build();
TEST_UTIL.getAdmin().modifyTable(newTable1Desc);
+ Connection conn = TEST_UTIL.getConnection();
+ int NB_ROWS_FAM3 = 6;
+ insertIntoTable(conn, table1, fam3Name, 3, NB_ROWS_FAM3).close();
+ insertIntoTable(conn, table1, mobName, 3, NB_ROWS_FAM3).close();
+ Admin admin = conn.getAdmin();
+ BackupAdminImpl client = new BackupAdminImpl(conn);
+ String backupIdFull = takeFullBackup(tables, client);
+ validateRootPathCanBeOverridden(BACKUP_ROOT_DIR, backupIdFull);
+ assertTrue(checkSucceeded(backupIdFull));
+
+ // #2 - insert some data to table
+ Table t1 = insertIntoTable(conn, table1, famName, 1, ADD_ROWS);
+ LOG.debug("writing " + ADD_ROWS + " rows to " + table1);
+ Assert.assertEquals(HBaseTestingUtil.countRows(t1), NB_ROWS_IN_BATCH +
ADD_ROWS + NB_ROWS_FAM3);
+ LOG.debug("written " + ADD_ROWS + " rows to " + table1);
+ // additionally, insert rows to MOB cf
+ int NB_ROWS_MOB = 111;
+ insertIntoTable(conn, table1, mobName, 3, NB_ROWS_MOB);
+ LOG.debug("written " + NB_ROWS_MOB + " rows to " + table1 + " to Mob
enabled CF");
+ t1.close();
+ Assert.assertEquals(HBaseTestingUtil.countRows(t1), NB_ROWS_IN_BATCH +
ADD_ROWS + NB_ROWS_MOB);
+ Table t2 = conn.getTable(table2);
+ Put p2;
+ for (int i = 0; i < 5; i++) {
+ p2 = new Put(Bytes.toBytes("row-t2" + i));
+ p2.addColumn(famName, qualName, Bytes.toBytes("val" + i));
+ t2.put(p2);
+ }
+ Assert.assertEquals(NB_ROWS_IN_BATCH + 5, HBaseTestingUtil.countRows(t2));
+ t2.close();
+ LOG.debug("written " + 5 + " rows to " + table2);
+ // split table1
+ SingleProcessHBaseCluster cluster = TEST_UTIL.getHBaseCluster();
+ List<HRegion> regions = cluster.getRegions(table1);
+ byte[] name = regions.get(0).getRegionInfo().getRegionName();
+ long startSplitTime = EnvironmentEdgeManager.currentTime();
+ try {
+ admin.splitRegionAsync(name).get();
+ } catch (Exception e) {
+ // although split fail, this may not affect following check in current
API,
+ // exception will be thrown.
+ LOG.debug("region is not splittable, because " + e);
+ }
+ TEST_UTIL.waitTableAvailable(table1);
+ long endSplitTime = EnvironmentEdgeManager.currentTime();
+ // split finished
+ LOG.debug("split finished in =" + (endSplitTime - startSplitTime));
+
+ // #3 - incremental backup for multiple tables
+ tables = Lists.newArrayList(table1, table2);
+ BackupRequest request = createBackupRequest(BackupType.INCREMENTAL,
tables, BACKUP_ROOT_DIR);
+ String backupIdIncMultiple = client.backupTables(request);
+ assertTrue(checkSucceeded(backupIdIncMultiple));
+ BackupManifest manifest =
+ HBackupFileSystem.getManifest(conf1, new Path(BACKUP_ROOT_DIR),
backupIdIncMultiple);
+ assertEquals(Sets.newHashSet(table1, table2), new
HashSet<>(manifest.getTableList()));
+ validateRootPathCanBeOverridden(BACKUP_ROOT_DIR, backupIdIncMultiple);
+
+ // add column family f2 to table1
+ // drop column family f3
+ final byte[] fam2Name = Bytes.toBytes("f2");
+ newTable1Desc = TableDescriptorBuilder.newBuilder(newTable1Desc)
+
.setColumnFamily(ColumnFamilyDescriptorBuilder.of(fam2Name)).removeColumnFamily(fam3Name)
+ .build();
+ TEST_UTIL.getAdmin().modifyTable(newTable1Desc);
+
+ // check that an incremental backup fails because the CFs don't match
+ final List<TableName> tablesCopy = tables;
+ IOException ex = assertThrows(IOException.class, () -> client
+ .backupTables(createBackupRequest(BackupType.INCREMENTAL, tablesCopy,
BACKUP_ROOT_DIR)));
+ checkThrowsCFMismatch(ex, List.of(table1));
+ takeFullBackup(tables, client);
+
+ int NB_ROWS_FAM2 = 7;
+ Table t3 = insertIntoTable(conn, table1, fam2Name, 2, NB_ROWS_FAM2);
+ t3.close();
+
+ // Wait for 5 sec to make sure that old WALs were deleted
+ Thread.sleep(5000);
Review Comment:
this isn't code that I wrote, so I'm not 100% sure why this is required. i'm
going to try and figure out why this test's diff is showing this as an addition
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]