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
|
||||
protected Properties setupProperties() {
|
||||
Properties overrides = super.setupProperties();
|
||||
validatorIdentity = setIfTestSystemPropertyPresent(overrides, provider + ".validatorIdentity");
|
||||
validatorCredential = setIfTestSystemPropertyPresent(overrides, provider + ".validatorCredential");
|
||||
validatorIdentity = setIfTestSystemPropertyPresent(overrides, provider + ".validator.identity");
|
||||
validatorCredential = setCredentialFromPemFile(overrides, validatorIdentity, provider + ".validator.credential");
|
||||
return overrides;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,6 @@ import org.jclouds.chef.ChefContext;
|
|||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.common.io.Files;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
|
@ -48,17 +47,26 @@ public class BaseChefContextLiveTest extends BaseContextLiveTest<ChefContext> {
|
|||
*/
|
||||
@Override
|
||||
protected Properties setupProperties() {
|
||||
try {
|
||||
return super.setupProperties();
|
||||
} finally {
|
||||
if (Strings.isNullOrEmpty(credential))
|
||||
credential = System.getProperty("user.home") + "/.chef/" + identity + ".pem";
|
||||
try {
|
||||
credential = Files.toString(new File(credential), Charsets.UTF_8);
|
||||
} catch (IOException e) {
|
||||
throw Throwables.propagate(e);
|
||||
}
|
||||
}
|
||||
Properties overrides = super.setupProperties();
|
||||
credential = setCredentialFromPemFile(overrides, identity, provider + ".credential");
|
||||
return overrides;
|
||||
}
|
||||
|
||||
protected String setCredentialFromPemFile(Properties overrides, String identity, String key) {
|
||||
String val = null;
|
||||
String credentialFromFile = null;
|
||||
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
|
||||
|
|
|
@ -23,7 +23,9 @@ import static org.testng.Assert.assertEquals;
|
|||
import java.util.Set;
|
||||
|
||||
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 com.google.common.collect.ImmutableSet;
|
||||
|
@ -34,8 +36,17 @@ import com.google.common.collect.ImmutableSet;
|
|||
* @author Adrian Cole
|
||||
*/
|
||||
@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
|
||||
public void testExecute() {
|
||||
Set<String> runList = ImmutableSet.of("role[" + prefix + "]");
|
||||
|
@ -45,7 +56,7 @@ public class CreateNodeAndPopulateAutomaticAttributesImplLiveTest extends BaseSt
|
|||
Node node = context.getApi().getNode(prefix);
|
||||
assertEquals(node.getName(), prefix);
|
||||
assertEquals(node.getRunList(), runList);
|
||||
assertEquals(node.getAutomatic().get("foo").toString(), "\"bar\"");
|
||||
assertEquals(node.getAutomatic().get("current_user").toString(), currentUserProvider.get().toString());
|
||||
} finally {
|
||||
context.getApi().deleteNode(prefix);
|
||||
}
|
||||
|
|
|
@ -23,7 +23,9 @@ import static org.testng.Assert.assertEquals;
|
|||
import java.util.Set;
|
||||
|
||||
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 com.google.common.collect.ImmutableSet;
|
||||
|
@ -34,8 +36,16 @@ import com.google.common.collect.ImmutableSet;
|
|||
* @author Adrian Cole
|
||||
*/
|
||||
@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
|
||||
public void testExecute() {
|
||||
Set<String> runList = ImmutableSet.of("role[" + prefix + "]");
|
||||
|
@ -45,7 +55,7 @@ public class UpdateAutomaticAttributesOnNodeImplLiveTest extends BaseStubbedOhai
|
|||
Node node = context.getApi().getNode(prefix);
|
||||
assertEquals(node.getName(), prefix);
|
||||
assertEquals(node.getRunList(), runList);
|
||||
assertEquals(node.getAutomatic().get("foo").toString(), "\"bar\"");
|
||||
assertEquals(node.getAutomatic().get("current_user").toString(), currentUserProvider.get().toString());
|
||||
} finally {
|
||||
context.getApi().deleteNode(prefix);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue