Copilot commented on code in PR #7045:
URL: https://github.com/apache/hbase/pull/7045#discussion_r2140630273


##########
hbase-backup/src/test/java/org/apache/hadoop/hbase/backup/TestBackupDescribe.java:
##########
@@ -107,4 +112,50 @@ public void testBackupDescribeCommand() throws Exception {
     table.close();
     assertTrue(response.indexOf(desc) >= 0);
   }
+
+  @Test
+  public void testBackupDescribeCommandForContinuousBackup() throws Exception {
+    LOG.info("test backup describe on a single table with data: command-line");
+    BackupSystemTable table = new BackupSystemTable(TEST_UTIL.getConnection());
+
+    Path root = TEST_UTIL.getDataTestDirOnTestFS();
+    Path backupWalDir = new Path(root, "testBackupDescribeCommand");
+    FileSystem fs = FileSystem.get(conf1);
+    fs.mkdirs(backupWalDir);
+    conf1.set(CONF_CONTINUOUS_BACKUP_WAL_DIR, backupWalDir.toString());
+
+    String[] backupArgs = new String[] { "create", BackupType.FULL.name(), 
BACKUP_ROOT_DIR, "-t",
+      table1.getNameAsString(), "-" + OPTION_ENABLE_CONTINUOUS_BACKUP };
+    int ret = ToolRunner.run(conf1, new BackupDriver(), backupArgs);
+    assertEquals("Backup should succeed", 0, ret);
+    String backupId = table.getBackupHistory().get(0).getBackupId();
+    assertTrue(checkSucceeded(backupId));
+    LOG.info("backup complete");
+
+    BackupInfo info = getBackupAdmin().getBackupInfo(backupId);
+    assertTrue(info.getState() == BackupState.COMPLETE);
+
+    ByteArrayOutputStream baos = new ByteArrayOutputStream();
+    System.setOut(new PrintStream(baos));
+
+    String[] args = new String[] { "describe", backupId };
+    // Run backup
+    ret = ToolRunner.run(conf1, new BackupDriver(), args);
+    assertTrue(ret == 0);
+    String response = baos.toString();
+    assertTrue(response.indexOf(backupId) > 0);
+    assertTrue(response.indexOf("COMPLETE") > 0);
+    assertTrue(response.indexOf("IsContinuous=true") > 0);
+
+    BackupInfo status = table.readBackupInfo(backupId);
+    String desc = status.getShortDescription();
+    table.close();
+    assertTrue(response.indexOf(desc) >= 0);
+

Review Comment:
   Capture the original System.out (e.g., PrintStream original = System.out) 
and restore it in a finally block or @After method to avoid side effects on 
other tests.
   ```suggestion
       PrintStream originalOut = System.out; // Capture the original System.out
       System.setOut(new PrintStream(baos));
       try {
         String[] args = new String[] { "describe", backupId };
         // Run backup
         ret = ToolRunner.run(conf1, new BackupDriver(), args);
         assertTrue(ret == 0);
         String response = baos.toString();
         assertTrue(response.indexOf(backupId) > 0);
         assertTrue(response.indexOf("COMPLETE") > 0);
         assertTrue(response.indexOf("IsContinuous=true") > 0);
   
         BackupInfo status = table.readBackupInfo(backupId);
         String desc = status.getShortDescription();
         table.close();
         assertTrue(response.indexOf(desc) >= 0);
       } finally {
         System.setOut(originalOut); // Restore the original System.out
       }
   ```



##########
hbase-backup/src/test/java/org/apache/hadoop/hbase/backup/TestBackupDescribe.java:
##########
@@ -107,4 +112,50 @@ public void testBackupDescribeCommand() throws Exception {
     table.close();
     assertTrue(response.indexOf(desc) >= 0);
   }
+
+  @Test
+  public void testBackupDescribeCommandForContinuousBackup() throws Exception {
+    LOG.info("test backup describe on a single table with data: command-line");
+    BackupSystemTable table = new BackupSystemTable(TEST_UTIL.getConnection());
+
+    Path root = TEST_UTIL.getDataTestDirOnTestFS();
+    Path backupWalDir = new Path(root, "testBackupDescribeCommand");
+    FileSystem fs = FileSystem.get(conf1);
+    fs.mkdirs(backupWalDir);
+    conf1.set(CONF_CONTINUOUS_BACKUP_WAL_DIR, backupWalDir.toString());
+
+    String[] backupArgs = new String[] { "create", BackupType.FULL.name(), 
BACKUP_ROOT_DIR, "-t",
+      table1.getNameAsString(), "-" + OPTION_ENABLE_CONTINUOUS_BACKUP };
+    int ret = ToolRunner.run(conf1, new BackupDriver(), backupArgs);
+    assertEquals("Backup should succeed", 0, ret);
+    String backupId = table.getBackupHistory().get(0).getBackupId();
+    assertTrue(checkSucceeded(backupId));
+    LOG.info("backup complete");
+
+    BackupInfo info = getBackupAdmin().getBackupInfo(backupId);
+    assertTrue(info.getState() == BackupState.COMPLETE);
+
+    ByteArrayOutputStream baos = new ByteArrayOutputStream();
+    System.setOut(new PrintStream(baos));
+
+    String[] args = new String[] { "describe", backupId };
+    // Run backup
+    ret = ToolRunner.run(conf1, new BackupDriver(), args);
+    assertTrue(ret == 0);
+    String response = baos.toString();
+    assertTrue(response.indexOf(backupId) > 0);
+    assertTrue(response.indexOf("COMPLETE") > 0);
+    assertTrue(response.indexOf("IsContinuous=true") > 0);

Review Comment:
   Use a non‐positional check like 
`assertTrue(response.contains("IsContinuous=true"))` or at least `>= 0` to 
correctly assert presence even at the start of the string.
   ```suggestion
       assertTrue(response.contains("IsContinuous=true"));
   ```



-- 
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: issues-unsubscr...@hbase.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to