mirror of https://github.com/apache/jclouds.git
Issue 412, 419: ssh test
This commit is contained in:
parent
bd7d9fb594
commit
c46bb08835
|
@ -64,6 +64,12 @@
|
|||
<artifactId>jclouds-elasticstack</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>jclouds-jsch</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>jclouds-core</artifactId>
|
||||
|
|
|
@ -27,7 +27,9 @@ import java.util.Set;
|
|||
import org.jclouds.cloudsigma.domain.DriveInfo;
|
||||
import org.jclouds.cloudsigma.domain.DriveType;
|
||||
import org.jclouds.cloudsigma.options.CloneDriveOptions;
|
||||
import org.jclouds.domain.Credentials;
|
||||
import org.jclouds.elasticstack.CommonElasticStackClientLiveTest;
|
||||
import org.jclouds.elasticstack.domain.Server;
|
||||
import org.jclouds.elasticstack.domain.ServerInfo;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
|
@ -78,6 +80,11 @@ public class CloudSigmaClientLiveTest extends CommonElasticStackClientLiveTest<C
|
|||
assertEquals(DriveInfo.class.cast(drive).getType(), null);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Credentials getSshCredentials(Server server) {
|
||||
return new Credentials("cloudsigma", "cloudsigma");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void prepareDrive() {
|
||||
client.destroyDrive(drive.getUuid());
|
||||
|
|
|
@ -64,6 +64,12 @@
|
|||
<artifactId>jclouds-core</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>jclouds-jsch</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>jclouds-core</artifactId>
|
||||
|
|
|
@ -23,12 +23,14 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.jclouds.Constants;
|
||||
import org.jclouds.domain.Credentials;
|
||||
import org.jclouds.elasticstack.domain.ClaimType;
|
||||
import org.jclouds.elasticstack.domain.CreateDriveRequest;
|
||||
import org.jclouds.elasticstack.domain.DriveData;
|
||||
|
@ -47,6 +49,9 @@ import org.jclouds.predicates.InetSocketAddressConnect;
|
|||
import org.jclouds.predicates.RetryablePredicate;
|
||||
import org.jclouds.rest.RestContext;
|
||||
import org.jclouds.rest.RestContextFactory;
|
||||
import org.jclouds.ssh.ExecResponse;
|
||||
import org.jclouds.ssh.SshClient;
|
||||
import org.jclouds.ssh.jsch.config.JschSshClientModule;
|
||||
import org.testng.annotations.AfterGroups;
|
||||
import org.testng.annotations.BeforeGroups;
|
||||
import org.testng.annotations.Test;
|
||||
|
@ -56,6 +61,7 @@ import com.google.common.base.Predicates;
|
|||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Module;
|
||||
|
||||
/**
|
||||
|
@ -251,6 +257,7 @@ public abstract class CommonElasticStackClientLiveTest<S extends CommonElasticSt
|
|||
assert socketTester.apply(new IPSocket(server.getVnc().getIp(), 5900)) : server;
|
||||
Logger.getAnonymousLogger().info("awaiting ssh");
|
||||
assert socketTester.apply(new IPSocket(server.getNics().get(0).getDhcp(), 22)) : server;
|
||||
doConnectViaSsh(server, getSshCredentials(server));
|
||||
}
|
||||
|
||||
@Test(dependsOnMethods = "testConnectivity")
|
||||
|
@ -305,6 +312,21 @@ public abstract class CommonElasticStackClientLiveTest<S extends CommonElasticSt
|
|||
assertEquals(client.getDriveInfo(drive.getUuid()), null);
|
||||
}
|
||||
|
||||
protected void doConnectViaSsh(Server server, Credentials creds) throws IOException {
|
||||
SshClient ssh = Guice.createInjector(new JschSshClientModule()).getInstance(SshClient.Factory.class)
|
||||
.create(new IPSocket(server.getVnc().getIp(), 22), creds);
|
||||
try {
|
||||
ssh.connect();
|
||||
ExecResponse hello = ssh.exec("echo hello");
|
||||
assertEquals(hello.getOutput().trim(), "hello");
|
||||
} finally {
|
||||
if (ssh != null)
|
||||
ssh.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract Credentials getSshCredentials(Server server);
|
||||
|
||||
@AfterGroups(groups = "live")
|
||||
protected void tearDown() {
|
||||
try {
|
||||
|
|
|
@ -23,9 +23,11 @@ import static org.testng.Assert.assertEquals;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jclouds.domain.Credentials;
|
||||
import org.jclouds.elasticstack.domain.CreateDriveRequest;
|
||||
import org.jclouds.elasticstack.domain.DriveInfo;
|
||||
import org.jclouds.elasticstack.domain.ImageConversionType;
|
||||
import org.jclouds.elasticstack.domain.Server;
|
||||
import org.jclouds.io.Payloads;
|
||||
import org.jclouds.util.Utils;
|
||||
import org.testng.annotations.Test;
|
||||
|
@ -66,6 +68,12 @@ public class ElasticStackClientLiveTest extends
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Credentials getSshCredentials(Server server) {
|
||||
// according to paul from elastichosts, this account should be present
|
||||
return new Credentials("toor", server.getVnc().getPassword());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void prepareDrive() {
|
||||
System.err.println("before prepare" + client.getDriveInfo(drive.getUuid()));
|
||||
|
|
Loading…
Reference in New Issue