xds: fix flaky wrr test (#10004)

This commit is contained in:
yifeizhuang 2023-04-03 09:14:44 -07:00 committed by GitHub
parent 10f5e5afd6
commit bbe5a0227d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -638,7 +638,8 @@ public class WeightedRoundRobinLoadBalancerTest {
pickCount.put(result, pickCount.getOrDefault(result, 0) + 1);
}
for (int i = 0; i < capacity; i++) {
assertThat(Math.abs(pickCount.get(i) / 1000.0 - weights[i] / totalWeight) ).isAtMost(0.01);
assertThat(Math.abs(pickCount.getOrDefault(i, 0) / 1000.0 - weights[i] / totalWeight) )
.isAtMost(0.01);
}
}