mirror of https://github.com/apache/jclouds.git
Issue 162: updated to standard computeservice test
This commit is contained in:
parent
97a66a206b
commit
de7a5e4891
|
@ -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>
|
||||
|
|
|
@ -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<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();
|
||||
@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<String, ? extends ComputeMetadata> nodes = service.getNodes();
|
||||
assertEquals(nodes.size(), 1);
|
||||
Map<String, ? extends ComputeMetadata> 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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
service=gogrid
|
||||
driver=gogrid
|
||||
account=apikey_not_your_email
|
||||
key=shared_secret_not_your_password
|
||||
nodetag=name_of_your_server
|
Loading…
Reference in New Issue