mirror of https://github.com/apache/jclouds.git
cleaned up nova impl
This commit is contained in:
parent
ca749a2c8b
commit
57df10029a
|
@ -0,0 +1,103 @@
|
|||
package org.jclouds.openstack.nova.compute.strategy;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static org.jclouds.openstack.nova.options.CreateServerOptions.Builder.withMetadata;
|
||||
import static org.jclouds.openstack.nova.options.ListOptions.Builder.withDetails;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.openstack.nova.NovaClient;
|
||||
import org.jclouds.openstack.nova.domain.Flavor;
|
||||
import org.jclouds.openstack.nova.domain.Image;
|
||||
import org.jclouds.openstack.nova.domain.RebootType;
|
||||
import org.jclouds.openstack.nova.domain.Server;
|
||||
import org.jclouds.openstack.nova.options.ListOptions;
|
||||
import org.jclouds.compute.ComputeService;
|
||||
import org.jclouds.compute.ComputeServiceAdapter;
|
||||
import org.jclouds.compute.domain.Template;
|
||||
import org.jclouds.domain.Location;
|
||||
import org.jclouds.domain.LoginCredentials;
|
||||
import org.jclouds.location.suppliers.JustProvider;
|
||||
|
||||
/**
|
||||
* defines the connection between the {@link NovaClient} implementation and the jclouds
|
||||
* {@link ComputeService}
|
||||
*
|
||||
*/
|
||||
@Singleton
|
||||
public class NovaComputeServiceAdapter implements ComputeServiceAdapter<Server, Flavor, Image, Location> {
|
||||
|
||||
protected final NovaClient client;
|
||||
protected final JustProvider locationSupplier;
|
||||
|
||||
@Inject
|
||||
protected NovaComputeServiceAdapter(NovaClient client, JustProvider locationSupplier) {
|
||||
this.client = checkNotNull(client, "client");
|
||||
this.locationSupplier = checkNotNull(locationSupplier, "locationSupplier");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public NodeAndInitialCredentials<Server> createNodeWithGroupEncodedIntoName(String group, String name,
|
||||
Template template) {
|
||||
Server server = client.createServer(name, template.getImage().getId(), template.getHardware().getId(),
|
||||
withMetadata(template.getOptions().getUserMetadata()));
|
||||
|
||||
return new NodeAndInitialCredentials<Server>(server, server.getId() + "", LoginCredentials.builder().password(
|
||||
server.getAdminPass()).build());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Flavor> listHardwareProfiles() {
|
||||
return client.listFlavors(withDetails());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Image> listImages() {
|
||||
return client.listImages(withDetails());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Server> listNodes() {
|
||||
return client.listServers(ListOptions.Builder.withDetails());
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Iterable<Location> listLocations() {
|
||||
return (Iterable<Location>) locationSupplier.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Server getNode(String id) {
|
||||
int serverId = Integer.parseInt(id);
|
||||
return client.getServer(serverId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroyNode(String id) {
|
||||
int serverId = Integer.parseInt(id);
|
||||
// if false server wasn't around in the first place
|
||||
client.deleteServer(serverId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rebootNode(String id) {
|
||||
int serverId = Integer.parseInt(id);
|
||||
// if false server wasn't around in the first place
|
||||
client.rebootServer(serverId, RebootType.HARD);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resumeNode(String id) {
|
||||
throw new UnsupportedOperationException("suspend not supported");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void suspendNode(String id) {
|
||||
throw new UnsupportedOperationException("suspend not supported");
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,424 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.jclouds.openstack.nova;
|
||||
|
||||
import static org.jclouds.openstack.nova.options.CreateServerOptions.Builder.withFile;
|
||||
import static org.jclouds.openstack.nova.options.ListOptions.Builder.withDetails;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.UndeclaredThrowableException;
|
||||
import java.security.SecureRandom;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.jclouds.compute.BaseVersionedServiceLiveTest;
|
||||
import org.jclouds.domain.LoginCredentials;
|
||||
import org.jclouds.http.HttpResponseException;
|
||||
import org.jclouds.io.Payload;
|
||||
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
||||
import org.jclouds.net.IPSocket;
|
||||
import org.jclouds.openstack.nova.domain.Flavor;
|
||||
import org.jclouds.openstack.nova.domain.Image;
|
||||
import org.jclouds.openstack.nova.domain.ImageStatus;
|
||||
import org.jclouds.openstack.nova.domain.RebootType;
|
||||
import org.jclouds.openstack.nova.domain.Server;
|
||||
import org.jclouds.openstack.nova.domain.ServerStatus;
|
||||
import org.jclouds.openstack.nova.options.RebuildServerOptions;
|
||||
import org.jclouds.predicates.RetryablePredicate;
|
||||
import org.jclouds.predicates.SocketOpen;
|
||||
import org.jclouds.rest.RestContextFactory;
|
||||
import org.jclouds.ssh.SshClient;
|
||||
import org.jclouds.ssh.SshException;
|
||||
import org.jclouds.sshj.config.SshjSshClientModule;
|
||||
import org.jclouds.util.Strings2;
|
||||
import org.testng.annotations.AfterTest;
|
||||
import org.testng.annotations.BeforeGroups;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.Module;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code NovaClient}
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "live", singleThreaded = true, testName = "NovaClientLiveTest")
|
||||
public class NovaClientLiveTest extends BaseVersionedServiceLiveTest {
|
||||
public NovaClientLiveTest() {
|
||||
provider = "nova";
|
||||
}
|
||||
|
||||
protected NovaClient client;
|
||||
protected SshClient.Factory sshFactory;
|
||||
protected Predicate<IPSocket> socketTester;
|
||||
|
||||
@BeforeGroups(groups = { "live" })
|
||||
public void setupClient() {
|
||||
setupCredentials();
|
||||
Properties overrides = setupProperties();
|
||||
|
||||
Injector injector = new RestContextFactory().createContextBuilder(provider,
|
||||
ImmutableSet.<Module> of(new Log4JLoggingModule(), new SshjSshClientModule()), overrides)
|
||||
.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
|
||||
}
|
||||
|
||||
public void testListServers() throws Exception {
|
||||
|
||||
Set<Server> response = client.listServers();
|
||||
assert null != response;
|
||||
long initialContainerCount = response.size();
|
||||
assertTrue(initialContainerCount >= 0);
|
||||
|
||||
}
|
||||
|
||||
public void testListServersDetail() throws Exception {
|
||||
Set<Server> response = client.listServers(withDetails());
|
||||
assert null != response;
|
||||
long initialContainerCount = response.size();
|
||||
assertTrue(initialContainerCount >= 0);
|
||||
}
|
||||
|
||||
public void testListImages() throws Exception {
|
||||
Set<Image> response = client.listImages();
|
||||
assert null != response;
|
||||
long imageCount = response.size();
|
||||
assertTrue(imageCount >= 1);
|
||||
for (Image image : response) {
|
||||
assertTrue(image.getId() >= 0);
|
||||
assert null != image.getName() : image;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void testListImagesDetail() throws Exception {
|
||||
Set<Image> response = client.listImages(withDetails());
|
||||
assert null != response;
|
||||
long imageCount = response.size();
|
||||
assertTrue(imageCount >= 0);
|
||||
for (Image image : response) {
|
||||
assertTrue(image.getId() >= 1);
|
||||
assert null != image.getName() : image;
|
||||
assert null != image.getStatus() : image;
|
||||
}
|
||||
}
|
||||
|
||||
public void testGetImagesDetail() throws Exception {
|
||||
Set<Image> response = client.listImages(withDetails());
|
||||
assert null != response;
|
||||
long imageCount = response.size();
|
||||
assertTrue(imageCount >= 0);
|
||||
for (Image image : response) {
|
||||
Image newDetails = client.getImage(image.getId());
|
||||
assertEquals(image, newDetails);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetImageDetailsNotFound() throws Exception {
|
||||
assert client.getImage(12312987) == null;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetServerDetailsNotFound() throws Exception {
|
||||
assert client.getServer(12312987) == null;
|
||||
}
|
||||
|
||||
public void testGetServersDetail() throws Exception {
|
||||
Set<Server> response = client.listServers(withDetails());
|
||||
assert null != response;
|
||||
long serverCount = response.size();
|
||||
assertTrue(serverCount >= 0);
|
||||
for (Server server : response) {
|
||||
Server newDetails = client.getServer(server.getId());
|
||||
assertEquals(server, newDetails);
|
||||
}
|
||||
}
|
||||
|
||||
public void testListFlavors() throws Exception {
|
||||
Set<Flavor> response = client.listFlavors();
|
||||
assert null != response;
|
||||
long flavorCount = response.size();
|
||||
assertTrue(flavorCount >= 1);
|
||||
for (Flavor flavor : response) {
|
||||
assertTrue(flavor.getId() >= 0);
|
||||
assert null != flavor.getName() : flavor;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void testListFlavorsDetail() throws Exception {
|
||||
Set<Flavor> response = client.listFlavors(withDetails());
|
||||
assert null != response;
|
||||
long flavorCount = response.size();
|
||||
assertTrue(flavorCount >= 0);
|
||||
for (Flavor flavor : response) {
|
||||
assertTrue(flavor.getId() >= 1);
|
||||
assert null != flavor.getName() : flavor;
|
||||
assert null != flavor.getDisk() : flavor;
|
||||
assert null != flavor.getRam() : flavor;
|
||||
}
|
||||
}
|
||||
|
||||
public void testGetFlavorsDetail() throws Exception {
|
||||
Set<Flavor> response = client.listFlavors(withDetails());
|
||||
assert null != response;
|
||||
long flavorCount = response.size();
|
||||
assertTrue(flavorCount >= 0);
|
||||
for (Flavor flavor : response) {
|
||||
Flavor newDetails = client.getFlavor(flavor.getId());
|
||||
assertEquals(flavor, newDetails);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetFlavorDetailsNotFound() throws Exception {
|
||||
assert client.getFlavor(12312987) == null;
|
||||
}
|
||||
|
||||
// Server name must start with one or more alphabet and/or space and/or number. E.g. server 10,
|
||||
// server, server1
|
||||
private String serverPrefix = System.getProperty("user.name").replace('.', ' ');
|
||||
private int serverId;
|
||||
private String adminPass;
|
||||
Map<String, String> metadata = ImmutableMap.of("jclouds", "nova");
|
||||
private int serverId2;
|
||||
private String createdImageRef;
|
||||
|
||||
public void testCreateServer() throws Exception {
|
||||
String flavorId = "1";
|
||||
Server server = null;
|
||||
while (server == null) {
|
||||
String serverName = serverPrefix + "createserver" + new SecureRandom().nextInt();
|
||||
try {
|
||||
server = client.createServer(serverName, imageId, flavorId, withFile("/etc/jclouds.txt",
|
||||
"nova".getBytes()).withMetadata(metadata));
|
||||
} catch (UndeclaredThrowableException e) {
|
||||
HttpResponseException htpe = (HttpResponseException) e.getCause().getCause();
|
||||
if (htpe.getResponse().getStatusCode() == 400)
|
||||
continue;
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
assertNotNull(server.getAdminPass());
|
||||
serverId = server.getId();
|
||||
adminPass = server.getAdminPass();
|
||||
assertEquals(server.getStatus(), ServerStatus.BUILD);
|
||||
blockUntilServerActive(serverId);
|
||||
}
|
||||
|
||||
private void blockUntilServerActive(int serverId) throws InterruptedException {
|
||||
Server currentDetails = null;
|
||||
for (currentDetails = client.getServer(serverId); currentDetails.getStatus() != ServerStatus.ACTIVE; currentDetails = client
|
||||
.getServer(serverId)) {
|
||||
System.out.printf("blocking on status active%n%s%n", currentDetails);
|
||||
Thread.sleep(5 * 1000);
|
||||
}
|
||||
}
|
||||
|
||||
private void blockUntilServerVerifyResize(int serverId) throws InterruptedException {
|
||||
Server currentDetails = null;
|
||||
for (currentDetails = client.getServer(serverId); currentDetails.getStatus() != ServerStatus.VERIFY_RESIZE; currentDetails = client
|
||||
.getServer(serverId)) {
|
||||
System.out.printf("blocking on status verify resize%n%s%n", currentDetails);
|
||||
Thread.sleep(5 * 1000);
|
||||
}
|
||||
}
|
||||
|
||||
private void blockUntilImageActive(String imageRef) throws InterruptedException {
|
||||
Image currentDetails = null;
|
||||
for (currentDetails = client.getImage(imageRef); currentDetails.getStatus() != ImageStatus.ACTIVE; currentDetails = client
|
||||
.getImage(imageRef)) {
|
||||
System.out.printf("blocking on status active%n%s%n", currentDetails);
|
||||
Thread.sleep(5 * 1000);
|
||||
}
|
||||
}
|
||||
|
||||
@Test(timeOut = 5 * 60 * 1000, dependsOnMethods = "testCreateServer")
|
||||
public void testServerDetails() throws Exception {
|
||||
Server server = client.getServer(serverId);
|
||||
|
||||
assertNotNull(server.getHostId());
|
||||
assertEquals(server.getStatus(), ServerStatus.ACTIVE);
|
||||
assert server.getProgress() >= 0 : "newDetails.getProgress()" + server.getProgress();
|
||||
assertEquals(new Integer(14362), server.getImage());
|
||||
assertEquals(new Integer(1), server.getFlavor());
|
||||
assertNotNull(server.getAddresses());
|
||||
// listAddresses tests..
|
||||
assertEquals(client.getAddresses(serverId), server.getAddresses());
|
||||
assertEquals(server.getAddresses().getPublicAddresses().size(), 1);
|
||||
assertEquals(client.listPublicAddresses(serverId), server.getAddresses().getPublicAddresses());
|
||||
assertEquals(server.getAddresses().getPrivateAddresses().size(), 1);
|
||||
assertEquals(client.listPrivateAddresses(serverId), server.getAddresses().getPrivateAddresses());
|
||||
|
||||
// check metadata
|
||||
assertEquals(server.getMetadata(), metadata);
|
||||
|
||||
checkPassOk(server, adminPass);
|
||||
}
|
||||
|
||||
/**
|
||||
* this tests "personality" as the file looked up was sent during server creation
|
||||
*/
|
||||
private void checkPassOk(Server newDetails, String pass) throws IOException {
|
||||
try {
|
||||
doCheckPass(newDetails, pass);
|
||||
} catch (SshException e) {// try twice in case there is a network timeout
|
||||
try {
|
||||
Thread.sleep(10 * 1000);
|
||||
} catch (InterruptedException e1) {
|
||||
}
|
||||
doCheckPass(newDetails, pass);
|
||||
}
|
||||
}
|
||||
|
||||
private void doCheckPass(Server newDetails, String pass) throws IOException {
|
||||
IPSocket socket = new IPSocket(Iterables.get(newDetails.getAddresses().getPublicAddresses(), 0).getAddress(), 22);
|
||||
socketTester.apply(socket);
|
||||
|
||||
SshClient client = sshFactory.create(socket, LoginCredentials.builder().user("root").password(pass).build());
|
||||
try {
|
||||
client.connect();
|
||||
Payload etcPasswd = client.get("/etc/jclouds.txt");
|
||||
String etcPasswdContents = Strings2.toStringAndClose(etcPasswd.getInput());
|
||||
assertEquals("nova", etcPasswdContents.trim());
|
||||
} finally {
|
||||
if (client != null)
|
||||
client.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
@Test(timeOut = 5 * 60 * 1000, dependsOnMethods = "testCreateServer")
|
||||
public void testRenameServer() throws Exception {
|
||||
Server server = client.getServer(serverId);
|
||||
String oldName = server.getName();
|
||||
client.renameServer(serverId, oldName + "new");
|
||||
blockUntilServerActive(serverId);
|
||||
assertEquals(oldName + "new", client.getServer(serverId).getName());
|
||||
}
|
||||
|
||||
@Test(timeOut = 5 * 60 * 1000, dependsOnMethods = "testCreateServer")
|
||||
public void testChangePassword() throws Exception {
|
||||
client.changeAdminPass(serverId, "elmo");
|
||||
blockUntilServerActive(serverId);
|
||||
checkPassOk(client.getServer(serverId), "elmo");
|
||||
this.adminPass = "elmo";
|
||||
}
|
||||
|
||||
@Test(timeOut = 10 * 60 * 1000, dependsOnMethods = "testChangePassword")
|
||||
public void testCreateImage() throws Exception {
|
||||
Image image = client.createImageFromServer("hoofie", serverId);
|
||||
assertEquals("hoofie", image.getName());
|
||||
assertEquals(new Integer(serverId), image.getServerRef());
|
||||
createdImageRef = image.getId()+"";
|
||||
blockUntilImageActive(createdImageRef);
|
||||
}
|
||||
|
||||
@Test(timeOut = 10 * 60 * 1000, dependsOnMethods = "testCreateImage")
|
||||
public void testRebuildServer() throws Exception {
|
||||
client.rebuildServer(serverId, new RebuildServerOptions().withImage(createdImageRef));
|
||||
blockUntilServerActive(serverId);
|
||||
assertEquals(new Integer(createdImageRef).intValue(),client.getServer(serverId).getImage().getId());
|
||||
}
|
||||
|
||||
@Test(timeOut = 10 * 60 * 1000, dependsOnMethods = "testRebuildServer")
|
||||
public void testRebootHard() throws Exception {
|
||||
client.rebootServer(serverId, RebootType.HARD);
|
||||
blockUntilServerActive(serverId);
|
||||
}
|
||||
|
||||
@Test(timeOut = 10 * 60 * 1000, dependsOnMethods = "testRebootHard")
|
||||
public void testRebootSoft() throws Exception {
|
||||
client.rebootServer(serverId, RebootType.SOFT);
|
||||
blockUntilServerActive(serverId);
|
||||
}
|
||||
|
||||
@Test(timeOut = 10 * 60 * 1000, dependsOnMethods = "testRebootSoft")
|
||||
public void testRevertResize() throws Exception {
|
||||
client.resizeServer(serverId, 2);
|
||||
blockUntilServerVerifyResize(serverId);
|
||||
client.revertResizeServer(serverId);
|
||||
blockUntilServerActive(serverId);
|
||||
assertEquals(new Integer(1), client.getServer(serverId).getFlavorRef());
|
||||
}
|
||||
|
||||
@Test(timeOut = 10 * 60 * 1000, dependsOnMethods = "testRebootSoft")
|
||||
public void testConfirmResize() throws Exception {
|
||||
client.resizeServer(serverId2, 2);
|
||||
blockUntilServerVerifyResize(serverId2);
|
||||
client.confirmResizeServer(serverId2);
|
||||
blockUntilServerActive(serverId2);
|
||||
assertEquals(new Integer(2), client.getServer(serverId2).getFlavorRef());
|
||||
}
|
||||
|
||||
@Test(timeOut = 10 * 60 * 1000, dependsOnMethods = { "testRebootSoft", "testRevertResize", "testConfirmResize" })
|
||||
void deleteServer2() {
|
||||
if (serverId2 > 0) {
|
||||
client.deleteServer(serverId2);
|
||||
assert client.getServer(serverId2) == null;
|
||||
}
|
||||
}
|
||||
|
||||
@Test(timeOut = 10 * 60 * 1000, dependsOnMethods = "deleteServer2")
|
||||
void testDeleteImage() {
|
||||
if (createdImageRef != null) {
|
||||
client.deleteImage(createdImageRef);
|
||||
assert client.getImage(createdImageRef) == null;
|
||||
}
|
||||
}
|
||||
|
||||
@Test(timeOut = 10 * 60 * 1000, dependsOnMethods = "testDeleteImage")
|
||||
void deleteServer1() {
|
||||
if (serverId > 0) {
|
||||
client.deleteServer(serverId);
|
||||
assert client.getServer(serverId) == null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@AfterTest
|
||||
void deleteServersOnEnd() {
|
||||
if (serverId > 0) {
|
||||
client.deleteServer(serverId);
|
||||
}
|
||||
if (serverId2 > 0) {
|
||||
client.deleteServer(serverId2);
|
||||
}
|
||||
if (createdImageRef != null) {
|
||||
client.deleteImage(createdImageRef);
|
||||
assert client.getImage(createdImageRef) == null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,89 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.openstack.nova.compute;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jclouds.compute.BaseComputeServiceLiveTest;
|
||||
import org.jclouds.compute.ComputeServiceContextFactory;
|
||||
import org.jclouds.compute.domain.NodeMetadata;
|
||||
import org.jclouds.domain.LocationScope;
|
||||
import org.jclouds.openstack.nova.NovaAsyncClient;
|
||||
import org.jclouds.openstack.nova.NovaClient;
|
||||
import org.jclouds.rest.RestContext;
|
||||
import org.jclouds.sshj.config.SshjSshClientModule;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.inject.Module;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "live", enabled = true, singleThreaded = true, testName = "NovaComputeServiceLiveTest")
|
||||
public class NovaComputeServiceLiveTest extends BaseComputeServiceLiveTest {
|
||||
public NovaComputeServiceLiveTest() {
|
||||
provider = "nova";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Module getSshModule() {
|
||||
return new SshjSshClientModule();
|
||||
}
|
||||
|
||||
public void testAssignability() throws Exception {
|
||||
@SuppressWarnings("unused")
|
||||
RestContext<NovaClient, NovaAsyncClient> tmContext = new ComputeServiceContextFactory()
|
||||
.createContext(provider, identity, credential).getProviderSpecificContext();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkNodes(Iterable<? extends NodeMetadata> nodes, String group, String task) throws IOException {
|
||||
super.checkNodes(nodes, group, task);
|
||||
for (NodeMetadata node : nodes) {
|
||||
assertEquals(node.getLocation().getScope(), LocationScope.HOST);
|
||||
}
|
||||
}
|
||||
|
||||
@Test(enabled = true, dependsOnMethods = "testReboot", expectedExceptions = UnsupportedOperationException.class)
|
||||
public void testSuspendResume() throws Exception {
|
||||
super.testSuspendResume();
|
||||
}
|
||||
|
||||
@Test(enabled = true, dependsOnMethods = "testSuspendResume")
|
||||
@Override
|
||||
public void testGetNodesWithDetails() throws Exception {
|
||||
super.testGetNodesWithDetails();
|
||||
}
|
||||
|
||||
@Test(enabled = true, dependsOnMethods = "testSuspendResume")
|
||||
@Override
|
||||
public void testListNodes() throws Exception {
|
||||
super.testListNodes();
|
||||
}
|
||||
|
||||
@Test(enabled = true, dependsOnMethods = { "testListNodes", "testGetNodesWithDetails" })
|
||||
@Override
|
||||
public void testDestroyNodes() {
|
||||
super.testDestroyNodes();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,166 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
|
||||
|
||||
<!--
|
||||
For more configuration infromation and examples see the Apache
|
||||
Log4j website: http://logging.apache.org/log4j/
|
||||
-->
|
||||
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"
|
||||
debug="false">
|
||||
|
||||
<!-- A time/date based rolling appender -->
|
||||
<appender name="WIREFILE" class="org.apache.log4j.DailyRollingFileAppender">
|
||||
<param name="File" value="target/test-data/jclouds-wire.log" />
|
||||
<param name="Append" value="true" />
|
||||
|
||||
<!-- Rollover at midnight each day -->
|
||||
<param name="DatePattern" value="'.'yyyy-MM-dd" />
|
||||
|
||||
<param name="Threshold" value="TRACE" />
|
||||
|
||||
<layout class="org.apache.log4j.PatternLayout">
|
||||
<!-- The default pattern: Date Priority [Category] Message\n -->
|
||||
<param name="ConversionPattern" value="%d %-5p [%c] (%t) %m%n" />
|
||||
|
||||
<!--
|
||||
The full pattern: Date MS Priority [Category]
|
||||
(Thread:NDC) Message\n <param name="ConversionPattern"
|
||||
value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
|
||||
-->
|
||||
</layout>
|
||||
</appender>
|
||||
|
||||
<!-- A time/date based rolling appender -->
|
||||
<appender name="FILE" class="org.apache.log4j.DailyRollingFileAppender">
|
||||
<param name="File" value="target/test-data/jclouds.log" />
|
||||
<param name="Append" value="true" />
|
||||
|
||||
<!-- Rollover at midnight each day -->
|
||||
<param name="DatePattern" value="'.'yyyy-MM-dd" />
|
||||
|
||||
<param name="Threshold" value="TRACE" />
|
||||
|
||||
<layout class="org.apache.log4j.PatternLayout">
|
||||
<!-- The default pattern: Date Priority [Category] Message\n -->
|
||||
<param name="ConversionPattern" value="%d %-5p [%c] (%t) %m%n" />
|
||||
|
||||
<!--
|
||||
The full pattern: Date MS Priority [Category]
|
||||
(Thread:NDC) Message\n <param name="ConversionPattern"
|
||||
value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
|
||||
-->
|
||||
</layout>
|
||||
</appender>
|
||||
<!-- A time/date based rolling appender -->
|
||||
<appender name="BLOBSTOREFILE" class="org.apache.log4j.DailyRollingFileAppender">
|
||||
<param name="File" value="target/test-data/jclouds-blobstore.log" />
|
||||
<param name="Append" value="true" />
|
||||
<param name="DatePattern" value="'.'yyyy-MM-dd" />
|
||||
<param name="Threshold" value="TRACE" />
|
||||
<layout class="org.apache.log4j.PatternLayout">
|
||||
<param name="ConversionPattern" value="%d %-5p [%c] (%t) %m%n" />
|
||||
</layout>
|
||||
</appender>
|
||||
|
||||
<!-- A time/date based rolling appender -->
|
||||
<appender name="COMPUTEFILE" class="org.apache.log4j.DailyRollingFileAppender">
|
||||
<param name="File" value="target/test-data/jclouds-compute.log" />
|
||||
<param name="Append" value="true" />
|
||||
|
||||
<!-- Rollover at midnight each day -->
|
||||
<param name="DatePattern" value="'.'yyyy-MM-dd" />
|
||||
|
||||
<param name="Threshold" value="TRACE" />
|
||||
|
||||
<layout class="org.apache.log4j.PatternLayout">
|
||||
<!-- The default pattern: Date Priority [Category] Message\n -->
|
||||
<param name="ConversionPattern" value="%d %-5p [%c] (%t) %m%n" />
|
||||
|
||||
<!--
|
||||
The full pattern: Date MS Priority [Category]
|
||||
(Thread:NDC) Message\n <param name="ConversionPattern"
|
||||
value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
|
||||
-->
|
||||
</layout>
|
||||
</appender>
|
||||
|
||||
<!-- A time/date based rolling appender -->
|
||||
<appender name="SSHFILE" class="org.apache.log4j.DailyRollingFileAppender">
|
||||
<param name="File" value="target/test-data/jclouds-ssh.log" />
|
||||
<param name="Append" value="true" />
|
||||
|
||||
<!-- Rollover at midnight each day -->
|
||||
<param name="DatePattern" value="'.'yyyy-MM-dd" />
|
||||
|
||||
<param name="Threshold" value="TRACE" />
|
||||
|
||||
<layout class="org.apache.log4j.PatternLayout">
|
||||
<!-- The default pattern: Date Priority [Category] Message\n -->
|
||||
<param name="ConversionPattern" value="%d %-5p [%c] (%t) %m%n" />
|
||||
|
||||
<!--
|
||||
The full pattern: Date MS Priority [Category]
|
||||
(Thread:NDC) Message\n <param name="ConversionPattern"
|
||||
value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
|
||||
-->
|
||||
</layout>
|
||||
</appender>
|
||||
|
||||
<appender name="ASYNCCOMPUTE" class="org.apache.log4j.AsyncAppender">
|
||||
<appender-ref ref="COMPUTEFILE" />
|
||||
</appender>
|
||||
|
||||
<appender name="ASYNCSSH" class="org.apache.log4j.AsyncAppender">
|
||||
<appender-ref ref="SSHFILE" />
|
||||
</appender>
|
||||
|
||||
<appender name="ASYNC" class="org.apache.log4j.AsyncAppender">
|
||||
<appender-ref ref="FILE" />
|
||||
</appender>
|
||||
|
||||
<appender name="ASYNCWIRE" class="org.apache.log4j.AsyncAppender">
|
||||
<appender-ref ref="WIREFILE" />
|
||||
</appender>
|
||||
|
||||
<appender name="ASYNCBLOBSTORE" class="org.apache.log4j.AsyncAppender">
|
||||
<appender-ref ref="BLOBSTOREFILE" />
|
||||
</appender>
|
||||
<!-- ================ -->
|
||||
<!-- Limit categories -->
|
||||
<!-- ================ -->
|
||||
|
||||
<category name="org.jclouds">
|
||||
<priority value="DEBUG" />
|
||||
<appender-ref ref="ASYNC" />
|
||||
</category>
|
||||
|
||||
<category name="jclouds.headers">
|
||||
<priority value="DEBUG" />
|
||||
<appender-ref ref="ASYNCWIRE" />
|
||||
</category>
|
||||
|
||||
<category name="jclouds.ssh">
|
||||
<priority value="DEBUG" />
|
||||
<appender-ref ref="ASYNCSSH" />
|
||||
</category>
|
||||
<category name="jclouds.wire">
|
||||
<priority value="DEBUG" />
|
||||
<appender-ref ref="ASYNCWIRE" />
|
||||
</category>
|
||||
<category name="jclouds.blobstore">
|
||||
<priority value="DEBUG" />
|
||||
<appender-ref ref="ASYNCBLOBSTORE" />
|
||||
</category>
|
||||
<category name="jclouds.compute">
|
||||
<priority value="TRACE" />
|
||||
<appender-ref ref="ASYNCCOMPUTE" />
|
||||
</category>
|
||||
<!-- ======================= -->
|
||||
<!-- Setup the Root category -->
|
||||
<!-- ======================= -->
|
||||
|
||||
<root>
|
||||
<priority value="WARN" />
|
||||
</root>
|
||||
|
||||
</log4j:configuration>
|
Loading…
Reference in New Issue