From c64f89f2c7625635c5d9b447234e284467afd169 Mon Sep 17 00:00:00 2001 From: Richard Downer Date: Tue, 20 Dec 2011 16:24:26 +0000 Subject: [PATCH] Protect against a potential infinite loop --- .../cloudstack/features/LoadBalancerClientLiveTest.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/LoadBalancerClientLiveTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/LoadBalancerClientLiveTest.java index aad14fcbd8..2c1e315aea 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/LoadBalancerClientLiveTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/LoadBalancerClientLiveTest.java @@ -20,6 +20,7 @@ package org.jclouds.cloudstack.features; import static com.google.common.collect.Iterables.find; import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertTrue; import java.io.IOException; @@ -87,7 +88,8 @@ public class LoadBalancerClientLiveTest extends BaseCloudStackClientLiveTest { public void testCreateLoadBalancerRule() throws Exception { if (networksDisabled) return; - while (rule == null) { + int attempts = 0; + while (rule == null && attempts < 50) { ip = reuseOrAssociate.apply(network); try { rule = client.getLoadBalancerClient().createLoadBalancerRuleForPublicIP(ip.getId(), Algorithm.LEASTCONN, @@ -96,6 +98,7 @@ public class LoadBalancerClientLiveTest extends BaseCloudStackClientLiveTest { // very likely an ip conflict, so retry; } } + assertNotNull(rule, "Failed to get a load balancer rule after "+attempts+" attempts"); assert (rule.getPublicIPId() == ip.getId()) : rule; assertEquals(rule.getPublicPort(), 22); assertEquals(rule.getPrivatePort(), 22);