ndimiduk commented on code in PR #6018:
URL: https://github.com/apache/hbase/pull/6018#discussion_r1654684530
##########
hbase-backup/src/test/java/org/apache/hadoop/hbase/backup/TestBackupBase.java:
##########
@@ -115,6 +118,38 @@ public IncrementalTableBackupClientForTest(Connection
conn, String backupId,
super(conn, backupId, request);
}
+ @Before
+ public void ensurePreviousBackupTestsAreCleanedUp() throws Exception {
+ // Every operation here may not be necessary for any given test,
+ // some often being no-ops. the goal is to help ensure atomicity
+ // of that tests that implement TestBackupBase
+ try (BackupAdmin backupAdmin = getBackupAdmin()) {
+ backupManager.finishBackupSession();
+ backupAdmin.listBackupSets().forEach(backupSet -> {
+ try {
+ backupAdmin.deleteBackupSet(backupSet.getName());
+ } catch (IOException ignored) {
+ }
+ });
+ } catch (Exception ignored) {
+ }
+ Arrays.stream(TEST_UTIL.getAdmin().listTableNames())
+ .filter(tableName -> !tableName.isSystemTable()).forEach(tableName -> {
+ try {
+ TEST_UTIL.truncateTable(tableName);
+ } catch (IOException ignored) {
+ }
+ });
+ TEST_UTIL.getMiniHBaseCluster().getRegionServerThreads().forEach(rst -> {
+ try {
+ LogRoller walRoller = rst.getRegionServer().getWalRoller();
+ walRoller.requestRollAll();
+ walRoller.waitUntilWalRollFinished();
+ } catch (Exception ignored) {
+ }
+ });
+ }
Review Comment:
Sure, let's try it.
For what it's worth, I've had success with refactoring inheritance out of
these junit4 tests by moving shared logic into an `ExternalResource`
implementation. It doesn't let you reuse `@Test` implementations, but it does
make implementing before/after logic more composable.
--
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]