You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by te...@apache.org on 2023/03/06 01:30:31 UTC
[pulsar] branch branch-2.11 updated: [improve][test] Add test `brokerReachThreshold` for ThresholdShedderTest (#18664)
This is an automated email from the ASF dual-hosted git repository.
technoboy pushed a commit to branch branch-2.11
in repository https://gitbox.apache.org/repos/asf/pulsar.git
The following commit(s) were added to refs/heads/branch-2.11 by this push:
new 35b4e173511 [improve][test] Add test `brokerReachThreshold` for ThresholdShedderTest (#18664)
35b4e173511 is described below
commit 35b4e1735112173fe56c51bb612edbd15e318d11
Author: Jiwei Guo <te...@apache.org>
AuthorDate: Tue Nov 29 16:02:37 2022 +0800
[improve][test] Add test `brokerReachThreshold` for ThresholdShedderTest (#18664)
---
.../loadbalance/impl/ThresholdShedderTest.java | 34 ++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/impl/ThresholdShedderTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/impl/ThresholdShedderTest.java
index 28c6b90759c..7f47c6d0fb9 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/impl/ThresholdShedderTest.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/impl/ThresholdShedderTest.java
@@ -89,6 +89,40 @@ public class ThresholdShedderTest {
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();