This is an automated email from the ASF dual-hosted git repository.
pan3793 pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/hadoop.git
The following commit(s) were added to refs/heads/trunk by this push:
new 6cee8fe4da1 HADOOP-19911. Fix flaky TestBalancerLongRunningTasks
(#8534)
6cee8fe4da1 is described below
commit 6cee8fe4da1b247fc08c8617e266c7d1a5ee8bef
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 12821561c4b..d1bd158dda6 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
@@ -106,9 +106,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();
}
}
@@ -822,18 +826,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]