isolated experimentlivetest so that it emulates as closely as possible client usage

This commit is contained in:
David Ribeiro Alves 2012-03-12 11:27:44 +00:00
parent 52514a77a5
commit 12a9b414e3
1 changed files with 17 additions and 5 deletions

View File

@ -26,35 +26,47 @@ import java.util.Set;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.inject.Named; import javax.inject.Named;
import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.compute.ComputeServiceContextFactory;
import org.jclouds.compute.RunNodesException; import org.jclouds.compute.RunNodesException;
import org.jclouds.compute.domain.ExecResponse; import org.jclouds.compute.domain.ExecResponse;
import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.compute.reference.ComputeServiceConstants; import org.jclouds.compute.reference.ComputeServiceConstants;
import org.jclouds.logging.Logger; import org.jclouds.logging.Logger;
import org.jclouds.logging.slf4j.config.SLF4JLoggingModule;
import org.jclouds.ssh.SshClient; import org.jclouds.ssh.SshClient;
import org.jclouds.virtualbox.BaseVirtualBoxClientLiveTest; import org.jclouds.sshj.config.SshjSshClientModule;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.base.Predicate; import com.google.common.base.Predicate;
import com.google.common.collect.ImmutableSet;
import com.google.inject.Module;
/** /**
* *
* @author Adrian Cole * @author Adrian Cole
*/ */
@Test(groups = "live", singleThreaded = true, testName = "VirtualBoxExperimentLiveTest") @Test(groups = "live", singleThreaded = true, testName = "VirtualBoxExperimentLiveTest")
public class VirtualBoxExperimentLiveTest extends BaseVirtualBoxClientLiveTest { public class VirtualBoxExperimentLiveTest {
@Resource @Resource
@Named(ComputeServiceConstants.COMPUTE_LOGGER) @Named(ComputeServiceConstants.COMPUTE_LOGGER)
protected Logger logger = Logger.NULL; protected Logger logger = Logger.NULL;
ComputeServiceContext context;
@BeforeClass
public void setUp() {
context = new ComputeServiceContextFactory().createContext("virtualbox", "toor", "password",
ImmutableSet.<Module> of(new SLF4JLoggingModule(), new SshjSshClientModule()));
}
@Test @Test
public void testLaunchCluster() throws RunNodesException { public void testLaunchCluster() throws RunNodesException {
int numNodes = 4; int numNodes = 4;
final String clusterName = "test-launch-cluster"; final String clusterName = "test-launch-cluster";
Set<? extends NodeMetadata> nodes = context.getComputeService().createNodesInGroup(clusterName, Set<? extends NodeMetadata> nodes = context.getComputeService().createNodesInGroup(clusterName, numNodes);
numNodes);
assertEquals(numNodes, nodes.size(), "wrong number of nodes"); assertEquals(numNodes, nodes.size(), "wrong number of nodes");
for (NodeMetadata node : nodes) { for (NodeMetadata node : nodes) {
logger.debug("Created Node: %s", node); logger.debug("Created Node: %s", node);