Retry loop did not increment the counter, so it would never actually terminate after repeated failures. Also decreased the number of attempts from 50 to 10, as 50 took too long to fail.

This commit is contained in:
Richard Downer 2011-12-21 18:12:02 +00:00
parent 4def02f00e
commit 21105f8322
1 changed files with 2 additions and 1 deletions

View File

@ -89,13 +89,14 @@ public class LoadBalancerClientLiveTest extends BaseCloudStackClientLiveTest {
if (networksDisabled) if (networksDisabled)
return; return;
int attempts = 0; int attempts = 0;
while (rule == null && attempts < 50) { while (rule == null && attempts < 10) {
ip = reuseOrAssociate.apply(network); ip = reuseOrAssociate.apply(network);
try { try {
rule = client.getLoadBalancerClient().createLoadBalancerRuleForPublicIP(ip.getId(), Algorithm.LEASTCONN, rule = client.getLoadBalancerClient().createLoadBalancerRuleForPublicIP(ip.getId(), Algorithm.LEASTCONN,
prefix, 22, 22); prefix, 22, 22);
} catch (IllegalStateException e) { } catch (IllegalStateException e) {
// very likely an ip conflict, so retry; // very likely an ip conflict, so retry;
attempts++;
} }
} }
assertNotNull(rule, "Failed to get a load balancer rule after "+attempts+" attempts"); assertNotNull(rule, "Failed to get a load balancer rule after "+attempts+" attempts");