|
38 | 38 | import org.apache.hadoop.hbase.Cell; |
39 | 39 | import org.apache.hadoop.hbase.HBaseTestingUtil; |
40 | 40 | import org.apache.hadoop.hbase.IntegrationTestBase; |
| 41 | +import org.apache.hadoop.hbase.IntegrationTestingUtility; |
41 | 42 | import org.apache.hadoop.hbase.ServerName; |
42 | 43 | import org.apache.hadoop.hbase.TableName; |
43 | 44 | import org.apache.hadoop.hbase.backup.impl.BackupAdminImpl; |
@@ -90,20 +91,19 @@ public abstract class IntegrationTestBackupRestoreBase extends IntegrationTestBa |
90 | 91 | protected static final int DEFAULT_NUM_ITERATIONS = 10; |
91 | 92 | protected static final int DEFAULT_ROWS_IN_ITERATION = 10000; |
92 | 93 | 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. |
94 | 95 | protected static final long SLEEP_TIME_DEFAULT = 50000L; |
95 | 96 | protected static String DEFAULT_BACKUP_ROOT_DIR = "backupIT"; |
96 | 97 |
|
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; |
104 | 104 | protected long sleepTime; |
105 | | - protected static Object lock = new Object(); |
106 | 105 |
|
| 106 | + protected static TableName[] tableNames; |
107 | 107 | protected FileSystem fs; |
108 | 108 | protected String backupRootDir; |
109 | 109 |
|
@@ -715,6 +715,40 @@ protected Set<String> getColumnFamilies() { |
715 | 715 | return null; |
716 | 716 | } |
717 | 717 |
|
| 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 | + |
718 | 752 | @Override |
719 | 753 | protected void addOptions() { |
720 | 754 | addOptWithArg(REGIONSERVER_COUNT_KEY, |
|
0 commit comments