Skip to content

Commit 2b428bf

Browse files
committed
HBASE-30073 Test fixes for some flappers and a reproducible error (#8057) (#8082)
Signed-off by: Charles Connell <cconnell@apache.org>
1 parent a0c4abb commit 2b428bf

File tree

11 files changed

+142
-538
lines changed

11 files changed

+142
-538
lines changed

hbase-common/src/test/java/org/apache/hadoop/hbase/HBaseJupiterExtension.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public class HBaseJupiterExtension implements InvocationInterceptor, BeforeAllCa
8484

8585
private static final Map<String, Duration> TAG_TO_TIMEOUT =
8686
ImmutableMap.of(SmallTests.TAG, Duration.ofMinutes(3), MediumTests.TAG, Duration.ofMinutes(6),
87-
LargeTests.TAG, Duration.ofMinutes(13), IntegrationTests.TAG, Duration.ZERO);
87+
LargeTests.TAG, Duration.ofMinutes(20), IntegrationTests.TAG, Duration.ZERO);
8888

8989
private static final String EXECUTOR = "executor";
9090

hbase-compression/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@
4545
<artifactId>hbase-resource-bundle</artifactId>
4646
<optional>true</optional>
4747
</dependency>
48+
<dependency>
49+
<groupId>org.junit.jupiter</groupId>
50+
<artifactId>junit-jupiter-api</artifactId>
51+
<scope>test</scope>
52+
</dependency>
4853
</dependencies>
4954

5055
<build>

hbase-server/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,10 @@ protected List<RegionPlan> balanceTable(TableName tableName,
631631
currentCost / sumMultiplier, functionCost(), computedMaxSteps);
632632

633633
final String initFunctionTotalCosts = totalCostsPerFunc();
634+
long searchStartTime = EnvironmentEdgeManager.currentTime();
635+
// Budget maxRunningTime for the stochastic walk only; initialization (cluster costs, etc.)
636+
// can be substantial on busy hosts and must not consume the search deadline.
637+
cluster.setStopRequestedAt(searchStartTime + maxRunningTime);
634638
// Perform a stochastic walk to see if we can get a good fit.
635639
long step;
636640
Map<Class<? extends CandidateGenerator>, Long> generatorToStepCount = new HashMap<>();

hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,13 @@ private void createSubDirAndSystemProperty(String propertyName, Path parent, Str
489489

490490
String sysValue = System.getProperty(propertyName);
491491

492-
if (sysValue != null) {
492+
// Check if directory sharing should be disabled for this test.
493+
// Tests that run with high parallelism and don't need shared directories can set this
494+
// to avoid race conditions where one test's tearDown() deletes directories another test
495+
// is still using.
496+
boolean disableSharing = conf.getBoolean("hbase.test.disable-directory-sharing", false);
497+
498+
if (sysValue != null && !disableSharing) {
493499
// There is already a value set. So we do nothing but hope
494500
// that there will be no conflicts
495501
LOG.info("System.getProperty(\"" + propertyName + "\") already set to: " + sysValue
@@ -502,7 +508,7 @@ private void createSubDirAndSystemProperty(String propertyName, Path parent, Str
502508
}
503509
conf.set(propertyName, sysValue);
504510
} else {
505-
// Ok, it's not set, so we create it as a subdirectory
511+
// Ok, it's not set (or sharing is disabled), so we create it as a subdirectory
506512
createSubDir(propertyName, parent, subDirName);
507513
System.setProperty(propertyName, conf.get(propertyName));
508514
}

hbase-server/src/test/java/org/apache/hadoop/hbase/TestZooKeeper.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ public static void setUpBeforeClass() throws Exception {
7777
conf.setInt(HConstants.ZK_SESSION_TIMEOUT, 1000);
7878
conf.setClass(HConstants.HBASE_MASTER_LOADBALANCER_CLASS, MockLoadBalancer.class,
7979
LoadBalancer.class);
80-
TEST_UTIL.startMiniDFSCluster(2);
8180
}
8281

8382
@AfterAll

hbase-server/src/test/java/org/apache/hadoop/hbase/client/AbstractTestAsyncTableScan.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
import java.util.stream.Stream;
4747
import org.apache.hadoop.conf.Configuration;
4848
import org.apache.hadoop.hbase.ConnectionRule;
49+
import org.apache.hadoop.hbase.HBaseConfiguration;
4950
import org.apache.hadoop.hbase.HBaseTestingUtility;
5051
import org.apache.hadoop.hbase.MatcherPredicate;
5152
import org.apache.hadoop.hbase.MiniClusterRule;
@@ -73,8 +74,21 @@
7374
public abstract class AbstractTestAsyncTableScan {
7475

7576
protected static final OpenTelemetryClassRule OTEL_CLASS_RULE = OpenTelemetryClassRule.create();
76-
protected static final MiniClusterRule MINI_CLUSTER_RULE = MiniClusterRule.newBuilder()
77-
.setMiniClusterOption(StartMiniClusterOption.builder().numWorkers(3).build()).build();
77+
78+
private static Configuration createConfiguration() {
79+
// Use HBaseConfiguration.create() instead of new Configuration() to properly load
80+
// hbase-default.xml which contains required default values (e.g. for log cleaner plugins)
81+
Configuration conf = HBaseConfiguration.create();
82+
// Disable directory sharing to prevent race conditions when tests run in parallel.
83+
// Each test instance gets its own isolated directories to avoid one test's tearDown()
84+
// deleting directories another parallel test is still using.
85+
conf.setBoolean("hbase.test.disable-directory-sharing", true);
86+
return conf;
87+
}
88+
89+
protected static final MiniClusterRule MINI_CLUSTER_RULE =
90+
MiniClusterRule.newBuilder().setConfiguration(createConfiguration())
91+
.setMiniClusterOption(StartMiniClusterOption.builder().numWorkers(3).build()).build();
7892

7993
protected static final ConnectionRule CONN_RULE =
8094
ConnectionRule.createAsyncConnectionRule(MINI_CLUSTER_RULE::createAsyncConnection);

0 commit comments

Comments
 (0)