mirror of https://github.com/apache/jclouds.git
[SoftLayer] fix some failing LiveTests
fix VirtualGuestBlockDeviceTemplateGroupApiLiveTest fix SoftLayerComputeServiceLiveTest
This commit is contained in:
parent
30aca7d833
commit
cc1217b5c8
|
@ -46,7 +46,7 @@ public class DatacenterToLocation implements Function<Datacenter, Location> {
|
|||
public DatacenterToLocation(JustProvider provider) {
|
||||
this.provider = checkNotNull(provider, "provider");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Location apply(Datacenter datacenter) {
|
||||
return new LocationBuilder().id(datacenter.getName())
|
||||
|
@ -69,6 +69,6 @@ public class DatacenterToLocation implements Function<Datacenter, Location> {
|
|||
|
||||
return ImmutableSet.<String> of("" + country + "-" + state);
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -83,7 +83,7 @@ public class OperatingSystemToImage implements Function<OperatingSystem, Image>
|
|||
.build();
|
||||
|
||||
return new ImageBuilder()
|
||||
.ids(operatingSystem.getId())
|
||||
.ids(optOSReferenceCode.or(operatingSystem.getId()))
|
||||
.description(optOSReferenceCode.or(UNRECOGNIZED))
|
||||
.operatingSystem(os)
|
||||
.status(Image.Status.AVAILABLE)
|
||||
|
|
|
@ -16,10 +16,8 @@
|
|||
*/
|
||||
package org.jclouds.softlayer.compute.functions;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.FluentIterable;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.compute.domain.Hardware;
|
||||
import org.jclouds.compute.domain.HardwareBuilder;
|
||||
import org.jclouds.compute.domain.Processor;
|
||||
|
@ -28,7 +26,10 @@ import org.jclouds.compute.domain.internal.VolumeImpl;
|
|||
import org.jclouds.softlayer.domain.VirtualGuest;
|
||||
import org.jclouds.softlayer.domain.VirtualGuestBlockDevice;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.FluentIterable;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
@Singleton
|
||||
public class VirtualGuestToHardware implements Function<VirtualGuest, Hardware> {
|
||||
|
|
|
@ -16,8 +16,12 @@
|
|||
*/
|
||||
package org.jclouds.softlayer.compute.functions;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.inject.Inject;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.compute.domain.Image;
|
||||
import org.jclouds.compute.domain.ImageBuilder;
|
||||
import org.jclouds.compute.domain.OperatingSystem;
|
||||
|
@ -26,11 +30,8 @@ import org.jclouds.compute.reference.ComputeServiceConstants;
|
|||
import org.jclouds.logging.Logger;
|
||||
import org.jclouds.softlayer.domain.VirtualGuest;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.inject.Inject;
|
||||
|
||||
@Singleton
|
||||
public class VirtualGuestToImage implements Function<VirtualGuest, Image> {
|
||||
|
@ -52,7 +53,7 @@ public class VirtualGuestToImage implements Function<VirtualGuest, Image> {
|
|||
public Image apply(VirtualGuest from) {
|
||||
checkNotNull(from, "from");
|
||||
if (from.getOperatingSystem() == null) {
|
||||
return new ImageBuilder().ids(from.getId() + "")
|
||||
return new ImageBuilder().ids(getReferenceCodeOrId(from))
|
||||
.name(from.getHostname())
|
||||
.status(Image.Status.UNRECOGNIZED)
|
||||
.operatingSystem(OperatingSystem.builder()
|
||||
|
@ -65,4 +66,12 @@ public class VirtualGuestToImage implements Function<VirtualGuest, Image> {
|
|||
return operatingSystemToImage.apply(from.getOperatingSystem());
|
||||
}
|
||||
}
|
||||
|
||||
public String getReferenceCodeOrId(VirtualGuest from) {
|
||||
String val = from.getSoftwareLicense() != null &&
|
||||
from.getSoftwareLicense().getSoftwareDescription() != null ?
|
||||
from.getSoftwareLicense().getSoftwareDescription().getReferenceCode() :
|
||||
from.getId() + "";
|
||||
return val;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,7 +32,9 @@ import org.jclouds.compute.domain.NodeMetadata.Status;
|
|||
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
||||
import org.jclouds.compute.functions.GroupNamingConvention;
|
||||
import org.jclouds.domain.Location;
|
||||
import org.jclouds.domain.LoginCredentials;
|
||||
import org.jclouds.location.predicates.LocationPredicates;
|
||||
import org.jclouds.softlayer.domain.Password;
|
||||
import org.jclouds.softlayer.domain.TagReference;
|
||||
import org.jclouds.softlayer.domain.VirtualGuest;
|
||||
|
||||
|
@ -40,6 +42,7 @@ import com.google.common.base.Function;
|
|||
import com.google.common.base.Supplier;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
@Singleton
|
||||
|
@ -55,6 +58,7 @@ public class VirtualGuestToNodeMetadata implements Function<VirtualGuest, NodeMe
|
|||
private final VirtualGuestToImage virtualGuestToImage;
|
||||
private final VirtualGuestToHardware virtualGuestToHardware;
|
||||
|
||||
|
||||
@Inject
|
||||
VirtualGuestToNodeMetadata(@Memoized Supplier<Set<? extends Location>> locations,
|
||||
GroupNamingConvention.Factory namingConvention, VirtualGuestToImage virtualGuestToImage,
|
||||
|
@ -89,6 +93,11 @@ public class VirtualGuestToNodeMetadata implements Function<VirtualGuest, NodeMe
|
|||
builder.publicAddresses(ImmutableSet.of(from.getPrimaryIpAddress()));
|
||||
if (from.getPrimaryBackendIpAddress() != null)
|
||||
builder.privateAddresses(ImmutableSet.of(from.getPrimaryBackendIpAddress()));
|
||||
// TODO simplify once we move domain classes to AutoValue
|
||||
if (from.getOperatingSystem() != null && from.getOperatingSystem().getPasswords() != null && !from.getOperatingSystem().getPasswords().isEmpty()) {
|
||||
Password password = Iterables.getOnlyElement(from.getOperatingSystem().getPasswords());
|
||||
builder.credentials(LoginCredentials.builder().identity(password.getUsername()).credential(password.getPassword()).build());
|
||||
}
|
||||
if (from.getTagReferences() != null && !from.getTagReferences().isEmpty()) {
|
||||
List<String> tags = Lists.newArrayList();
|
||||
for (TagReference tagReference : from.getTagReferences()) {
|
||||
|
|
|
@ -22,24 +22,18 @@ import java.util.Set;
|
|||
import javax.annotation.Resource;
|
||||
import javax.inject.Named;
|
||||
|
||||
import org.jclouds.ContextBuilder;
|
||||
import org.jclouds.compute.ComputeServiceContext;
|
||||
import org.jclouds.compute.RunNodesException;
|
||||
import org.jclouds.compute.domain.ExecResponse;
|
||||
import org.jclouds.compute.domain.NodeMetadata;
|
||||
import org.jclouds.compute.domain.Template;
|
||||
import org.jclouds.compute.domain.TemplateBuilder;
|
||||
import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
|
||||
import org.jclouds.compute.reference.ComputeServiceConstants;
|
||||
import org.jclouds.logging.Logger;
|
||||
import org.jclouds.logging.slf4j.config.SLF4JLoggingModule;
|
||||
import org.jclouds.softlayer.compute.options.SoftLayerTemplateOptions;
|
||||
import org.jclouds.ssh.SshClient;
|
||||
import org.jclouds.sshj.config.SshjSshClientModule;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
@Test(groups = "live", testName = "SoftLayerComputeServiceContextLiveTest")
|
||||
public class SoftLayerComputeServiceContextLiveTest extends BaseComputeServiceContextLiveTest {
|
||||
|
@ -53,34 +47,26 @@ public class SoftLayerComputeServiceContextLiveTest extends BaseComputeServiceCo
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testLaunchClusterWithMinDisk() throws RunNodesException {
|
||||
public void testLaunchClusterWithDomainName() throws RunNodesException {
|
||||
int numNodes = 1;
|
||||
final String name = "node";
|
||||
ComputeServiceContext context = ContextBuilder.newBuilder("softlayer").credentials(identity, credential)
|
||||
.modules(ImmutableSet.of(new SLF4JLoggingModule(),
|
||||
new SshjSshClientModule()))
|
||||
.build(ComputeServiceContext.class);
|
||||
|
||||
TemplateBuilder templateBuilder = context.getComputeService().templateBuilder();
|
||||
|
||||
Template template = templateBuilder.build();
|
||||
Template template = view.getComputeService().templateBuilder().build();
|
||||
// test passing custom options
|
||||
SoftLayerTemplateOptions options = template.getOptions().as(SoftLayerTemplateOptions.class);
|
||||
options.domainName("live.org");
|
||||
options.portSpeed(100);
|
||||
|
||||
//tags
|
||||
options.tags(ImmutableList.of("jclouds"));
|
||||
|
||||
Set<? extends NodeMetadata> nodes = context.getComputeService().createNodesInGroup(name, numNodes, template);
|
||||
Set<? extends NodeMetadata> nodes = view.getComputeService().createNodesInGroup(name, numNodes, template);
|
||||
assertEquals(numNodes, nodes.size(), "wrong number of nodes");
|
||||
for (NodeMetadata node : nodes) {
|
||||
logger.debug("Created Node: %s", node);
|
||||
SshClient client = context.utils().sshForNode().apply(node);
|
||||
SshClient client = view.utils().sshForNode().apply(node);
|
||||
client.connect();
|
||||
ExecResponse hello = client.exec("mount");
|
||||
logger.debug(hello.getOutput().trim());
|
||||
context.getComputeService().destroyNode(node.getId());
|
||||
view.getComputeService().destroyNode(node.getId());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,10 +26,6 @@ import org.testng.annotations.Test;
|
|||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.inject.Module;
|
||||
|
||||
/**
|
||||
*
|
||||
* Generally disabled, as it incurs higher fees.
|
||||
*/
|
||||
@Test(groups = "live", enabled = true, singleThreaded = true)
|
||||
public class SoftLayerComputeServiceLiveTest extends BaseComputeServiceLiveTest {
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ public class OperatingSystemToImageTest {
|
|||
@Test
|
||||
public void testOperatingSystemToImage() {
|
||||
OperatingSystem operatingSystem = OperatingSystem.builder()
|
||||
.id("123456789")
|
||||
.id("UBUNTU_12_64")
|
||||
.softwareLicense(SoftwareLicense.builder()
|
||||
.softwareDescription(SoftwareDescription.builder()
|
||||
.version("12.04-64 Minimal for CCI")
|
||||
|
|
|
@ -48,20 +48,21 @@ import com.google.inject.Module;
|
|||
@Test(groups = "live")
|
||||
public class VirtualGuestApiLiveTest extends BaseSoftLayerApiLiveTest {
|
||||
|
||||
public static final String DATACENTER = "dal05";
|
||||
|
||||
private VirtualGuestApi virtualGuestApi;
|
||||
private Predicate<VirtualGuest> loginDetailsTester;
|
||||
private VirtualGuestHasLoginDetailsPresent virtualGuestHasLoginDetailsPresent;
|
||||
private long guestLoginDelay = 60 * 60 * 1000;
|
||||
|
||||
private VirtualGuest virtualGuest = null;
|
||||
private Datacenter datacenter = null;
|
||||
|
||||
@BeforeClass(groups = {"integration", "live"})
|
||||
@Override
|
||||
public void setup() {
|
||||
super.setup();
|
||||
virtualGuestApi = api.getVirtualGuestApi();
|
||||
datacenter = Iterables.get(api.getDatacenterApi().listDatacenters(), 0);
|
||||
assertNotNull(datacenter, "Datacenter must not be null");
|
||||
}
|
||||
|
||||
@AfterClass(groups = {"integration", "live"})
|
||||
|
@ -94,7 +95,7 @@ public class VirtualGuestApiLiveTest extends BaseSoftLayerApiLiveTest {
|
|||
.startCpus(1)
|
||||
.maxMemory(1024)
|
||||
.operatingSystem(OperatingSystem.builder().id("CENTOS_6_64").operatingSystemReferenceCode("CENTOS_6_64").build())
|
||||
.datacenter(Datacenter.builder().name(DATACENTER).build())
|
||||
.datacenter(Datacenter.builder().name(datacenter.getName()).build())
|
||||
.build();
|
||||
|
||||
virtualGuest = virtualGuestApi.createVirtualGuest(virtualGuestRequest);
|
||||
|
|
|
@ -33,6 +33,7 @@ import com.beust.jcommander.internal.Sets;
|
|||
public class VirtualGuestBlockDeviceTemplateGroupApiLiveTest extends BaseSoftLayerApiLiveTest {
|
||||
|
||||
Set<VirtualGuestBlockDeviceTemplateGroup> publicImages = Sets.newHashSet();
|
||||
|
||||
@BeforeClass
|
||||
void init() {
|
||||
publicImages = api().getPublicImages();
|
||||
|
|
Loading…
Reference in New Issue