mirror of https://github.com/apache/jclouds.git
Initial live test fixes:
* Disabled parallel integration test execution to avoid concurrent creation of the same node. * Fixed @Credential binding to bind the contents of the PEM file instead of the path. * Fixed validation identity and credential property loading. * TestOhaiModule did not use the overriden provider method. Changed strategy live tests to check against the current user as set by the CurrentUserProvider.
This commit is contained in:
parent
250722e9df
commit
ae857b4911
|
@ -90,8 +90,8 @@ public abstract class BaseChefClientLiveTest extends BaseChefContextLiveTest {
|
||||||
@Override
|
@Override
|
||||||
protected Properties setupProperties() {
|
protected Properties setupProperties() {
|
||||||
Properties overrides = super.setupProperties();
|
Properties overrides = super.setupProperties();
|
||||||
validatorIdentity = setIfTestSystemPropertyPresent(overrides, provider + ".validatorIdentity");
|
validatorIdentity = setIfTestSystemPropertyPresent(overrides, provider + ".validator.identity");
|
||||||
validatorCredential = setIfTestSystemPropertyPresent(overrides, provider + ".validatorCredential");
|
validatorCredential = setCredentialFromPemFile(overrides, validatorIdentity, provider + ".validator.credential");
|
||||||
return overrides;
|
return overrides;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,6 @@ import org.jclouds.chef.ChefContext;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.base.Charsets;
|
import com.google.common.base.Charsets;
|
||||||
import com.google.common.base.Strings;
|
|
||||||
import com.google.common.base.Throwables;
|
import com.google.common.base.Throwables;
|
||||||
import com.google.common.io.Files;
|
import com.google.common.io.Files;
|
||||||
import com.google.common.reflect.TypeToken;
|
import com.google.common.reflect.TypeToken;
|
||||||
|
@ -48,17 +47,26 @@ public class BaseChefContextLiveTest extends BaseContextLiveTest<ChefContext> {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected Properties setupProperties() {
|
protected Properties setupProperties() {
|
||||||
try {
|
Properties overrides = super.setupProperties();
|
||||||
return super.setupProperties();
|
credential = setCredentialFromPemFile(overrides, identity, provider + ".credential");
|
||||||
} finally {
|
return overrides;
|
||||||
if (Strings.isNullOrEmpty(credential))
|
}
|
||||||
credential = System.getProperty("user.home") + "/.chef/" + identity + ".pem";
|
|
||||||
try {
|
protected String setCredentialFromPemFile(Properties overrides, String identity, String key) {
|
||||||
credential = Files.toString(new File(credential), Charsets.UTF_8);
|
String val = null;
|
||||||
} catch (IOException e) {
|
String credentialFromFile = null;
|
||||||
throw Throwables.propagate(e);
|
if (System.getProperties().containsKey("test." + key)) {
|
||||||
}
|
val = System.getProperty("test." + key);
|
||||||
}
|
} else {
|
||||||
|
val = System.getProperty("user.home") + "/.chef/" + identity + ".pem";
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
credentialFromFile = Files.toString(new File(val), Charsets.UTF_8);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw Throwables.propagate(e);
|
||||||
|
}
|
||||||
|
overrides.setProperty(key, credentialFromFile);
|
||||||
|
return credentialFromFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -23,7 +23,9 @@ import static org.testng.Assert.assertEquals;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.jclouds.chef.domain.Node;
|
import org.jclouds.chef.domain.Node;
|
||||||
import org.jclouds.chef.internal.BaseStubbedOhaiLiveTest;
|
import org.jclouds.chef.internal.BaseChefContextLiveTest;
|
||||||
|
import org.jclouds.ohai.config.OhaiModule.CurrentUserProvider;
|
||||||
|
import org.testng.annotations.BeforeClass;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
@ -34,8 +36,17 @@ import com.google.common.collect.ImmutableSet;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live", testName = "CreateNodeAndPopulateAutomaticAttributesImplLiveTest")
|
@Test(groups = "live", testName = "CreateNodeAndPopulateAutomaticAttributesImplLiveTest")
|
||||||
public class CreateNodeAndPopulateAutomaticAttributesImplLiveTest extends BaseStubbedOhaiLiveTest {
|
public class CreateNodeAndPopulateAutomaticAttributesImplLiveTest extends BaseChefContextLiveTest {
|
||||||
|
|
||||||
|
private CurrentUserProvider currentUserProvider;
|
||||||
|
|
||||||
|
@BeforeClass(groups = { "integration", "live" })
|
||||||
|
@Override
|
||||||
|
public void setupContext() {
|
||||||
|
super.setupContext();
|
||||||
|
this.currentUserProvider = context.utils().injector().getInstance(CurrentUserProvider.class);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testExecute() {
|
public void testExecute() {
|
||||||
Set<String> runList = ImmutableSet.of("role[" + prefix + "]");
|
Set<String> runList = ImmutableSet.of("role[" + prefix + "]");
|
||||||
|
@ -45,7 +56,7 @@ public class CreateNodeAndPopulateAutomaticAttributesImplLiveTest extends BaseSt
|
||||||
Node node = context.getApi().getNode(prefix);
|
Node node = context.getApi().getNode(prefix);
|
||||||
assertEquals(node.getName(), prefix);
|
assertEquals(node.getName(), prefix);
|
||||||
assertEquals(node.getRunList(), runList);
|
assertEquals(node.getRunList(), runList);
|
||||||
assertEquals(node.getAutomatic().get("foo").toString(), "\"bar\"");
|
assertEquals(node.getAutomatic().get("current_user").toString(), currentUserProvider.get().toString());
|
||||||
} finally {
|
} finally {
|
||||||
context.getApi().deleteNode(prefix);
|
context.getApi().deleteNode(prefix);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,9 @@ import static org.testng.Assert.assertEquals;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.jclouds.chef.domain.Node;
|
import org.jclouds.chef.domain.Node;
|
||||||
import org.jclouds.chef.internal.BaseStubbedOhaiLiveTest;
|
import org.jclouds.chef.internal.BaseChefContextLiveTest;
|
||||||
|
import org.jclouds.ohai.config.OhaiModule.CurrentUserProvider;
|
||||||
|
import org.testng.annotations.BeforeClass;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
@ -34,8 +36,16 @@ import com.google.common.collect.ImmutableSet;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "live", testName = "UpdateAutomaticAttributesOnNodeImplLiveTest")
|
@Test(groups = "live", testName = "UpdateAutomaticAttributesOnNodeImplLiveTest")
|
||||||
public class UpdateAutomaticAttributesOnNodeImplLiveTest extends BaseStubbedOhaiLiveTest {
|
public class UpdateAutomaticAttributesOnNodeImplLiveTest extends BaseChefContextLiveTest {
|
||||||
|
|
||||||
|
private CurrentUserProvider currentUserProvider;
|
||||||
|
|
||||||
|
@BeforeClass(groups = { "integration", "live" })
|
||||||
|
@Override
|
||||||
|
public void setupContext() {
|
||||||
|
super.setupContext();
|
||||||
|
this.currentUserProvider = context.utils().injector().getInstance(CurrentUserProvider.class);
|
||||||
|
}
|
||||||
@Test
|
@Test
|
||||||
public void testExecute() {
|
public void testExecute() {
|
||||||
Set<String> runList = ImmutableSet.of("role[" + prefix + "]");
|
Set<String> runList = ImmutableSet.of("role[" + prefix + "]");
|
||||||
|
@ -45,7 +55,7 @@ public class UpdateAutomaticAttributesOnNodeImplLiveTest extends BaseStubbedOhai
|
||||||
Node node = context.getApi().getNode(prefix);
|
Node node = context.getApi().getNode(prefix);
|
||||||
assertEquals(node.getName(), prefix);
|
assertEquals(node.getName(), prefix);
|
||||||
assertEquals(node.getRunList(), runList);
|
assertEquals(node.getRunList(), runList);
|
||||||
assertEquals(node.getAutomatic().get("foo").toString(), "\"bar\"");
|
assertEquals(node.getAutomatic().get("current_user").toString(), currentUserProvider.get().toString());
|
||||||
} finally {
|
} finally {
|
||||||
context.getApi().deleteNode(prefix);
|
context.getApi().deleteNode(prefix);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue