Skip to content
Permalink
Browse files
Make the windows image optional
Skip tests if not present.
  • Loading branch information
neykov authored and nacx committed Mar 28, 2017
1 parent 76353e7 commit 57690d2b2522c98e6d54c33f2936794cb2cdee13
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
@@ -41,6 +41,10 @@ public class BoxToImage implements Function<Box, Image> {

@Override
public Image apply(Box input) {
if (input == null) {
return null;
}

OperatingSystem os = new OperatingSystem(inferOsFamily(input), input.getName(), input.getVersion(), null, input.getName(), true);
return new ImageBuilder()
.ids(input.getName())
@@ -20,6 +20,7 @@
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;

import java.util.NoSuchElementException;
import java.util.Set;

import org.jclouds.compute.ComputeService;
@@ -33,6 +34,7 @@
import org.jclouds.domain.LoginCredentials;
import org.jclouds.vagrant.internal.BoxConfig;
import org.jclouds.vagrant.reference.VagrantConstants;
import org.testng.SkipException;
import org.testng.annotations.Test;

import com.google.common.base.Optional;
@@ -70,7 +72,7 @@ protected TemplateBuilder templateBuilder() {
}

private String getImageId() {
return "boxcutter/eval-win7x86-enterprise";
return "boxcutter/eval-win2012r2-standard";
}

protected Template buildTemplate(TemplateBuilder templateBuilder) {
@@ -79,6 +81,8 @@ protected Template buildTemplate(TemplateBuilder templateBuilder) {

@Test
public void testGet() throws Exception {
skipIfImageNotPresent();

Set<? extends NodeMetadata> nodes = client.createNodesInGroup("vagrant-win", 1, buildTemplate(templateBuilder()));
NodeMetadata node = Iterables.getOnlyElement(nodes);
OperatingSystem os = node.getOperatingSystem();
@@ -95,6 +99,8 @@ public void testGet() throws Exception {

@Test
public void testBoxConfig() {
skipIfImageNotPresent();

Image image = view.getComputeService().getImage(getImageId());

BoxConfig.Factory boxConfigFactory = new BoxConfig.Factory();
@@ -103,4 +109,11 @@ public void testBoxConfig() {
assertEquals(boxConfig.getStringKey(".vm.communicator"), Optional.of("winrm"));
assertEquals(boxConfig.getKey(VagrantConstants.KEY_VM_GUEST), Optional.of(VagrantConstants.VM_GUEST_WINDOWS));
}

private void skipIfImageNotPresent() {
Image image = view.getComputeService().getImage(getImageId());
if (image == null) {
throw new SkipException("Image " + getImageId() + " not available. Skipping windows tests.");
}
}
}

0 comments on commit 57690d2

Please sign in to comment.