mirror of https://github.com/apache/jclouds.git
Fixes in live tests
This commit is contained in:
parent
27c1162eaf
commit
b9a5397a45
|
@ -18,22 +18,9 @@
|
|||
*/
|
||||
package org.jclouds.openstack.nova;
|
||||
|
||||
import static org.jclouds.Constants.PROPERTY_API_VERSION;
|
||||
import static org.jclouds.openstack.nova.options.CreateServerOptions.Builder.withFile;
|
||||
import static org.jclouds.openstack.nova.options.CreateServerOptions.Builder.withMetadata;
|
||||
import static org.jclouds.openstack.nova.options.ListOptions.Builder.changesSince;
|
||||
import static org.jclouds.openstack.nova.options.ListOptions.Builder.withDetails;
|
||||
import static org.jclouds.openstack.nova.options.RebuildServerOptions.Builder.withImage;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URI;
|
||||
import java.util.Date;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.inject.Module;
|
||||
import com.google.inject.TypeLiteral;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.RequiresHttp;
|
||||
import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
||||
|
@ -58,9 +45,20 @@ import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
|||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.inject.Module;
|
||||
import com.google.inject.TypeLiteral;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URI;
|
||||
import java.util.Date;
|
||||
import java.util.Properties;
|
||||
|
||||
import static org.jclouds.Constants.PROPERTY_API_VERSION;
|
||||
import static org.jclouds.openstack.nova.options.CreateServerOptions.Builder.withFile;
|
||||
import static org.jclouds.openstack.nova.options.CreateServerOptions.Builder.withMetadata;
|
||||
import static org.jclouds.openstack.nova.options.ListOptions.Builder.changesSince;
|
||||
import static org.jclouds.openstack.nova.options.ListOptions.Builder.withDetails;
|
||||
import static org.jclouds.openstack.nova.options.RebuildServerOptions.Builder.withImage;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code NovaAsyncClient}
|
||||
|
|
|
@ -0,0 +1,100 @@
|
|||
package org.jclouds.openstack.nova.live;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.Module;
|
||||
import org.jclouds.logging.slf4j.config.SLF4JLoggingModule;
|
||||
import org.jclouds.net.IPSocket;
|
||||
import org.jclouds.openstack.nova.NovaClient;
|
||||
import org.jclouds.openstack.nova.domain.Image;
|
||||
import org.jclouds.openstack.nova.domain.Server;
|
||||
import org.jclouds.predicates.RetryablePredicate;
|
||||
import org.jclouds.predicates.SocketOpen;
|
||||
import org.jclouds.rest.RestContextFactory;
|
||||
import org.jclouds.ssh.SshClient;
|
||||
import org.jclouds.ssh.jsch.config.JschSshClientModule;
|
||||
import org.testng.annotations.BeforeTest;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static org.jclouds.openstack.nova.live.PropertyHelper.*;
|
||||
import static org.jclouds.openstack.nova.options.CreateServerOptions.Builder.withFile;
|
||||
|
||||
/**
|
||||
* @author Victor Galkin
|
||||
*/
|
||||
public class ClientBase {
|
||||
protected int testImageId = 95;
|
||||
protected NovaClient client;
|
||||
protected SshClient.Factory sshFactory;
|
||||
private Predicate<IPSocket> socketTester;
|
||||
protected String provider = "nova";
|
||||
protected String serverPrefix = System.getProperty("user.name") + ".cs";
|
||||
protected Map<String, String> keyPair;
|
||||
private int serverId;
|
||||
private String adminPass;
|
||||
Map<String, String> metadata = ImmutableMap.of("jclouds", "rackspace");
|
||||
private int createdImageId;
|
||||
|
||||
|
||||
@BeforeTest
|
||||
public void before() throws IOException {
|
||||
Properties properties = setupOverrides(setupProperties(this.getClass()));
|
||||
|
||||
Injector injector = new RestContextFactory().createContextBuilder(provider,
|
||||
ImmutableSet.<Module>of(new SLF4JLoggingModule(), new JschSshClientModule()), properties)
|
||||
.buildInjector();
|
||||
|
||||
client = injector.getInstance(NovaClient.class);
|
||||
|
||||
sshFactory = injector.getInstance(SshClient.Factory.class);
|
||||
SocketOpen socketOpen = injector.getInstance(SocketOpen.class);
|
||||
socketTester = new RetryablePredicate<IPSocket>(socketOpen, 120, 1, TimeUnit.SECONDS);
|
||||
injector.injectMembers(socketOpen); // add logger
|
||||
|
||||
keyPair = setupKeyPair(properties);
|
||||
}
|
||||
|
||||
protected Server getDefaultServerImmediately() {
|
||||
String defaultName = serverPrefix + "default";
|
||||
for (Server server : client.listServers()) {
|
||||
if (server.getName().equals(defaultName))
|
||||
return server;
|
||||
}
|
||||
return createDefaultServer(defaultName);
|
||||
}
|
||||
|
||||
private Server createDefaultServer(String serverName) {
|
||||
String imageRef = client.getImage(testImageId).getURI().toASCIIString();
|
||||
String flavorRef = client.getFlavor(1).getURI().toASCIIString();
|
||||
|
||||
return client.createServer(serverName, imageRef, flavorRef, withFile("/etc/jclouds.txt",
|
||||
"rackspace".getBytes()).withMetadata(metadata));
|
||||
}
|
||||
|
||||
protected Image getDefaultImageImmediately(Server server) {
|
||||
String defaultName = "hoofie";
|
||||
for (Image image : client.listImages()) {
|
||||
if (image.getName() != null)
|
||||
if (image.getName().equals(defaultName))
|
||||
return image;
|
||||
}
|
||||
return createDefaultImage("hoofie", server);
|
||||
}
|
||||
|
||||
private Image createDefaultImage(String name, Server server) {
|
||||
return client.createImageFromServer("hoofie", server.getId());
|
||||
}
|
||||
|
||||
protected void waitServerDeleted(int serverId) throws InterruptedException {
|
||||
while (null != client.getServer(serverId)) {
|
||||
System.out.println("Await deleted server" + serverId);
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -42,10 +42,8 @@ public class DeleteServersInVariousStatesLiveTest {
|
|||
protected SshClient.Factory sshFactory;
|
||||
private Predicate<IPSocket> socketTester;
|
||||
protected String provider = "nova";
|
||||
protected String identity;
|
||||
protected String credential;
|
||||
protected String endpoint;
|
||||
protected String apiversion;
|
||||
|
||||
private int testImageId = 95;
|
||||
|
||||
Map<String, String> metadata = ImmutableMap.of("jclouds", "rackspace");
|
||||
Server server = null;
|
||||
|
@ -56,19 +54,8 @@ public class DeleteServersInVariousStatesLiveTest {
|
|||
}
|
||||
|
||||
@Test(enabled = true)
|
||||
public void testCreateServer() throws Exception {
|
||||
// String imageRef = client.getImage(13).getURI().toASCIIString();
|
||||
// String flavorRef = client.getFlavor(1).getURI().toASCIIString();
|
||||
// String serverName = serverPrefix + "createserver" + new SecureRandom().nextInt();
|
||||
// Server server = client.createServer(serverName, imageRef, flavorRef, withFile("/etc/jclouds.txt",
|
||||
// "rackspace".getBytes()).withMetadata(metadata));
|
||||
//
|
||||
// assertNotNull(server.getAdminPass());
|
||||
// assertEquals(server.getStatus(), ServerStatus.BUILD);
|
||||
// serverId = server.getId();
|
||||
// adminPass = server.getAdminPass();
|
||||
// blockUntilServerActive(serverId);
|
||||
// client.getServer(serverId).getAddresses().getPublicAddresses().iterator().next().getAddress();
|
||||
public void testDeleteAfterCreate() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
private void blockUntilServerActive(int serverId) throws InterruptedException {
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIICWgIBAAKBgQDItJzHxyFVPZwjE2Wl+17OLJotFruaMaoKLOH8yOr0WnKFYDCs
|
||||
AiN88AvwH2YKaF6SQR3gmMTE8SbuKSXR/PVUZfWfhvDinVbAi8gn8A6P5xkym5A6
|
||||
uBnJn1Mb0rZAKCJT/nN62vomGGO/3VYkpQcKAWgfSpaB7F1BIebaWR/CgQIBIwKB
|
||||
gQCa1Hjx4sHxTMjn28NxaiSQa4zg9EeUNPDjRzH9hQ0FpNwAfWdgHugtLjUYUrxu
|
||||
bcVMQNyIsF1HeDP5jXTycq6e01EYDODnuPC3a06u6Drep0xm/8XuODwekApN811r
|
||||
kfx9AsgRL9ZwkLqMY8E+OXUmsGVXzEM9jUO3iwA4CCBb/wJBAO0klCumLDm9rYXX
|
||||
m3YHuwqcgFPnwSodTWX4tIzHKM0tn3PwajJ1x9kCVxsj9uFzz4LXNrxVrUKcYnVx
|
||||
e/d7sksCQQDYqkr+vt9XaoQSio1M/OOkzc3ynmqtYrNrq9xM1M5IYY2/y5IVLAU3
|
||||
6tiyqXTObSTJT+iFd+OwQymi8FgeN77jAkBzLwYj1F6fs+aRd1ojYtcxCi+zubWY
|
||||
HNxzW4rlSsqszQROQZKqy35TdipPAtb/yolczu6zP46rU0XEA+vBWVaZAkB1nkX4
|
||||
ATdp9/6NuO2e0mzzEKMADNrTJvOveo2Iy0tpHwPOhHPfm43N5eNZrHKb8htItlmn
|
||||
ijnGFdTGKrN+HkMNAkAqh8ulNxVBAK5E0VzzzC2zAh2UFRe3J5K0SgzFkR8W9aM1
|
||||
Vb+iZvj4tVlbFtFLGv0ssty8Q0jS7+Hy75XMatry
|
||||
-----END RSA PRIVATE KEY-----
|
Loading…
Reference in New Issue