Skip to content

Commit

Permalink
[improve][test] Add test brokerReachThreshold for ThresholdShedderT…
Browse files Browse the repository at this point in the history
…est (apache#18664)
  • Loading branch information
Technoboy- authored and lifepuzzlefun committed Dec 9, 2022
1 parent 43ea63f commit c2d6cec
Showing 1 changed file with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,40 @@ public void testBrokerNotReachThreshold() {
assertTrue(thresholdShedder.findBundlesForUnloading(loadData, conf).isEmpty());
}

@Test
public void testBrokerReachThreshold() {
LoadData loadData = new LoadData();

LocalBrokerData broker1 = new LocalBrokerData();
broker1.setCpu(new ResourceUsage(140, 100));
broker1.setMemory(new ResourceUsage(10, 100));
broker1.setDirectMemory(new ResourceUsage(10, 100));
broker1.setBandwidthIn(new ResourceUsage(500, 1000));
broker1.setBandwidthOut(new ResourceUsage(500, 1000));
broker1.setBundles(Sets.newHashSet("bundle-1", "bundle-2"));
broker1.setMsgThroughputIn(Double.MAX_VALUE);

LocalBrokerData broker2 = new LocalBrokerData();
broker2.setCpu(new ResourceUsage(10, 100));
broker2.setMemory(new ResourceUsage(10, 100));
broker2.setDirectMemory(new ResourceUsage(10, 100));
broker2.setBandwidthIn(new ResourceUsage(500, 1000));
broker2.setBandwidthOut(new ResourceUsage(500, 1000));
broker2.setBundles(Sets.newHashSet("bundle-3", "bundle-4"));

BundleData bundleData = new BundleData();
TimeAverageMessageData timeAverageMessageData = new TimeAverageMessageData();
timeAverageMessageData.setMsgThroughputIn(1000);
timeAverageMessageData.setMsgThroughputOut(1000);
bundleData.setShortTermData(timeAverageMessageData);

loadData.getBundleData().put("bundle-2", bundleData);
loadData.getBrokerData().put("broker-2", new BrokerData(broker1));
loadData.getBrokerData().put("broker-3", new BrokerData(broker2));

assertFalse(thresholdShedder.findBundlesForUnloading(loadData, conf).isEmpty());
}

@Test
public void testBrokerWithSingleBundle() {
LoadData loadData = new LoadData();
Expand Down

0 comments on commit c2d6cec

Please sign in to comment.