Skip to content
This repository has been archived by the owner on Jul 25, 2020. It is now read-only.

Commit

Permalink
Run live tests against a single, configurable imageId.
Browse files Browse the repository at this point in the history
  • Loading branch information
neykov committed Jan 10, 2017
1 parent 1c397bd commit 4cb8ba5
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 122 deletions.
29 changes: 29 additions & 0 deletions vagrant/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<test.vagrant.template>imageId=ubuntu/xenial64</test.vagrant.template>
<jclouds.osgi.export>org.jclouds.vagrant*;version="${project.version}"</jclouds.osgi.export>
<jclouds.osgi.import>org.jclouds*;version="${project.version}",*</jclouds.osgi.import>
</properties>
Expand Down Expand Up @@ -97,4 +98,32 @@
<scope>test</scope>
</dependency>
</dependencies>

<profiles>
<profile>
<id>live</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<executions>
<execution>
<id>integration</id>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<systemPropertyVariables>
<test.vagrant.template>${test.vagrant.template}</test.vagrant.template>
</systemPropertyVariables>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,38 @@
package org.jclouds.vagrant.compute;

import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;

import org.jclouds.compute.domain.Image;
import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
import org.jclouds.vagrant.internal.BoxConfig;
import org.jclouds.vagrant.reference.VagrantConstants;
import org.testng.annotations.Test;

import com.google.common.base.Optional;

@Test(groups = "live", singleThreaded = true, testName = "UbuntuXenialLiveTest")
public class UbuntuXenialLiveTest extends VagrantComputeServiceAdapterLiveTest {
@Test(groups = "live", testName = "BoxConfigLiveTest")
public class BoxConfigLiveTest extends BaseComputeServiceContextLiveTest {

@Override
protected String getImageId() {
// Uses non-default username and password for login
return "ubuntu/xenial64";
public BoxConfigLiveTest() {
provider = "vagrant";
}

@Test
public void testBoxConfig() {
Image image = view.getComputeService().getImage(getImageId());
public void testDefaultCredentials() {
Image image = view.getComputeService().getImage("ubuntu/trusty64");

BoxConfig.Factory boxConfigFactory = new BoxConfig.Factory();
BoxConfig boxConfig = boxConfigFactory.newInstance(image);

assertFalse(boxConfig.getStringKey(VagrantConstants.CONFIG_USERNAME).isPresent());
assertFalse(boxConfig.getStringKey(VagrantConstants.CONFIG_PASSWORD).isPresent());
}

@Test
public void testCustomUsernameAndPassword() {
Image image = view.getComputeService().getImage("ubuntu/xenial64");

BoxConfig.Factory boxConfigFactory = new BoxConfig.Factory();
BoxConfig boxConfig = boxConfigFactory.newInstance(image);
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,18 @@
*/
package org.jclouds.vagrant.compute;

import java.io.File;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;

import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.compute.domain.TemplateBuilder;
import org.jclouds.compute.domain.OsFamily;
import org.jclouds.compute.domain.Template;
import org.jclouds.compute.internal.BaseComputeServiceLiveTest;
import org.jclouds.sshj.config.SshjSshClientModule;
import org.jclouds.vagrant.reference.VagrantConstants;
import org.testng.annotations.Test;

import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.inject.Module;

public abstract class VagrantComputeServiceAdapterLiveTest extends BaseComputeServiceLiveTest {
public class VagrantComputeServiceAdapterLiveTest extends BaseComputeServiceLiveTest {

public VagrantComputeServiceAdapterLiveTest() {
provider = "vagrant";
Expand All @@ -43,24 +38,6 @@ protected Module getSshModule() {
return new SshjSshClientModule();
}

@Override
protected TemplateBuilder templateBuilder() {
return super.templateBuilder()
.imageId(getImageId());
}

@Override
protected Properties setupProperties() {
Properties overrides = super.setupProperties();
File testsHome = new File(VagrantConstants.JCLOUDS_VAGRANT_HOME_DEFAULT, "tests");
File imageHome = new File(testsHome, getImageId().replaceAll("/", "_"));
overrides.setProperty(VagrantConstants.JCLOUDS_VAGRANT_HOME, imageHome.getAbsolutePath());
Logger.getAnonymousLogger().log(Level.INFO, "Home for " + getImageId() + " at " + imageHome.getAbsolutePath());
return overrides;
}

protected abstract String getImageId();

@Override
@Test(enabled = true)
public void testCorrectAuthException() throws Exception {
Expand All @@ -86,4 +63,23 @@ public void testOptionToNotBlock() throws Exception {
// so can't return earlier.
}

@Override
@Test(enabled = true, dependsOnMethods = { "testCompareSizes" })
public void testAScriptExecutionAfterBootWithBasicTemplate() throws Exception {
// Fails on CentOS 7. Can't ssh back with user foo because SELinux not configured correctly.
// "foo" is created out of the /home folder, /over/ridden is not white listed with the correct context.
// Steps needed to configure SELinux before creating the user:
//
// semanage fcontext -a -e /home /over/ridden
// mkdir /over/ridden
// restorecon /over/ridden
// useradd -d /over/ridden/foo foo
//
// semanage is not available on a default install - needs "yum install policycoreutils-python"

Template template = buildTemplate(templateBuilder());
if (template.getImage().getOperatingSystem().getFamily() != OsFamily.CENTOS) {
super.testAScriptExecutionAfterBootWithBasicTemplate();
}
}
}

0 comments on commit 4cb8ba5

Please sign in to comment.