You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by al...@apache.org on 2021/08/21 08:37:26 UTC
[dubbo] branch 3.0 updated: Fix ShortestResponseLoadBalanceTest
failure (#8519)
This is an automated email from the ASF dual-hosted git repository.
albumenj pushed a commit to branch 3.0
in repository https://gitbox.apache.org/repos/asf/dubbo.git
The following commit(s) were added to refs/heads/3.0 by this push:
new 74fcf4d Fix ShortestResponseLoadBalanceTest failure (#8519)
74fcf4d is described below
commit 74fcf4d933fb2f38991cc94759e63482a70dd498
Author: lmj <10...@qq.com>
AuthorDate: Sat Aug 21 16:36:47 2021 +0800
Fix ShortestResponseLoadBalanceTest failure (#8519)
---
.../rpc/cluster/loadbalance/ShortestResponseLoadBalanceTest.java | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/dubbo-cluster/src/test/java/org/apache/dubbo/rpc/cluster/loadbalance/ShortestResponseLoadBalanceTest.java b/dubbo-cluster/src/test/java/org/apache/dubbo/rpc/cluster/loadbalance/ShortestResponseLoadBalanceTest.java
index cfc317f..345c370 100644
--- a/dubbo-cluster/src/test/java/org/apache/dubbo/rpc/cluster/loadbalance/ShortestResponseLoadBalanceTest.java
+++ b/dubbo-cluster/src/test/java/org/apache/dubbo/rpc/cluster/loadbalance/ShortestResponseLoadBalanceTest.java
@@ -97,14 +97,13 @@ public class ShortestResponseLoadBalanceTest extends LoadBalanceBaseTest {
}
}
Map<Invoker<LoadBalanceBaseTest>, Integer> weightMap = weightInvokersSR.stream()
- .collect(Collectors.toMap(Function.identity(), e -> Integer.valueOf(e.getUrl().getParameter("weight"))));
+ .collect(Collectors.toMap(Function.identity(), e -> Integer.valueOf(e.getUrl().getParameter("weight"))));
Integer totalWeight = weightMap.values().stream().reduce(0, Integer::sum);
- // max deviation 10%
+ // max deviation = expectWeightValue * 2
int expectWeightValue = loop / totalWeight;
- int maxDeviation = expectWeightValue / 10;
+ int maxDeviation = expectWeightValue * 2;
Assertions.assertEquals(sumInvoker1 + sumInvoker2 + sumInvoker5, loop, "select failed!");
- Assertions.assertTrue(Math.abs(sumInvoker1 / weightMap.get(weightInvoker1) - expectWeightValue) < maxDeviation, "select failed!");
Assertions.assertTrue(Math.abs(sumInvoker2 / weightMap.get(weightInvoker2) - expectWeightValue) < maxDeviation, "select failed!");
Assertions.assertTrue(Math.abs(sumInvoker5 / weightMap.get(weightInvoker5) - expectWeightValue) < maxDeviation, "select failed!");
}