Issue 162: updated to standard computeservice test

This commit is contained in:
Adrian Cole 2010-03-06 14:12:44 -08:00
parent 97a66a206b
commit de7a5e4891
3 changed files with 63 additions and 39 deletions

View File

@ -34,7 +34,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.jclouds</groupId>
<artifactId>jclouds-gogrid</artifactId>
<name>jclouds GoGrid core</name>
<name>jclouds GoGrid compute</name>
<packaging>jar</packaging>
<description>jclouds components to access GoGrid</description>
@ -44,15 +44,22 @@
<url>http://jclouds.googlecode.com/svn/trunk/gogrid</url>
</scm>
<properties>
<jclouds.test.user>apiKey</jclouds.test.user>
<jclouds.test.key>secret</jclouds.test.key>
<jclouds.test.user>${jclouds.gogrid.apikey}</jclouds.test.user>
<jclouds.test.key>${jclouds.gogrid.secret}</jclouds.test.key>
</properties>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>jclouds-core</artifactId>
<artifactId>jclouds-compute</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>jclouds-compute</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>jclouds-core</artifactId>

View File

@ -18,48 +18,59 @@
*/
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 {
private ComputeServiceContext context;
@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");
context = new ComputeServiceContextFactory().createContext("gogrid", user, password,
ImmutableSet.of(new Log4JLoggingModule(), new JschSshClientModule()));
@Test(groups = "live", enabled = true, sequential = true, testName = "gogrid.GoGridComputeServiceLiveTest")
public class GoGridComputeServiceLiveTest extends BaseComputeServiceLiveTest {
@BeforeClass
@Override
public void setServiceDefaults() {
service = "gogrid";
}
@Test(enabled=false)
protected Template buildTemplate(TemplateBuilder templateBuilder) {
return templateBuilder.osFamily(CENTOS).osDescriptionMatches(".*5.3.*").smallest().build();
}
@Override
protected JschSshClientModule getSshModule() {
return new JschSshClientModule();
}
public void testAssignability() throws Exception {
@SuppressWarnings("unused")
RestContext<GoGridAsyncClient, GoGridClient> 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();
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);
@ -68,7 +79,8 @@ public class GoGridComputeServiceLiveTest {
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");
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

View File

@ -0,0 +1,5 @@
service=gogrid
driver=gogrid
account=apikey_not_your_email
key=shared_secret_not_your_password
nodetag=name_of_your_server