From 9c64cae887b1f23ea374caae9a6016c7e3a672b1 Mon Sep 17 00:00:00 2001 From: Kevin Geiszler Date: Thu, 16 Oct 2025 21:22:59 -0700 Subject: [PATCH 1/2] HBASE-29815: Fix issue where backup integration tests are not running in IntelliJ Change-Id: I467b73cd736d72c198d9314feea10dc6baa8af9b --- .../backup/IntegrationTestBackupRestore.java | 3 +- .../IntegrationTestBackupRestoreBase.java | 59 ++++++++++++++++--- ...ntegrationTestContinuousBackupRestore.java | 3 +- 3 files changed, 52 insertions(+), 13 deletions(-) diff --git a/hbase-it/src/test/java/org/apache/hadoop/hbase/backup/IntegrationTestBackupRestore.java b/hbase-it/src/test/java/org/apache/hadoop/hbase/backup/IntegrationTestBackupRestore.java index 99fbcb21a2b5..988688eb6f59 100644 --- a/hbase-it/src/test/java/org/apache/hadoop/hbase/backup/IntegrationTestBackupRestore.java +++ b/hbase-it/src/test/java/org/apache/hadoop/hbase/backup/IntegrationTestBackupRestore.java @@ -45,8 +45,7 @@ public class IntegrationTestBackupRestore extends IntegrationTestBackupRestoreBa @Override @Before public void setUp() throws Exception { - util = new IntegrationTestingUtility(); - conf = util.getConfiguration(); + initializeTestParameters(); BackupTestUtil.enableBackup(conf); LOG.info("Initializing cluster with {} region servers.", regionServerCount); util.initializeCluster(regionServerCount); diff --git a/hbase-it/src/test/java/org/apache/hadoop/hbase/backup/IntegrationTestBackupRestoreBase.java b/hbase-it/src/test/java/org/apache/hadoop/hbase/backup/IntegrationTestBackupRestoreBase.java index 56349fe055a7..9bf478312242 100644 --- a/hbase-it/src/test/java/org/apache/hadoop/hbase/backup/IntegrationTestBackupRestoreBase.java +++ b/hbase-it/src/test/java/org/apache/hadoop/hbase/backup/IntegrationTestBackupRestoreBase.java @@ -38,6 +38,7 @@ import org.apache.hadoop.hbase.Cell; import org.apache.hadoop.hbase.HBaseTestingUtil; import org.apache.hadoop.hbase.IntegrationTestBase; +import org.apache.hadoop.hbase.IntegrationTestingUtility; import org.apache.hadoop.hbase.ServerName; import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.backup.impl.BackupAdminImpl; @@ -90,20 +91,19 @@ public abstract class IntegrationTestBackupRestoreBase extends IntegrationTestBa protected static final int DEFAULT_NUM_ITERATIONS = 10; protected static final int DEFAULT_ROWS_IN_ITERATION = 10000; protected static final String SLEEP_TIME_KEY = "sleeptime"; - // short default interval because tests don't run very long. + // Short default interval because tests don't run very long. protected static final long SLEEP_TIME_DEFAULT = 50000L; protected static String DEFAULT_BACKUP_ROOT_DIR = "backupIT"; - protected static int rowsInIteration; - protected static int regionsCountPerServer; - protected static int regionServerCount; + // These test parameters can be configured using a Configuration object or via the command line. + protected static int rowsInIteration = -1; + protected static int regionsCountPerServer = -1; + protected static int regionServerCount = -1; + protected static int numIterations = -1; + protected static int numTables = -1; + protected static long sleepTime = -1; - protected static int numIterations; - protected static int numTables; protected static TableName[] tableNames; - protected long sleepTime; - protected static Object lock = new Object(); - protected FileSystem fs; protected String backupRootDir; @@ -715,6 +715,47 @@ protected Set getColumnFamilies() { return null; } + /** + * This method is useful for ensuring important test parameters are initialized when running + * integration tests in IntelliJ or in the command line with Maven. Tests executed in the command + * line via the bin/hbase command have their parameters set in + * {@link IntegrationTestBase#processOptions} + */ + protected void initializeTestParameters() { + util = new IntegrationTestingUtility(); + conf = util.getConfiguration(); + + if (regionsCountPerServer == -1) { + regionsCountPerServer = conf.getInt(REGION_COUNT_KEY, DEFAULT_REGION_COUNT); + } + LOG.info("regionsCountPerServer is set to {}", regionsCountPerServer); + + if (regionServerCount == -1) { + regionServerCount = conf.getInt(REGIONSERVER_COUNT_KEY, DEFAULT_REGIONSERVER_COUNT); + } + LOG.info("regionServerCount is set to {}", regionServerCount); + + if (rowsInIteration == -1) { + rowsInIteration = conf.getInt(ROWS_PER_ITERATION_KEY, DEFAULT_ROWS_IN_ITERATION); + } + LOG.info("rowsInIteration is set to {}", rowsInIteration); + + if (numIterations == -1) { + numIterations = conf.getInt(NUM_ITERATIONS_KEY, DEFAULT_NUM_ITERATIONS); + } + LOG.info("numIterations is set to {}", numIterations); + + if (numTables == -1) { + numTables = conf.getInt(NUMBER_OF_TABLES_KEY, DEFAULT_NUMBER_OF_TABLES); + } + LOG.info("numTables is set to {}", numTables); + + if (sleepTime == -1) { + sleepTime = conf.getLong(SLEEP_TIME_KEY, SLEEP_TIME_DEFAULT); + } + LOG.info("sleepTime is set to {}", sleepTime); + } + @Override protected void addOptions() { addOptWithArg(REGIONSERVER_COUNT_KEY, diff --git a/hbase-it/src/test/java/org/apache/hadoop/hbase/backup/IntegrationTestContinuousBackupRestore.java b/hbase-it/src/test/java/org/apache/hadoop/hbase/backup/IntegrationTestContinuousBackupRestore.java index 61ce3eea2b15..8ca8caa04f99 100644 --- a/hbase-it/src/test/java/org/apache/hadoop/hbase/backup/IntegrationTestContinuousBackupRestore.java +++ b/hbase-it/src/test/java/org/apache/hadoop/hbase/backup/IntegrationTestContinuousBackupRestore.java @@ -54,8 +54,7 @@ public class IntegrationTestContinuousBackupRestore extends IntegrationTestBacku @Override @Before public void setUp() throws Exception { - util = new IntegrationTestingUtility(); - conf = util.getConfiguration(); + initializeTestParameters(); BackupTestUtil.enableBackup(conf); conf.set(CONF_BACKUP_MAX_WAL_SIZE, "10240"); conf.set(CONF_STAGED_WAL_FLUSH_INITIAL_DELAY, "10"); From 6db6b9e78788d8cd8d184289730f9572fa8cd069 Mon Sep 17 00:00:00 2001 From: Kevin Geiszler Date: Thu, 15 Jan 2026 12:06:03 -0800 Subject: [PATCH 2/2] Address PR comments Change-Id: Iac0de197dde0bc4b392ebe839b4619bc5ba68383 --- .../IntegrationTestBackupRestoreBase.java | 53 ++++++++----------- 1 file changed, 23 insertions(+), 30 deletions(-) diff --git a/hbase-it/src/test/java/org/apache/hadoop/hbase/backup/IntegrationTestBackupRestoreBase.java b/hbase-it/src/test/java/org/apache/hadoop/hbase/backup/IntegrationTestBackupRestoreBase.java index 9bf478312242..82464acd40d5 100644 --- a/hbase-it/src/test/java/org/apache/hadoop/hbase/backup/IntegrationTestBackupRestoreBase.java +++ b/hbase-it/src/test/java/org/apache/hadoop/hbase/backup/IntegrationTestBackupRestoreBase.java @@ -96,12 +96,12 @@ public abstract class IntegrationTestBackupRestoreBase extends IntegrationTestBa protected static String DEFAULT_BACKUP_ROOT_DIR = "backupIT"; // These test parameters can be configured using a Configuration object or via the command line. - protected static int rowsInIteration = -1; - protected static int regionsCountPerServer = -1; - protected static int regionServerCount = -1; - protected static int numIterations = -1; - protected static int numTables = -1; - protected static long sleepTime = -1; + protected int rowsInIteration; + protected int regionsCountPerServer; + protected int regionServerCount; + protected int numIterations; + protected int numTables; + protected long sleepTime; protected static TableName[] tableNames; protected FileSystem fs; @@ -725,35 +725,28 @@ protected void initializeTestParameters() { util = new IntegrationTestingUtility(); conf = util.getConfiguration(); - if (regionsCountPerServer == -1) { - regionsCountPerServer = conf.getInt(REGION_COUNT_KEY, DEFAULT_REGION_COUNT); - } - LOG.info("regionsCountPerServer is set to {}", regionsCountPerServer); + regionsCountPerServer = conf.getInt(REGION_COUNT_KEY, + regionsCountPerServer > 0 ? regionsCountPerServer : DEFAULT_REGION_COUNT); + LOG.debug("regionsCountPerServer is set to {}", regionsCountPerServer); - if (regionServerCount == -1) { - regionServerCount = conf.getInt(REGIONSERVER_COUNT_KEY, DEFAULT_REGIONSERVER_COUNT); - } - LOG.info("regionServerCount is set to {}", regionServerCount); + regionServerCount = conf.getInt(REGIONSERVER_COUNT_KEY, + regionServerCount > 0 ? regionServerCount : DEFAULT_REGIONSERVER_COUNT); + LOG.debug("regionServerCount is set to {}", regionServerCount); - if (rowsInIteration == -1) { - rowsInIteration = conf.getInt(ROWS_PER_ITERATION_KEY, DEFAULT_ROWS_IN_ITERATION); - } - LOG.info("rowsInIteration is set to {}", rowsInIteration); + rowsInIteration = conf.getInt(ROWS_PER_ITERATION_KEY, + rowsInIteration > 0 ? rowsInIteration : DEFAULT_ROWS_IN_ITERATION); + LOG.debug("rowsInIteration is set to {}", rowsInIteration); - if (numIterations == -1) { - numIterations = conf.getInt(NUM_ITERATIONS_KEY, DEFAULT_NUM_ITERATIONS); - } - LOG.info("numIterations is set to {}", numIterations); + numIterations = + conf.getInt(NUM_ITERATIONS_KEY, numIterations > 0 ? numIterations : DEFAULT_NUM_ITERATIONS); + LOG.debug("numIterations is set to {}", numIterations); - if (numTables == -1) { - numTables = conf.getInt(NUMBER_OF_TABLES_KEY, DEFAULT_NUMBER_OF_TABLES); - } - LOG.info("numTables is set to {}", numTables); + numTables = + conf.getInt(NUMBER_OF_TABLES_KEY, numTables > 0 ? numTables : DEFAULT_NUMBER_OF_TABLES); + LOG.debug("numTables is set to {}", numTables); - if (sleepTime == -1) { - sleepTime = conf.getLong(SLEEP_TIME_KEY, SLEEP_TIME_DEFAULT); - } - LOG.info("sleepTime is set to {}", sleepTime); + sleepTime = conf.getLong(SLEEP_TIME_KEY, sleepTime > 0 ? sleepTime : SLEEP_TIME_DEFAULT); + LOG.debug("sleepTime is set to {}", sleepTime); } @Override