Skip to content

Commit 6a4af7f

Browse files
authored
HBASE-29815: Fix issue where backup integration tests are not running in IntelliJ (#7625)
Signed-off-by: Tak Lon (Stephen) Wu <taklwu@apache.org>
1 parent 7537362 commit 6a4af7f

3 files changed

Lines changed: 45 additions & 13 deletions

File tree

hbase-it/src/test/java/org/apache/hadoop/hbase/backup/IntegrationTestBackupRestore.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ public class IntegrationTestBackupRestore extends IntegrationTestBackupRestoreBa
4545
@Override
4646
@Before
4747
public void setUp() throws Exception {
48-
util = new IntegrationTestingUtility();
49-
conf = util.getConfiguration();
48+
initializeTestParameters();
5049
BackupTestUtil.enableBackup(conf);
5150
LOG.info("Initializing cluster with {} region servers.", regionServerCount);
5251
util.initializeCluster(regionServerCount);

hbase-it/src/test/java/org/apache/hadoop/hbase/backup/IntegrationTestBackupRestoreBase.java

Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import org.apache.hadoop.hbase.Cell;
3939
import org.apache.hadoop.hbase.HBaseTestingUtil;
4040
import org.apache.hadoop.hbase.IntegrationTestBase;
41+
import org.apache.hadoop.hbase.IntegrationTestingUtility;
4142
import org.apache.hadoop.hbase.ServerName;
4243
import org.apache.hadoop.hbase.TableName;
4344
import org.apache.hadoop.hbase.backup.impl.BackupAdminImpl;
@@ -90,20 +91,19 @@ public abstract class IntegrationTestBackupRestoreBase extends IntegrationTestBa
9091
protected static final int DEFAULT_NUM_ITERATIONS = 10;
9192
protected static final int DEFAULT_ROWS_IN_ITERATION = 10000;
9293
protected static final String SLEEP_TIME_KEY = "sleeptime";
93-
// short default interval because tests don't run very long.
94+
// Short default interval because tests don't run very long.
9495
protected static final long SLEEP_TIME_DEFAULT = 50000L;
9596
protected static String DEFAULT_BACKUP_ROOT_DIR = "backupIT";
9697

97-
protected static int rowsInIteration;
98-
protected static int regionsCountPerServer;
99-
protected static int regionServerCount;
100-
101-
protected static int numIterations;
102-
protected static int numTables;
103-
protected static TableName[] tableNames;
98+
// These test parameters can be configured using a Configuration object or via the command line.
99+
protected int rowsInIteration;
100+
protected int regionsCountPerServer;
101+
protected int regionServerCount;
102+
protected int numIterations;
103+
protected int numTables;
104104
protected long sleepTime;
105-
protected static Object lock = new Object();
106105

106+
protected static TableName[] tableNames;
107107
protected FileSystem fs;
108108
protected String backupRootDir;
109109

@@ -715,6 +715,40 @@ protected Set<String> getColumnFamilies() {
715715
return null;
716716
}
717717

718+
/**
719+
* This method is useful for ensuring important test parameters are initialized when running
720+
* integration tests in IntelliJ or in the command line with Maven. Tests executed in the command
721+
* line via the bin/hbase command have their parameters set in
722+
* {@link IntegrationTestBase#processOptions}
723+
*/
724+
protected void initializeTestParameters() {
725+
util = new IntegrationTestingUtility();
726+
conf = util.getConfiguration();
727+
728+
regionsCountPerServer = conf.getInt(REGION_COUNT_KEY,
729+
regionsCountPerServer > 0 ? regionsCountPerServer : DEFAULT_REGION_COUNT);
730+
LOG.debug("regionsCountPerServer is set to {}", regionsCountPerServer);
731+
732+
regionServerCount = conf.getInt(REGIONSERVER_COUNT_KEY,
733+
regionServerCount > 0 ? regionServerCount : DEFAULT_REGIONSERVER_COUNT);
734+
LOG.debug("regionServerCount is set to {}", regionServerCount);
735+
736+
rowsInIteration = conf.getInt(ROWS_PER_ITERATION_KEY,
737+
rowsInIteration > 0 ? rowsInIteration : DEFAULT_ROWS_IN_ITERATION);
738+
LOG.debug("rowsInIteration is set to {}", rowsInIteration);
739+
740+
numIterations =
741+
conf.getInt(NUM_ITERATIONS_KEY, numIterations > 0 ? numIterations : DEFAULT_NUM_ITERATIONS);
742+
LOG.debug("numIterations is set to {}", numIterations);
743+
744+
numTables =
745+
conf.getInt(NUMBER_OF_TABLES_KEY, numTables > 0 ? numTables : DEFAULT_NUMBER_OF_TABLES);
746+
LOG.debug("numTables is set to {}", numTables);
747+
748+
sleepTime = conf.getLong(SLEEP_TIME_KEY, sleepTime > 0 ? sleepTime : SLEEP_TIME_DEFAULT);
749+
LOG.debug("sleepTime is set to {}", sleepTime);
750+
}
751+
718752
@Override
719753
protected void addOptions() {
720754
addOptWithArg(REGIONSERVER_COUNT_KEY,

hbase-it/src/test/java/org/apache/hadoop/hbase/backup/IntegrationTestContinuousBackupRestore.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ public class IntegrationTestContinuousBackupRestore extends IntegrationTestBacku
5454
@Override
5555
@Before
5656
public void setUp() throws Exception {
57-
util = new IntegrationTestingUtility();
58-
conf = util.getConfiguration();
57+
initializeTestParameters();
5958
BackupTestUtil.enableBackup(conf);
6059
conf.set(CONF_BACKUP_MAX_WAL_SIZE, "10240");
6160
conf.set(CONF_STAGED_WAL_FLUSH_INITIAL_DELAY, "10");

0 commit comments

Comments
 (0)