From de7a5e48913ddf1b90cee79fd559675ac274940f Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Sat, 6 Mar 2010 14:12:44 -0800 Subject: [PATCH] Issue 162: updated to standard computeservice test --- gogrid/pom.xml | 15 +++- .../gogrid/GoGridComputeServiceLiveTest.java | 82 +++++++++++-------- .../samples/compute/build.properties.gogrid | 5 ++ 3 files changed, 63 insertions(+), 39 deletions(-) create mode 100644 tools/antcontrib/samples/compute/build.properties.gogrid diff --git a/gogrid/pom.xml b/gogrid/pom.xml index de18a8e761..dea80691e8 100644 --- a/gogrid/pom.xml +++ b/gogrid/pom.xml @@ -34,7 +34,7 @@ 4.0.0 org.jclouds jclouds-gogrid - jclouds GoGrid core + jclouds GoGrid compute jar jclouds components to access GoGrid @@ -44,15 +44,22 @@ http://jclouds.googlecode.com/svn/trunk/gogrid - apiKey - secret + ${jclouds.gogrid.apikey} + ${jclouds.gogrid.secret} ${project.groupId} - jclouds-core + jclouds-compute ${project.version} + + ${project.groupId} + jclouds-compute + ${project.version} + test-jar + test + ${project.groupId} jclouds-core diff --git a/gogrid/src/test/java/org/jclouds/gogrid/GoGridComputeServiceLiveTest.java b/gogrid/src/test/java/org/jclouds/gogrid/GoGridComputeServiceLiveTest.java index 70fab2b16f..bbbb1438b2 100644 --- a/gogrid/src/test/java/org/jclouds/gogrid/GoGridComputeServiceLiveTest.java +++ b/gogrid/src/test/java/org/jclouds/gogrid/GoGridComputeServiceLiveTest.java @@ -18,61 +18,73 @@ */ package org.jclouds.gogrid; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Iterables; +import static org.jclouds.compute.domain.OsFamily.CENTOS; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; + +import java.util.Map; + +import org.jclouds.compute.BaseComputeServiceLiveTest; import org.jclouds.compute.ComputeService; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.ComputeServiceContextFactory; import org.jclouds.compute.domain.ComputeMetadata; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.NodeState; import org.jclouds.compute.domain.Template; -import org.jclouds.logging.log4j.config.Log4JLoggingModule; +import org.jclouds.compute.domain.TemplateBuilder; +import org.jclouds.rest.RestContext; import org.jclouds.ssh.jsch.config.JschSshClientModule; -import org.testng.annotations.BeforeTest; +import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import static org.testng.Assert.*; - -import java.io.IOException; -import java.util.Map; - -import static com.google.common.base.Preconditions.checkNotNull; +import com.google.common.collect.Iterables; /** * @author Oleksiy Yarmula */ -public class GoGridComputeServiceLiveTest { +@Test(groups = "live", enabled = true, sequential = true, testName = "gogrid.GoGridComputeServiceLiveTest") +public class GoGridComputeServiceLiveTest extends BaseComputeServiceLiveTest { - private ComputeServiceContext context; + @BeforeClass + @Override + public void setServiceDefaults() { + service = "gogrid"; + } - @BeforeTest - public void setupClient() throws IOException { - String user = checkNotNull(System.getProperty("jclouds.test.user"), "jclouds.test.user"); - String password = checkNotNull(System.getProperty("jclouds.test.key"), "jclouds.test.key"); + protected Template buildTemplate(TemplateBuilder templateBuilder) { + return templateBuilder.osFamily(CENTOS).osDescriptionMatches(".*5.3.*").smallest().build(); + } - context = new ComputeServiceContextFactory().createContext("gogrid", user, password, - ImmutableSet.of(new Log4JLoggingModule(), new JschSshClientModule())); + @Override + protected JschSshClientModule getSshModule() { + return new JschSshClientModule(); + } - } + public void testAssignability() throws Exception { + @SuppressWarnings("unused") + RestContext tmContext = new ComputeServiceContextFactory() + .createContext(service, user, password).getProviderSpecificContext(); + } - @Test(enabled=false) - public void endToEndComputeServiceTest() { - ComputeService service = context.getComputeService(); - Template t = service.templateBuilder().minRam(1024).imageId("GSI-6890f8b6-c8fb-4ac1-bc33-2563eb4e29d2").build(); + @Test(enabled = false) + public void endToEndComputeServiceTest() { + ComputeService service = context.getComputeService(); + Template t = service.templateBuilder().minRam(1024).imageId( + "GSI-6890f8b6-c8fb-4ac1-bc33-2563eb4e29d2").build(); - assertEquals(t.getImage().getId(), "GSI-6890f8b6-c8fb-4ac1-bc33-2563eb4e29d2"); - service.runNodesWithTag("testTag", 1, t); + assertEquals(t.getImage().getId(), "GSI-6890f8b6-c8fb-4ac1-bc33-2563eb4e29d2"); + service.runNodesWithTag("testTag", 1, t); - Map nodes = service.getNodes(); - assertEquals(nodes.size(), 1); + Map nodes = service.getNodes(); + assertEquals(nodes.size(), 1); - NodeMetadata nodeMetadata = service.getNodeMetadata(Iterables.getOnlyElement(nodes.values())); - assertEquals(nodeMetadata.getPublicAddresses().size(), 1, "There must be 1 public address for the node"); - assertTrue(nodeMetadata.getName().startsWith("testTag")); - service.rebootNode(nodeMetadata); // blocks until finished + NodeMetadata nodeMetadata = service.getNodeMetadata(Iterables.getOnlyElement(nodes.values())); + assertEquals(nodeMetadata.getPublicAddresses().size(), 1, + "There must be 1 public address for the node"); + assertTrue(nodeMetadata.getName().startsWith("testTag")); + service.rebootNode(nodeMetadata); // blocks until finished - assertEquals(service.getNodeMetadata(nodeMetadata).getState(), NodeState.RUNNING); - service.destroyNode(nodeMetadata); - } + assertEquals(service.getNodeMetadata(nodeMetadata).getState(), NodeState.RUNNING); + service.destroyNode(nodeMetadata); + } } diff --git a/tools/antcontrib/samples/compute/build.properties.gogrid b/tools/antcontrib/samples/compute/build.properties.gogrid new file mode 100644 index 0000000000..03870339cb --- /dev/null +++ b/tools/antcontrib/samples/compute/build.properties.gogrid @@ -0,0 +1,5 @@ +service=gogrid +driver=gogrid +account=apikey_not_your_email +key=shared_secret_not_your_password +nodetag=name_of_your_server