diff --git a/core/src/test/java/org/jclouds/apis/BaseApiLiveTest.java b/core/src/test/java/org/jclouds/apis/BaseApiLiveTest.java index 194c3fff4f..e3e4e07203 100644 --- a/core/src/test/java/org/jclouds/apis/BaseApiLiveTest.java +++ b/core/src/test/java/org/jclouds/apis/BaseApiLiveTest.java @@ -24,6 +24,7 @@ import static org.jclouds.util.Closeables2.closeQuietly; import java.io.Closeable; import java.util.NoSuchElementException; import java.util.Properties; +import java.util.Set; import java.util.logging.Logger; import org.jclouds.ContextBuilder; @@ -34,7 +35,9 @@ import org.jclouds.providers.Providers; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; +import com.google.common.base.Splitter; import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Sets; import com.google.common.reflect.TypeToken; import com.google.inject.Module; @@ -74,6 +77,20 @@ public abstract class BaseApiLiveTest { return null; } + /** + * This helps live testing against specific zones only. + * @param zones A list of zones, usually from getConfiguredZones() + * @return a set of zones in the given set that are also contained in the set specified by the test.live.zones system property + */ + protected Set filterZones(Set zones) { + String zonesToList = System.getProperty("test.live.zones"); + if(zonesToList == null) { + return zones; // no filter applied + } + Set zoneFilter = Sets.newHashSet(Splitter.on(',').split(zonesToList)); + return Sets.intersection(zones, zoneFilter); + } + @BeforeClass(groups = { "integration", "live" }) public void setup() { initialize();