You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by vj...@apache.org on 2020/08/30 14:53:45 UTC
[hbase] branch branch-2.3 updated: HBASE-24894 [Flakey Test]
TestStochasticLoadBalancer.testMoveCostMultiplier
This is an automated email from the ASF dual-hosted git repository.
vjasani pushed a commit to branch branch-2.3
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/branch-2.3 by this push:
new df2a380 HBASE-24894 [Flakey Test] TestStochasticLoadBalancer.testMoveCostMultiplier
df2a380 is described below
commit df2a3808c515021d21b41552bb502ac1e38e60d2
Author: Zheng Wang <18...@qq.com>
AuthorDate: Sun Aug 30 20:08:28 2020 +0530
HBASE-24894 [Flakey Test] TestStochasticLoadBalancer.testMoveCostMultiplier
Closes #2270
Signed-off-by: Viraj Jasani <vj...@apache.org>
---
.../hadoop/hbase/master/balancer/TestStochasticLoadBalancer.java | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/balancer/TestStochasticLoadBalancer.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/balancer/TestStochasticLoadBalancer.java
index dcacfb5..f9e6a9e 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/master/balancer/TestStochasticLoadBalancer.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/master/balancer/TestStochasticLoadBalancer.java
@@ -29,6 +29,7 @@ import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Queue;
+import java.util.TimeZone;
import java.util.TreeMap;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.ClusterMetrics;
@@ -48,6 +49,7 @@ import org.apache.hadoop.hbase.master.balancer.StochasticLoadBalancer.ServerLoca
import org.apache.hadoop.hbase.testclassification.MasterTests;
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
@@ -214,9 +216,14 @@ public class TestStochasticLoadBalancer extends BalancerTestBase {
assertEquals(StochasticLoadBalancer.MoveCostFunction.DEFAULT_MOVE_COST,
costFunction.getMultiplier(), 0.01);
- //In offpeak hours, the multiplier of move cost should be lower
+ // In offpeak hours, the multiplier of move cost should be lower
conf.setInt("hbase.offpeak.start.hour",0);
conf.setInt("hbase.offpeak.end.hour",23);
+ // Set a fixed time which hour is 15, so it will always in offpeak
+ // See HBASE-24898 for more info of the calculation here
+ long deltaFor15 = TimeZone.getDefault().getRawOffset() - 28800000;
+ long timeFor15 = 1597907081000L - deltaFor15;
+ EnvironmentEdgeManager.injectEdge(() -> timeFor15);
costFunction = new StochasticLoadBalancer.MoveCostFunction(conf);
costFunction.init(cluster);
costFunction.cost();