This is an automated email from the ASF dual-hosted git repository.
pan3793 pushed a commit to branch branch-3.5
in repository https://gitbox.apache.org/repos/asf/hadoop.git
The following commit(s) were added to refs/heads/branch-3.5 by this push:
new 13a1ba12568 HADOOP-19911. Fix flaky TestBalancerLongRunningTasks
(#8534)
13a1ba12568 is described below
commit 13a1ba1256804546565e967c79d68c20ec8d0075
Author: Cheng Pan <[email protected]>
AuthorDate: Tue Jun 16 19:44:07 2026 +0800
HADOOP-19911. Fix flaky TestBalancerLongRunningTasks (#8534)
Reviewed-by: hualong <[email protected]>
Reviewed-by: Shilun Fan <[email protected]>
Signed-off-by: Cheng Pan <[email protected]>
---
.../balancer/TestBalancerLongRunningTasks.java | 34 +++++++++++++---------
1 file changed, 21 insertions(+), 13 deletions(-)
diff --git
a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/balancer/TestBalancerLongRunningTasks.java
b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/balancer/TestBalancerLongRunningTasks.java
index 3bf64977210..70d754ff0cc 100644
---
a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/balancer/TestBalancerLongRunningTasks.java
+++
b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/balancer/TestBalancerLongRunningTasks.java
@@ -104,9 +104,13 @@ public class TestBalancerLongRunningTasks {
@AfterEach
public void shutdown() throws Exception {
- if (cluster != null) {
- cluster.shutdown();
+ try {
+ if (cluster != null) {
+ cluster.shutdown();
+ }
+ } finally {
cluster = null;
+ DefaultMetricsSystem.shutdown();
}
}
@@ -820,18 +824,22 @@ public void testBalancerMetricsDuplicate() throws
Exception {
assertEquals(1, namenodes.size());
// Throw an error when we double-initialize BalancerMetrics
+ boolean oldValue = DefaultMetricsSystem.inMiniClusterMode();
DefaultMetricsSystem.setMiniClusterMode(false);
- MetricsSystem instance = DefaultMetricsSystem.instance();
- // Avoid the impact of cluster metric, remove cluster JvmMetrics
- instance.unregisterSource("JvmMetrics");
-
- final BalancerParameters balancerParameters = Balancer.Cli.parse(new
String[] {
- "-policy", BalancingPolicy.Node.INSTANCE.getName(),
- "-threshold", "10",
- });
- int r = Balancer.run(namenodes, nsIds, balancerParameters, conf);
- assertEquals(ExitStatus.SUCCESS.getExitCode(), r);
- DefaultMetricsSystem.setMiniClusterMode(true);
+ try {
+ MetricsSystem instance = DefaultMetricsSystem.instance();
+ // Avoid the impact of cluster metric, remove cluster JvmMetrics
+ instance.unregisterSource("JvmMetrics");
+
+ final BalancerParameters balancerParameters = Balancer.Cli.parse(new
String[] {
+ "-policy", BalancingPolicy.Node.INSTANCE.getName(),
+ "-threshold", "10",
+ });
+ int r = Balancer.run(namenodes, nsIds, balancerParameters, conf);
+ assertEquals(ExitStatus.SUCCESS.getExitCode(), r);
+ } finally {
+ DefaultMetricsSystem.setMiniClusterMode(oldValue);
+ }
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]