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>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>org.jclouds</groupId>
|
<groupId>org.jclouds</groupId>
|
||||||
<artifactId>jclouds-gogrid</artifactId>
|
<artifactId>jclouds-gogrid</artifactId>
|
||||||
<name>jclouds GoGrid core</name>
|
<name>jclouds GoGrid compute</name>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<description>jclouds components to access GoGrid</description>
|
<description>jclouds components to access GoGrid</description>
|
||||||
|
|
||||||
|
@ -44,15 +44,22 @@
|
||||||
<url>http://jclouds.googlecode.com/svn/trunk/gogrid</url>
|
<url>http://jclouds.googlecode.com/svn/trunk/gogrid</url>
|
||||||
</scm>
|
</scm>
|
||||||
<properties>
|
<properties>
|
||||||
<jclouds.test.user>apiKey</jclouds.test.user>
|
<jclouds.test.user>${jclouds.gogrid.apikey}</jclouds.test.user>
|
||||||
<jclouds.test.key>secret</jclouds.test.key>
|
<jclouds.test.key>${jclouds.gogrid.secret}</jclouds.test.key>
|
||||||
</properties>
|
</properties>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>${project.groupId}</groupId>
|
<groupId>${project.groupId}</groupId>
|
||||||
<artifactId>jclouds-core</artifactId>
|
<artifactId>jclouds-compute</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>${project.groupId}</groupId>
|
||||||
|
<artifactId>jclouds-compute</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<type>test-jar</type>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>${project.groupId}</groupId>
|
<groupId>${project.groupId}</groupId>
|
||||||
<artifactId>jclouds-core</artifactId>
|
<artifactId>jclouds-core</artifactId>
|
||||||
|
|
|
@ -18,61 +18,73 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.gogrid;
|
package org.jclouds.gogrid;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import static org.jclouds.compute.domain.OsFamily.CENTOS;
|
||||||
import com.google.common.collect.Iterables;
|
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.ComputeService;
|
||||||
import org.jclouds.compute.ComputeServiceContext;
|
|
||||||
import org.jclouds.compute.ComputeServiceContextFactory;
|
import org.jclouds.compute.ComputeServiceContextFactory;
|
||||||
import org.jclouds.compute.domain.ComputeMetadata;
|
import org.jclouds.compute.domain.ComputeMetadata;
|
||||||
import org.jclouds.compute.domain.NodeMetadata;
|
import org.jclouds.compute.domain.NodeMetadata;
|
||||||
import org.jclouds.compute.domain.NodeState;
|
import org.jclouds.compute.domain.NodeState;
|
||||||
import org.jclouds.compute.domain.Template;
|
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.jclouds.ssh.jsch.config.JschSshClientModule;
|
||||||
import org.testng.annotations.BeforeTest;
|
import org.testng.annotations.BeforeClass;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
import static org.testng.Assert.*;
|
|
||||||
|
|
||||||
|
import com.google.common.collect.Iterables;
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Oleksiy Yarmula
|
* @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
|
protected Template buildTemplate(TemplateBuilder templateBuilder) {
|
||||||
public void setupClient() throws IOException {
|
return templateBuilder.osFamily(CENTOS).osDescriptionMatches(".*5.3.*").smallest().build();
|
||||||
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,
|
@Override
|
||||||
ImmutableSet.of(new Log4JLoggingModule(), new JschSshClientModule()));
|
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)
|
@Test(enabled = false)
|
||||||
public void endToEndComputeServiceTest() {
|
public void endToEndComputeServiceTest() {
|
||||||
ComputeService service = context.getComputeService();
|
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");
|
assertEquals(t.getImage().getId(), "GSI-6890f8b6-c8fb-4ac1-bc33-2563eb4e29d2");
|
||||||
service.runNodesWithTag("testTag", 1, t);
|
service.runNodesWithTag("testTag", 1, t);
|
||||||
|
|
||||||
Map<String, ? extends ComputeMetadata> nodes = service.getNodes();
|
Map<String, ? extends ComputeMetadata> nodes = service.getNodes();
|
||||||
assertEquals(nodes.size(), 1);
|
assertEquals(nodes.size(), 1);
|
||||||
|
|
||||||
NodeMetadata nodeMetadata = service.getNodeMetadata(Iterables.getOnlyElement(nodes.values()));
|
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,
|
||||||
assertTrue(nodeMetadata.getName().startsWith("testTag"));
|
"There must be 1 public address for the node");
|
||||||
service.rebootNode(nodeMetadata); // blocks until finished
|
assertTrue(nodeMetadata.getName().startsWith("testTag"));
|
||||||
|
service.rebootNode(nodeMetadata); // blocks until finished
|
||||||
|
|
||||||
assertEquals(service.getNodeMetadata(nodeMetadata).getState(), NodeState.RUNNING);
|
assertEquals(service.getNodeMetadata(nodeMetadata).getState(), NodeState.RUNNING);
|
||||||
service.destroyNode(nodeMetadata);
|
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