Skip to content

Commit

Permalink
HBASE-24894 [Flakey Test] TestStochasticLoadBalancer.testMoveCostMult…
Browse files Browse the repository at this point in the history
…iplier

Closes #2270

Signed-off-by: Viraj Jasani <[email protected]>
  • Loading branch information
bsglz authored and virajjasani committed Aug 30, 2020
1 parent e022094 commit a765d85
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
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;
Expand All @@ -48,6 +49,7 @@
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;
Expand Down Expand Up @@ -214,9 +216,14 @@ public void testMoveCostMultiplier() throws Exception {
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();
Expand Down

0 comments on commit a765d85

Please sign in to comment.