mirror of https://github.com/apache/jclouds.git
Fix ProfitBricks TemplateBuilderLiveTests
This commit is contained in:
parent
243afed278
commit
59a88ff898
|
@ -16,6 +16,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.profitbricks;
|
package org.jclouds.profitbricks;
|
||||||
|
|
||||||
|
import static org.jclouds.Constants.PROPERTY_ISO3166_CODES;
|
||||||
import static org.jclouds.Constants.PROPERTY_SO_TIMEOUT;
|
import static org.jclouds.Constants.PROPERTY_SO_TIMEOUT;
|
||||||
import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_RUNNING;
|
import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_RUNNING;
|
||||||
import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_SUSPENDED;
|
import static org.jclouds.compute.config.ComputeServiceProperties.TIMEOUT_NODE_SUSPENDED;
|
||||||
|
@ -64,6 +65,9 @@ public class ProfitBricksProviderMetadata extends BaseProviderMetadata {
|
||||||
properties.setProperty(PROPERTY_REGION + ".de.zones", "de/fkb,de/fra");
|
properties.setProperty(PROPERTY_REGION + ".de.zones", "de/fkb,de/fra");
|
||||||
properties.setProperty(PROPERTY_REGION + ".us.zones", "us/las,us/lasdev");
|
properties.setProperty(PROPERTY_REGION + ".us.zones", "us/las,us/lasdev");
|
||||||
properties.setProperty(PROPERTY_ZONES, "de/fkb,de/fra,us/las,us/lasdev");
|
properties.setProperty(PROPERTY_ZONES, "de/fkb,de/fra,us/las,us/lasdev");
|
||||||
|
properties.setProperty(PROPERTY_ISO3166_CODES, "DE-BW,DE-HE,US_NV");
|
||||||
|
properties.setProperty(PROPERTY_REGION + ".de." + ISO3166_CODES, "DE-BW,DE-HE");
|
||||||
|
properties.setProperty(PROPERTY_REGION + ".us." + ISO3166_CODES, "US-NV");
|
||||||
properties.setProperty(PROPERTY_ZONE + ".de/fkb." + ISO3166_CODES, "DE-BW");
|
properties.setProperty(PROPERTY_ZONE + ".de/fkb." + ISO3166_CODES, "DE-BW");
|
||||||
properties.setProperty(PROPERTY_ZONE + ".de/fra." + ISO3166_CODES, "DE-HE");
|
properties.setProperty(PROPERTY_ZONE + ".de/fra." + ISO3166_CODES, "DE-HE");
|
||||||
properties.setProperty(PROPERTY_ZONE + ".us/las." + ISO3166_CODES, "US-NV");
|
properties.setProperty(PROPERTY_ZONE + ".us/las." + ISO3166_CODES, "US-NV");
|
||||||
|
|
|
@ -16,88 +16,23 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.profitbricks.compute;
|
package org.jclouds.profitbricks.compute;
|
||||||
|
|
||||||
import static org.jclouds.profitbricks.BaseProfitBricksLiveTest.testLocation;
|
|
||||||
import static org.jclouds.profitbricks.config.ProfitBricksComputeProperties.POLL_PREDICATE_DATACENTER;
|
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import com.google.common.base.Predicate;
|
|
||||||
import com.google.common.base.Supplier;
|
|
||||||
import com.google.common.collect.FluentIterable;
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
|
||||||
import com.google.inject.Key;
|
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
import com.google.inject.name.Names;
|
|
||||||
|
|
||||||
import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest;
|
import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest;
|
||||||
import org.jclouds.profitbricks.ProfitBricksApi;
|
|
||||||
import org.jclouds.profitbricks.domain.DataCenter;
|
|
||||||
import org.jclouds.profitbricks.features.DataCenterApi;
|
|
||||||
import org.testng.annotations.AfterClass;
|
|
||||||
import org.testng.annotations.BeforeClass;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
@Test(groups = "live", testName = "ProfitBricksTemplateBuilderLiveTest", singleThreaded = true)
|
@Test(groups = "live", testName = "ProfitBricksTemplateBuilderLiveTest", singleThreaded = true)
|
||||||
public class ProfitBricksTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest {
|
public class ProfitBricksTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest {
|
||||||
|
|
||||||
private static final String TEST_DC_NAME = "templateBuilderLiveTest-" + System.currentTimeMillis();
|
|
||||||
|
|
||||||
private DataCenter dataCenter;
|
|
||||||
|
|
||||||
public ProfitBricksTemplateBuilderLiveTest() {
|
public ProfitBricksTemplateBuilderLiveTest() {
|
||||||
this.provider = "profitbricks";
|
this.provider = "profitbricks";
|
||||||
}
|
}
|
||||||
|
|
||||||
@BeforeClass
|
|
||||||
@Override
|
|
||||||
public void setupContext() {
|
|
||||||
super.setupContext();
|
|
||||||
|
|
||||||
final DataCenterApi api = getDataCenterApi();
|
|
||||||
final Predicate<String> predicate = getDataCenterPredicate();
|
|
||||||
dataCenter = FluentIterable.from(api.getAllDataCenters()).firstMatch(new Predicate<DataCenter>() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean apply(DataCenter input) {
|
|
||||||
boolean match = Objects.equals(input.name(), TEST_DC_NAME);
|
|
||||||
if (match && input.location() == testLocation)
|
|
||||||
return predicate.apply(input.id());
|
|
||||||
return match;
|
|
||||||
}
|
|
||||||
}).or(new Supplier<DataCenter>() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public DataCenter get() {
|
|
||||||
DataCenter dataCenter = api.createDataCenter(
|
|
||||||
DataCenter.Request.creatingPayload(TEST_DC_NAME, testLocation));
|
|
||||||
predicate.apply(dataCenter.id());
|
|
||||||
|
|
||||||
return api.getDataCenter(dataCenter.id());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private Predicate<String> getDataCenterPredicate() {
|
|
||||||
return view.utils().injector().getInstance(Key.get(new TypeLiteral<Predicate<String>>() {
|
|
||||||
}, Names.named(POLL_PREDICATE_DATACENTER)));
|
|
||||||
}
|
|
||||||
|
|
||||||
private DataCenterApi getDataCenterApi() {
|
|
||||||
return view.unwrapApi(ProfitBricksApi.class).dataCenterApi();
|
|
||||||
}
|
|
||||||
|
|
||||||
@AfterClass(groups = {"integration", "live"}, alwaysRun = true)
|
|
||||||
@Override
|
|
||||||
protected void tearDownContext() {
|
|
||||||
super.tearDownContext();
|
|
||||||
if (dataCenter != null)
|
|
||||||
getDataCenterApi().deleteDataCenter(dataCenter.id());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Set<String> getIso3166Codes() {
|
protected Set<String> getIso3166Codes() {
|
||||||
return ImmutableSet.of();
|
return ImmutableSet.of("DE-BW", "DE-HE", "US-NV");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue