mirror of https://github.com/apache/jclouds.git
Merge pull request #557 from grkvlt/vcloud-fixes
Issue 830: vCloud test fixes
This commit is contained in:
commit
70d179b3c7
|
@ -23,7 +23,6 @@ import static org.jclouds.dmtf.DMTFConstants.OVF_NS;
|
||||||
|
|
||||||
import javax.xml.bind.annotation.XmlAttribute;
|
import javax.xml.bind.annotation.XmlAttribute;
|
||||||
import javax.xml.bind.annotation.XmlElement;
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
import javax.xml.bind.annotation.XmlType;
|
|
||||||
|
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
|
|
||||||
|
@ -33,7 +32,6 @@ import com.google.common.base.Objects;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
* @author Adam Lowe
|
* @author Adam Lowe
|
||||||
*/
|
*/
|
||||||
@XmlType(name = "OperatingSystemSection_Type")
|
|
||||||
public class OperatingSystemSection extends SectionType {
|
public class OperatingSystemSection extends SectionType {
|
||||||
|
|
||||||
public static Builder<?> builder() {
|
public static Builder<?> builder() {
|
||||||
|
|
|
@ -25,7 +25,6 @@ import java.util.Set;
|
||||||
|
|
||||||
import javax.xml.bind.annotation.XmlAttribute;
|
import javax.xml.bind.annotation.XmlAttribute;
|
||||||
import javax.xml.bind.annotation.XmlElement;
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
import javax.xml.bind.annotation.XmlType;
|
|
||||||
|
|
||||||
import org.jclouds.dmtf.cim.ResourceAllocationSettingData;
|
import org.jclouds.dmtf.cim.ResourceAllocationSettingData;
|
||||||
import org.jclouds.dmtf.cim.VirtualSystemSettingData;
|
import org.jclouds.dmtf.cim.VirtualSystemSettingData;
|
||||||
|
@ -46,7 +45,6 @@ import com.google.common.collect.Sets;
|
||||||
* @author Adam Lowe
|
* @author Adam Lowe
|
||||||
* @author grkvlt@apache.org
|
* @author grkvlt@apache.org
|
||||||
*/
|
*/
|
||||||
@XmlType(name = "VirtualHardwareSection_Type")
|
|
||||||
public class VirtualHardwareSection extends SectionType {
|
public class VirtualHardwareSection extends SectionType {
|
||||||
|
|
||||||
public static Builder<?> builder() {
|
public static Builder<?> builder() {
|
||||||
|
|
|
@ -95,6 +95,7 @@ public class Link extends Reference {
|
||||||
@XmlEnumValue("remove") REMOVE("remove"),
|
@XmlEnumValue("remove") REMOVE("remove"),
|
||||||
@XmlEnumValue("screen:acquireTicket") SCREEN_ACQUIRE_TICKET("screen:acquireTicket"),
|
@XmlEnumValue("screen:acquireTicket") SCREEN_ACQUIRE_TICKET("screen:acquireTicket"),
|
||||||
@XmlEnumValue("screen:thumbnail") SCREEN_THUMBNAIL("screen:thumbnail"),
|
@XmlEnumValue("screen:thumbnail") SCREEN_THUMBNAIL("screen:thumbnail"),
|
||||||
|
@XmlEnumValue("syncSyslogSettings") SYNC_SYSLOG_SETTINGS("syncSyslogSettings"),
|
||||||
@XmlEnumValue("task:cancel") TASK_CANCEL("task:cancel"),
|
@XmlEnumValue("task:cancel") TASK_CANCEL("task:cancel"),
|
||||||
@XmlEnumValue("blockingTask") BLOCKING_TASK("blockingTask"),
|
@XmlEnumValue("blockingTask") BLOCKING_TASK("blockingTask"),
|
||||||
@XmlEnumValue("taskOwner") TASK_OWNER("taskOwner"),
|
@XmlEnumValue("taskOwner") TASK_OWNER("taskOwner"),
|
||||||
|
@ -121,7 +122,7 @@ public class Link extends Reference {
|
||||||
NEXT_PAGE, OVA, OVF, POWER_OFF, POWER_ON, REBOOT, RESET, SHUTDOWN,
|
NEXT_PAGE, OVA, OVF, POWER_OFF, POWER_ON, REBOOT, RESET, SHUTDOWN,
|
||||||
SUSPEND, PREVIOUS_PAGE, PUBLISH, RECOMPOSE, RECONNECT, REGISTER,
|
SUSPEND, PREVIOUS_PAGE, PUBLISH, RECOMPOSE, RECONNECT, REGISTER,
|
||||||
REJECT, RELOCATE, REMOVE, REPAIR, SCREEN_ACQUIRE_TICKET,
|
REJECT, RELOCATE, REMOVE, REPAIR, SCREEN_ACQUIRE_TICKET,
|
||||||
SCREEN_THUMBNAIL, TASK_CANCEL, BLOCKING_TASK, TASK_OWNER,
|
SCREEN_THUMBNAIL, SYNC_SYSLOG_SETTINGS, TASK_CANCEL, BLOCKING_TASK, TASK_OWNER,
|
||||||
TASK_PARAMS, TASK_REQUEST, UNDEPLOY, UNLOCK, UNREGISTER, UP,
|
TASK_PARAMS, TASK_REQUEST, UNDEPLOY, UNLOCK, UNREGISTER, UP,
|
||||||
UPDATE_PROGRESS, UPGRADE, UPLOAD_ALTERNATE, UPLOAD_DEFAULT,
|
UPDATE_PROGRESS, UPGRADE, UPLOAD_ALTERNATE, UPLOAD_DEFAULT,
|
||||||
UPLOAD_DEFAULT);
|
UPLOAD_DEFAULT);
|
||||||
|
|
|
@ -20,6 +20,7 @@ package org.jclouds.vcloud.director.v1_5.domain;
|
||||||
|
|
||||||
import static com.google.common.base.Objects.equal;
|
import static com.google.common.base.Objects.equal;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
import static org.jclouds.dmtf.DMTFConstants.OVF_NS;
|
||||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_1_5_NS;
|
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_1_5_NS;
|
||||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_VMW_NS;
|
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_VMW_NS;
|
||||||
|
|
||||||
|
@ -30,6 +31,7 @@ import javax.xml.bind.annotation.XmlAttribute;
|
||||||
import javax.xml.bind.annotation.XmlElement;
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
import javax.xml.bind.annotation.XmlSeeAlso;
|
import javax.xml.bind.annotation.XmlSeeAlso;
|
||||||
|
import javax.xml.bind.annotation.XmlType;
|
||||||
|
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
import com.google.common.base.Objects.ToStringHelper;
|
import com.google.common.base.Objects.ToStringHelper;
|
||||||
|
@ -43,7 +45,8 @@ import com.google.common.collect.Sets;
|
||||||
* @author Adam Lowe
|
* @author Adam Lowe
|
||||||
* @author grkvlt@apache.org
|
* @author grkvlt@apache.org
|
||||||
*/
|
*/
|
||||||
@XmlRootElement(name = "OperatingSystemSection")
|
@XmlRootElement(name = "OperatingSystemSection", namespace = OVF_NS)
|
||||||
|
@XmlType(name = "OperatingSystemSection_Type")
|
||||||
@XmlSeeAlso({ org.jclouds.dmtf.ovf.OperatingSystemSection.class })
|
@XmlSeeAlso({ org.jclouds.dmtf.ovf.OperatingSystemSection.class })
|
||||||
public class OperatingSystemSection extends org.jclouds.dmtf.ovf.OperatingSystemSection {
|
public class OperatingSystemSection extends org.jclouds.dmtf.ovf.OperatingSystemSection {
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ package org.jclouds.vcloud.director.v1_5.domain;
|
||||||
|
|
||||||
import static com.google.common.base.Objects.equal;
|
import static com.google.common.base.Objects.equal;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
import static org.jclouds.dmtf.DMTFConstants.OVF_NS;
|
||||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_1_5_NS;
|
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_1_5_NS;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
@ -30,6 +31,7 @@ import javax.xml.bind.annotation.XmlElement;
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
import javax.xml.bind.annotation.XmlSchemaType;
|
import javax.xml.bind.annotation.XmlSchemaType;
|
||||||
import javax.xml.bind.annotation.XmlSeeAlso;
|
import javax.xml.bind.annotation.XmlSeeAlso;
|
||||||
|
import javax.xml.bind.annotation.XmlType;
|
||||||
|
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
import com.google.common.base.Objects.ToStringHelper;
|
import com.google.common.base.Objects.ToStringHelper;
|
||||||
|
@ -41,7 +43,8 @@ import com.google.common.collect.Sets;
|
||||||
*
|
*
|
||||||
* @author grkvlt@apache.org
|
* @author grkvlt@apache.org
|
||||||
*/
|
*/
|
||||||
@XmlRootElement(name = "VirtualHardwareSection", namespace = VCLOUD_1_5_NS)
|
@XmlRootElement(name = "VirtualHardwareSection", namespace = OVF_NS)
|
||||||
|
@XmlType(name = "VirtualHardwareSection_Type")
|
||||||
@XmlSeeAlso({ org.jclouds.dmtf.ovf.VirtualHardwareSection.class })
|
@XmlSeeAlso({ org.jclouds.dmtf.ovf.VirtualHardwareSection.class })
|
||||||
public class VirtualHardwareSection extends org.jclouds.dmtf.ovf.VirtualHardwareSection {
|
public class VirtualHardwareSection extends org.jclouds.dmtf.ovf.VirtualHardwareSection {
|
||||||
|
|
||||||
|
|
|
@ -204,7 +204,7 @@ public interface VAppTemplateAsyncClient {
|
||||||
* @see VAppTemplateClient#getNetworkConnectionSection(URI)
|
* @see VAppTemplateClient#getNetworkConnectionSection(URI)
|
||||||
*/
|
*/
|
||||||
@GET
|
@GET
|
||||||
@Consumes(NETWORK_CONFIG_SECTION)
|
@Consumes(NETWORK_CONNECTION_SECTION)
|
||||||
@Path("/networkConnectionSection")
|
@Path("/networkConnectionSection")
|
||||||
@JAXBResponseParser
|
@JAXBResponseParser
|
||||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||||
|
|
|
@ -55,11 +55,12 @@ public class VCloudDirectorErrorHandler implements HttpErrorHandler {
|
||||||
: String.format("%s -> %s", command.getCurrentRequest().getRequestLine(), response.getStatusLine());
|
: String.format("%s -> %s", command.getCurrentRequest().getRequestLine(), response.getStatusLine());
|
||||||
Exception exception = new HttpResponseException(command, response, message);
|
Exception exception = new HttpResponseException(command, response, message);
|
||||||
|
|
||||||
// Try to create a VCloudDirectorException from XML payload
|
// Try to create a VCloudDirectorException from XML payload, if it exists
|
||||||
if (response.getPayload().getContentMetadata().getContentType().startsWith(VCloudDirectorMediaType.ERROR)) {
|
if (response.getPayload() != null && response.getPayload().getContentMetadata().getContentType().startsWith(VCloudDirectorMediaType.ERROR)) {
|
||||||
try {
|
try {
|
||||||
Error error = JAXB.unmarshal(InputSuppliers.of(data).getInput(), Error.class);
|
Error error = JAXB.unmarshal(InputSuppliers.of(data).getInput(), Error.class);
|
||||||
exception = new VCloudDirectorException(error);
|
exception = new VCloudDirectorException(error);
|
||||||
|
message = error.getMessage();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Throwables.propagate(e);
|
Throwables.propagate(e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.vcloud.director.v1_5.predicates;
|
package org.jclouds.vcloud.director.v1_5.predicates;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -34,7 +36,7 @@ import com.google.common.base.Predicate;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test a {@link Task} to see if it has succeeded.
|
* Test a {@link Task} status is in a particular set of {@link Task.Status statuses}.
|
||||||
*
|
*
|
||||||
* @author grkvlt@apache.org
|
* @author grkvlt@apache.org
|
||||||
*/
|
*/
|
||||||
|
@ -61,6 +63,7 @@ public class TaskStatusEquals implements Predicate<Task> {
|
||||||
/** @see Predicate#apply(Object) */
|
/** @see Predicate#apply(Object) */
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Task task) {
|
public boolean apply(Task task) {
|
||||||
|
checkNotNull(task, "task");
|
||||||
logger.trace("looking for status on task %s", task);
|
logger.trace("looking for status on task %s", task);
|
||||||
|
|
||||||
// TODO shouldn't we see if it's already done before getting it from API server?
|
// TODO shouldn't we see if it's already done before getting it from API server?
|
||||||
|
|
|
@ -18,6 +18,10 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.vcloud.director.v1_5.predicates;
|
package org.jclouds.vcloud.director.v1_5.predicates;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import java.util.EnumSet;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
@ -30,7 +34,7 @@ import org.jclouds.vcloud.director.v1_5.features.TaskClient;
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test a {@link Task} to see if it has succeeded.
|
* Test a {@link Task} to see if it has {@link Task.Status#SUCCESS succeeded}.
|
||||||
*
|
*
|
||||||
* @author grkvlt@apache.org
|
* @author grkvlt@apache.org
|
||||||
*/
|
*/
|
||||||
|
@ -50,21 +54,19 @@ public class TaskSuccess implements Predicate<Task> {
|
||||||
/** @see Predicate#apply(Object) */
|
/** @see Predicate#apply(Object) */
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Task task) {
|
public boolean apply(Task task) {
|
||||||
logger.trace("looking for status on task %s", task);
|
checkNotNull(task, "task");
|
||||||
|
logger.trace("looking for status on task %s", task.getOperationName());
|
||||||
|
|
||||||
// TODO shouldn't we see if it's already done before getting it from API server?
|
// TODO shouldn't we see if it's already done before getting it from API server?
|
||||||
task = taskClient.getTask(task.getHref());
|
task = taskClient.getTask(task.getHref());
|
||||||
|
|
||||||
// perhaps task isn't available, yet
|
// perhaps task isn't available, yet
|
||||||
if (task == null) return false;
|
if (task == null) return false;
|
||||||
logger.trace("%s: looking for status %s: currently: %s", task, Task.Status.SUCCESS, task.getStatus());
|
|
||||||
if (task.getStatus().equals(Task.Status.ERROR))
|
logger.trace("%s: looking for status %s: currently: %s", task.getOperationName(), Task.Status.SUCCESS, task.getStatus());
|
||||||
|
if (EnumSet.of(Task.Status.ERROR, Task.Status.CANCELED, Task.Status.ABORTED).contains(task.getStatus())) {
|
||||||
throw new VCloudDirectorException(task);
|
throw new VCloudDirectorException(task);
|
||||||
if (task.getStatus().equals(Task.Status.CANCELED))
|
} else return task.getStatus().equals(Task.Status.SUCCESS);
|
||||||
throw new VCloudDirectorException(task);
|
|
||||||
if (task.getStatus().equals(Task.Status.ABORTED))
|
|
||||||
throw new VCloudDirectorException(task);
|
|
||||||
return task.getStatus().equals(Task.Status.SUCCESS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -0,0 +1,114 @@
|
||||||
|
/*
|
||||||
|
* 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.vcloud.director.v1_5;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
import static org.testng.Assert.assertEquals;
|
||||||
|
import static org.testng.Assert.assertNotNull;
|
||||||
|
import static org.testng.Assert.assertTrue;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URI;
|
||||||
|
|
||||||
|
import org.jclouds.crypto.CryptoStreams;
|
||||||
|
import org.jclouds.http.HttpRequest;
|
||||||
|
import org.jclouds.http.HttpResponse;
|
||||||
|
import org.jclouds.util.Strings2;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.domain.OrgList;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.domain.SessionWithToken;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest;
|
||||||
|
import org.jclouds.xml.internal.JAXBParser;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableMultimap;
|
||||||
|
import com.google.common.collect.Iterables;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests live behavior of {@link AdminCatalogClient}.
|
||||||
|
*
|
||||||
|
* @author danikov
|
||||||
|
*/
|
||||||
|
@Test(groups = { "live", "user" }, singleThreaded = true, testName = "HttpClientLiveTest")
|
||||||
|
public class HttpClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
||||||
|
|
||||||
|
private JAXBParser parser = new JAXBParser("true");
|
||||||
|
private SessionWithToken sessionWithToken;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void setupRequiredClients() throws Exception {
|
||||||
|
setupCredentials();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(description = "POST /login")
|
||||||
|
public void testPostLogin() throws IOException {
|
||||||
|
testLoginWithMethod("POST");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(description = "GET /login")
|
||||||
|
public void testGetLogin() throws IOException {
|
||||||
|
testLoginWithMethod("GET");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void testLoginWithMethod(final String method) throws IOException {
|
||||||
|
String user = identity.substring(0, identity.lastIndexOf('@'));
|
||||||
|
String org = identity.substring(identity.lastIndexOf('@') + 1);
|
||||||
|
String password = credential;
|
||||||
|
|
||||||
|
String authHeader = "Basic " + CryptoStreams.base64(String.format("%s@%s:%s", checkNotNull(user), checkNotNull(org), checkNotNull(password)).getBytes("UTF-8"));
|
||||||
|
|
||||||
|
HttpResponse response = context.getUtils().getHttpClient().invoke(HttpRequest.builder()
|
||||||
|
.method(method)
|
||||||
|
.endpoint(URI.create(endpoint + "/login"))
|
||||||
|
.headers(ImmutableMultimap.<String, String>builder()
|
||||||
|
.put("Authorization", authHeader)
|
||||||
|
.put("Accept", "*/*")
|
||||||
|
.build())
|
||||||
|
.build());
|
||||||
|
|
||||||
|
sessionWithToken = SessionWithToken.builder().session(session).token(response.getFirstHeaderOrNull("x-vcloud-authorization")).build();
|
||||||
|
|
||||||
|
assertEquals(sessionWithToken.getSession().getUser(), user);
|
||||||
|
assertEquals(sessionWithToken.getSession().getOrg(), org);
|
||||||
|
assertTrue(sessionWithToken.getSession().getLinks().size() > 0);
|
||||||
|
assertNotNull(sessionWithToken.getToken());
|
||||||
|
|
||||||
|
OrgList orgList = parser.fromXML(Strings2.toStringAndClose(response.getPayload().getInput()), OrgList.class);
|
||||||
|
|
||||||
|
assertTrue(orgList.getOrgs().size() > 0, "must have orgs");
|
||||||
|
|
||||||
|
context.getApi().getOrgClient().getOrg(Iterables.getLast(orgList.getOrgs()).getHref());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(description = "GET /schema/{schemaFileName}", dependsOnMethods = { "testPostLogin", "testGetLogin" })
|
||||||
|
public void testGetSchema() throws IOException {
|
||||||
|
String schemafileName = "master.xsd";
|
||||||
|
HttpResponse response = context.getUtils().getHttpClient().invoke(HttpRequest.builder()
|
||||||
|
.method("GET")
|
||||||
|
.endpoint(URI.create(endpoint + "/v1.5/schema/" + schemafileName))
|
||||||
|
.headers(ImmutableMultimap.<String, String>builder()
|
||||||
|
.put("x-vcloud-authorization", sessionWithToken.getToken())
|
||||||
|
.put("Accept", "*/*")
|
||||||
|
.build())
|
||||||
|
.build());
|
||||||
|
|
||||||
|
String schema = Strings2.toStringAndClose(response.getPayload().getInput());
|
||||||
|
|
||||||
|
// TODO: asserting something about the schema
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,136 +0,0 @@
|
||||||
/*
|
|
||||||
* 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.vcloud.director.v1_5;
|
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static org.testng.Assert.assertEquals;
|
|
||||||
import static org.testng.Assert.assertNotNull;
|
|
||||||
import static org.testng.Assert.assertTrue;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.URI;
|
|
||||||
|
|
||||||
import org.jclouds.crypto.CryptoStreams;
|
|
||||||
import org.jclouds.http.HttpRequest;
|
|
||||||
import org.jclouds.http.HttpResponse;
|
|
||||||
import org.jclouds.util.Strings2;
|
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.OrgList;
|
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.SessionWithToken;
|
|
||||||
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest;
|
|
||||||
import org.jclouds.xml.internal.JAXBParser;
|
|
||||||
import org.testng.annotations.Test;
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMultimap;
|
|
||||||
import com.google.common.collect.Iterables;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests live behavior of {@link AdminCatalogClient}.
|
|
||||||
*
|
|
||||||
* @author danikov
|
|
||||||
*/
|
|
||||||
@Test(groups = {"live", "user", "nonClient"}, singleThreaded = true, testName = "NonClientOperationsLiveTest")
|
|
||||||
public class NonClientOperationsLiveTest extends BaseVCloudDirectorClientLiveTest
|
|
||||||
{
|
|
||||||
|
|
||||||
private JAXBParser parser = new JAXBParser("true");
|
|
||||||
|
|
||||||
private SessionWithToken sessionWithToken;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void setupRequiredClients() throws Exception
|
|
||||||
{
|
|
||||||
setupCredentials();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(testName = "POST /login")
|
|
||||||
public void testPostLogin() throws IOException
|
|
||||||
{
|
|
||||||
testLoginWithMethod("POST");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(testName = "GET /login")
|
|
||||||
public void testGetLogin() throws IOException
|
|
||||||
{
|
|
||||||
testLoginWithMethod("GET");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void testLoginWithMethod(final String method) throws IOException
|
|
||||||
{
|
|
||||||
String user = identity.substring(0, identity.lastIndexOf('@'));
|
|
||||||
String org = identity.substring(identity.lastIndexOf('@') + 1);
|
|
||||||
String password = credential;
|
|
||||||
|
|
||||||
String authHeader =
|
|
||||||
"Basic "
|
|
||||||
+ CryptoStreams.base64(String.format("%s@%s:%s", checkNotNull(user),
|
|
||||||
checkNotNull(org), checkNotNull(password)).getBytes("UTF-8"));
|
|
||||||
|
|
||||||
HttpResponse response =
|
|
||||||
context
|
|
||||||
.getUtils()
|
|
||||||
.getHttpClient()
|
|
||||||
.invoke(
|
|
||||||
HttpRequest
|
|
||||||
.builder()
|
|
||||||
.method(method)
|
|
||||||
.endpoint(URI.create(endpoint + "/login"))
|
|
||||||
.headers(ImmutableMultimap.of("Authorization", authHeader, "Accept", "*/*"))
|
|
||||||
.build());
|
|
||||||
|
|
||||||
sessionWithToken =
|
|
||||||
SessionWithToken.builder().session(session)
|
|
||||||
.token(response.getFirstHeaderOrNull("x-vcloud-authorization")).build();
|
|
||||||
|
|
||||||
assertEquals(sessionWithToken.getSession().getUser(), user);
|
|
||||||
assertEquals(sessionWithToken.getSession().getOrg(), org);
|
|
||||||
assertTrue(sessionWithToken.getSession().getLinks().size() > 0);
|
|
||||||
assertNotNull(sessionWithToken.getToken());
|
|
||||||
|
|
||||||
OrgList orgList =
|
|
||||||
parser.fromXML(Strings2.toStringAndClose(response.getPayload().getInput()),
|
|
||||||
OrgList.class);
|
|
||||||
|
|
||||||
assertTrue(orgList.getOrgs().size() > 0, "must have orgs");
|
|
||||||
|
|
||||||
context.getApi().getOrgClient().getOrg(Iterables.getLast(orgList.getOrgs()).getHref());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(testName = "GET /schema/{schemaFileName}", dependsOnMethods = {"testPostLogin",
|
|
||||||
"testGetLogin"})
|
|
||||||
public void testGetSchema() throws IOException
|
|
||||||
{
|
|
||||||
String schemafileName = "master.xsd";
|
|
||||||
HttpResponse response =
|
|
||||||
context
|
|
||||||
.getUtils()
|
|
||||||
.getHttpClient()
|
|
||||||
.invoke(
|
|
||||||
HttpRequest
|
|
||||||
.builder()
|
|
||||||
.method("GET")
|
|
||||||
.endpoint(URI.create(endpoint + "/v1.5/schema/" + schemafileName))
|
|
||||||
.headers(
|
|
||||||
ImmutableMultimap.of("x-vcloud-authorization",
|
|
||||||
sessionWithToken.getToken(), "Accept", "*/*")).build());
|
|
||||||
|
|
||||||
String schema = Strings2.toStringAndClose(response.getPayload().getInput());
|
|
||||||
|
|
||||||
// TODO: asserting something about the schema
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -51,6 +51,8 @@ public class VCloudDirectorLiveTestConstants {
|
||||||
|
|
||||||
public static final String OBJ_FIELD_GTE_1 = "ERR-108: %s field %s must be greater than to equal to 0 (%d)";
|
public static final String OBJ_FIELD_GTE_1 = "ERR-108: %s field %s must be greater than to equal to 0 (%d)";
|
||||||
|
|
||||||
|
public static final String OBJ_FIELD_GTE = "ERR-108: %s field %s must be greater than to equal to %d (%d)";
|
||||||
|
|
||||||
public static final String GETTER_RETURNS_SAME_OBJ = "ERR-109: %s should return the same %s as %s (%s, %s)";
|
public static final String GETTER_RETURNS_SAME_OBJ = "ERR-109: %s should return the same %s as %s (%s, %s)";
|
||||||
|
|
||||||
public static final String OBJ_FIELD_UPDATABLE = "ERR-110: %s field %s should be updatable";
|
public static final String OBJ_FIELD_UPDATABLE = "ERR-110: %s field %s should be updatable";
|
||||||
|
@ -89,6 +91,12 @@ public class VCloudDirectorLiveTestConstants {
|
||||||
|
|
||||||
public static final String MATCHES_STRING_FMT = "ERR-127: The %s field must match the pattern \"%s\" (%s)";
|
public static final String MATCHES_STRING_FMT = "ERR-127: The %s field must match the pattern \"%s\" (%s)";
|
||||||
|
|
||||||
|
public static final String OBJ_FIELD_LIST_EMPTY = "ERR-128: %s %s must be empty (%d members)";
|
||||||
|
|
||||||
|
public static final String OBJ_FIELD_LIST_SIZE_EQ = "ERR-129: %s %s must have %d members (%d members)";
|
||||||
|
|
||||||
|
public static final String OBJ_FIELD_LIST_SIZE_GE = "ERR-130: %s %s must have at least %d members (%d members)";
|
||||||
|
|
||||||
/* Error codes from 300 to 399 reflect entities and their links and relationship errors. */
|
/* Error codes from 300 to 399 reflect entities and their links and relationship errors. */
|
||||||
|
|
||||||
public static final String ENTITY_NON_NULL = "ERR-301: The %s entity must not be null";
|
public static final String ENTITY_NON_NULL = "ERR-301: The %s entity must not be null";
|
||||||
|
|
|
@ -582,6 +582,8 @@ public class Checks {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void checkVmPendingQuestion(VmPendingQuestion question) {
|
public static void checkVmPendingQuestion(VmPendingQuestion question) {
|
||||||
|
assertNotNull(question, String.format(NOT_NULL_OBJ_FMT, "VmPendingQuestion"));
|
||||||
|
|
||||||
// Check required fields
|
// Check required fields
|
||||||
assertNotNull(question.getQuestion(), String.format(OBJ_FIELD_REQ, "VmPendingQuestion", "Question"));
|
assertNotNull(question.getQuestion(), String.format(OBJ_FIELD_REQ, "VmPendingQuestion", "Question"));
|
||||||
assertNotNull(question.getQuestionId(), String.format(OBJ_FIELD_REQ, "VmPendingQuestion", "QuestionId"));
|
assertNotNull(question.getQuestionId(), String.format(OBJ_FIELD_REQ, "VmPendingQuestion", "QuestionId"));
|
||||||
|
@ -727,7 +729,7 @@ public class Checks {
|
||||||
// NOTE transport cannot be checked
|
// NOTE transport cannot be checked
|
||||||
if (hardware.getItems() != null) {
|
if (hardware.getItems() != null) {
|
||||||
for (ResourceAllocationSettingData item : hardware.getItems()) {
|
for (ResourceAllocationSettingData item : hardware.getItems()) {
|
||||||
checkResourceAllocationSettingData((RasdItem) item);
|
checkResourceAllocationSettingData(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -758,7 +760,7 @@ public class Checks {
|
||||||
// assertNotNull(virtualSystem.getVirtualSystemType(), String.format(OBJ_FIELD_REQ, "VirtualSystemSettingData", "virtualSystemType"));
|
// assertNotNull(virtualSystem.getVirtualSystemType(), String.format(OBJ_FIELD_REQ, "VirtualSystemSettingData", "virtualSystemType"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void checkResourceAllocationSettingData(RasdItem item) {
|
public static void checkResourceAllocationSettingData(ResourceAllocationSettingData item) {
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ import com.google.common.collect.ImmutableSet;
|
||||||
*
|
*
|
||||||
* @author grkvlt@apache.org
|
* @author grkvlt@apache.org
|
||||||
*/
|
*/
|
||||||
@Test(groups = { "unit", "user", "catalog" }, singleThreaded = true, testName = "CatalogClientExpectTest")
|
@Test(groups = { "unit", "user" }, singleThreaded = true, testName = "CatalogClientExpectTest")
|
||||||
public class CatalogClientExpectTest extends VCloudDirectorClientExpectTest {
|
public class CatalogClientExpectTest extends VCloudDirectorClientExpectTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -25,7 +25,6 @@ import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.O
|
||||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.REF_REQ_LIVE;
|
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.REF_REQ_LIVE;
|
||||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.TASK_COMPLETE_TIMELY;
|
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.TASK_COMPLETE_TIMELY;
|
||||||
import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkCatalogItem;
|
import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkCatalogItem;
|
||||||
import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkError;
|
|
||||||
import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkMetadata;
|
import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkMetadata;
|
||||||
import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkMetadataValue;
|
import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkMetadataValue;
|
||||||
import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkTask;
|
import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkTask;
|
||||||
|
@ -35,9 +34,7 @@ import static org.testng.Assert.assertEquals;
|
||||||
import static org.testng.Assert.assertNotNull;
|
import static org.testng.Assert.assertNotNull;
|
||||||
import static org.testng.Assert.assertNull;
|
import static org.testng.Assert.assertNull;
|
||||||
import static org.testng.Assert.assertTrue;
|
import static org.testng.Assert.assertTrue;
|
||||||
import static org.testng.Assert.fail;
|
|
||||||
|
|
||||||
import org.jclouds.vcloud.director.v1_5.VCloudDirectorException;
|
|
||||||
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
|
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.AdminCatalog;
|
import org.jclouds.vcloud.director.v1_5.domain.AdminCatalog;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.CatalogItem;
|
import org.jclouds.vcloud.director.v1_5.domain.CatalogItem;
|
||||||
|
@ -64,7 +61,7 @@ import com.google.common.collect.Iterables;
|
||||||
*
|
*
|
||||||
* @author grkvlt@apache.org
|
* @author grkvlt@apache.org
|
||||||
*/
|
*/
|
||||||
@Test(groups = { "live", "user", "catalog" }, singleThreaded = true, testName = "CatalogClientLiveTest")
|
@Test(groups = { "live", "user" }, singleThreaded = true, testName = "CatalogClientLiveTest")
|
||||||
public class CatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
public class CatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -112,22 +109,29 @@ public class CatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
||||||
|
|
||||||
@AfterClass(alwaysRun = true)
|
@AfterClass(alwaysRun = true)
|
||||||
public void tearDown() {
|
public void tearDown() {
|
||||||
if (catalogItem != null)
|
if (catalogItem != null) {
|
||||||
catalogClient.deleteCatalogItem(catalogItem.getHref());
|
|
||||||
|
|
||||||
if (media != null)
|
|
||||||
context.getApi().getMediaClient().deleteMedia(media.getHref());
|
|
||||||
|
|
||||||
if (adminCatalog != null) {
|
|
||||||
adminContext.getApi().getCatalogClient().deleteCatalog(adminCatalog.getHref());
|
|
||||||
try {
|
try {
|
||||||
catalogClient.getCatalog(catalogRef.getHref());
|
catalogClient.deleteCatalogItem(catalogItem.getHref());
|
||||||
fail("The Catalog should have been deleted");
|
} catch (Exception e) {
|
||||||
} catch (VCloudDirectorException vcde) {
|
logger.warn(e, "Error when deleting catalog item '%s'", catalogItem.getName());
|
||||||
checkError(vcde.getError());
|
|
||||||
assertEquals(vcde.getError().getMajorErrorCode(), Integer.valueOf(403), "The majorErrorCode should be 403 since the item has been deleted");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (media != null) {
|
||||||
|
try {
|
||||||
|
Task delete = context.getApi().getMediaClient().deleteMedia(media.getHref());
|
||||||
|
taskDoneEventually(delete);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.warn(e, "Error when deleting media '%s'", media.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (adminContext != null && adminCatalog != null) {
|
||||||
|
try {
|
||||||
|
adminContext.getApi().getCatalogClient().deleteCatalog(adminCatalog.getHref());
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.warn(e, "Error when deleting catalog '%s'", adminCatalog.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// TODO wait for tasks
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(description = "GET /catalog/{id}")
|
@Test(description = "GET /catalog/{id}")
|
||||||
|
|
|
@ -49,7 +49,7 @@ import com.google.common.collect.ImmutableSet;
|
||||||
*
|
*
|
||||||
* @author danikov
|
* @author danikov
|
||||||
*/
|
*/
|
||||||
@Test(groups = { "unit", "user", "media" }, singleThreaded = true, testName = "MediaClientExpectTest")
|
@Test(groups = { "unit", "user" }, singleThreaded = true, testName = "MediaClientExpectTest")
|
||||||
public class MediaClientExpectTest extends VCloudDirectorAdminClientExpectTest {
|
public class MediaClientExpectTest extends VCloudDirectorAdminClientExpectTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -32,6 +32,8 @@ import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.O
|
||||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_REQ;
|
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_REQ;
|
||||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_REQ_LIVE;
|
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_REQ_LIVE;
|
||||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_UPDATABLE;
|
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_UPDATABLE;
|
||||||
|
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_LIST_SIZE_EQ;
|
||||||
|
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_LIST_SIZE_GE;
|
||||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_REQ_LIVE;
|
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_REQ_LIVE;
|
||||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.REF_REQ_LIVE;
|
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.REF_REQ_LIVE;
|
||||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.TASK_COMPLETE_TIMELY;
|
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.TASK_COMPLETE_TIMELY;
|
||||||
|
@ -42,18 +44,15 @@ import static org.testng.Assert.assertFalse;
|
||||||
import static org.testng.Assert.assertNotNull;
|
import static org.testng.Assert.assertNotNull;
|
||||||
import static org.testng.Assert.assertNull;
|
import static org.testng.Assert.assertNull;
|
||||||
import static org.testng.Assert.assertTrue;
|
import static org.testng.Assert.assertTrue;
|
||||||
import static org.testng.Assert.fail;
|
|
||||||
|
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.jclouds.io.Payloads;
|
import org.jclouds.io.Payloads;
|
||||||
import org.jclouds.vcloud.director.v1_5.VCloudDirectorException;
|
|
||||||
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
|
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.Checks;
|
import org.jclouds.vcloud.director.v1_5.domain.Checks;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.CloneMediaParams;
|
import org.jclouds.vcloud.director.v1_5.domain.CloneMediaParams;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.Error;
|
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.File;
|
import org.jclouds.vcloud.director.v1_5.domain.File;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.Link;
|
import org.jclouds.vcloud.director.v1_5.domain.Link;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.Media;
|
import org.jclouds.vcloud.director.v1_5.domain.Media;
|
||||||
|
@ -65,10 +64,12 @@ import org.jclouds.vcloud.director.v1_5.domain.Reference;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.Task;
|
import org.jclouds.vcloud.director.v1_5.domain.Task;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.Vdc;
|
import org.jclouds.vcloud.director.v1_5.domain.Vdc;
|
||||||
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest;
|
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.predicates.LinkPredicates;
|
||||||
import org.testng.annotations.AfterClass;
|
import org.testng.annotations.AfterClass;
|
||||||
import org.testng.annotations.BeforeClass;
|
import org.testng.annotations.BeforeClass;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import com.google.common.base.Predicates;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
|
|
||||||
|
@ -77,7 +78,7 @@ import com.google.common.collect.Iterables;
|
||||||
*
|
*
|
||||||
* @author danikov
|
* @author danikov
|
||||||
*/
|
*/
|
||||||
@Test(groups = { "live", "user", "media" }, singleThreaded = true, testName = "MediaClientLiveTest")
|
@Test(groups = { "live", "user" }, singleThreaded = true, testName = "MediaClientLiveTest")
|
||||||
public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
||||||
|
|
||||||
public static final String MEDIA = "media";
|
public static final String MEDIA = "media";
|
||||||
|
@ -108,10 +109,20 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
||||||
@AfterClass(alwaysRun = true)
|
@AfterClass(alwaysRun = true)
|
||||||
protected void tidyUp() {
|
protected void tidyUp() {
|
||||||
if (media != null) {
|
if (media != null) {
|
||||||
assertTaskSucceeds(mediaClient.deleteMedia(media.getHref()));
|
try {
|
||||||
|
Task delete = mediaClient.deleteMedia(media.getHref());
|
||||||
|
taskDoneEventually(delete);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.warn(e, "Error when deleting media '%s': %s", media.getName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (oldMedia != null) {
|
if (oldMedia != null) {
|
||||||
assertTaskSucceeds(mediaClient.deleteMedia(oldMedia.getHref()));
|
try {
|
||||||
|
Task delete = mediaClient.deleteMedia(oldMedia.getHref());
|
||||||
|
taskDoneEventually(delete);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.warn(e, "Error when deleting media '%s': %s", oldMedia.getName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,29 +148,27 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
||||||
Checks.checkMediaFor(MEDIA, media);
|
Checks.checkMediaFor(MEDIA, media);
|
||||||
|
|
||||||
assertNotNull(media.getFiles(), String.format(OBJ_FIELD_REQ, MEDIA, "files"));
|
assertNotNull(media.getFiles(), String.format(OBJ_FIELD_REQ, MEDIA, "files"));
|
||||||
assertTrue(media.getFiles().size() == 1, String.format(OBJ_FIELD_EQ, MEDIA, "files.size()", "1",
|
assertTrue(media.getFiles().size() == 1, String.format(OBJ_FIELD_LIST_SIZE_EQ, MEDIA, "files", 1, media.getFiles().size()));
|
||||||
media.getFiles().size()));
|
|
||||||
File uploadFile = getFirst(media.getFiles(), null);
|
File uploadFile = getFirst(media.getFiles(), null);
|
||||||
assertNotNull(uploadFile, String.format(OBJ_FIELD_REQ, MEDIA, "files.first"));
|
assertNotNull(uploadFile, String.format(OBJ_FIELD_REQ, MEDIA, "files.first"));
|
||||||
assertEquals(uploadFile.getSize(), new Long(iso.length));
|
assertEquals(uploadFile.getSize(), new Long(iso.length));
|
||||||
assertTrue(equal(uploadFile.getSize(), sourceMedia.getSize()), String.format(OBJ_FIELD_EQ, MEDIA, "uploadFile.size()",
|
assertEquals(uploadFile.getSize().longValue(), sourceMedia.getSize(),
|
||||||
sourceMedia.getSize(), uploadFile.getSize()));
|
String.format(OBJ_FIELD_EQ, MEDIA, "uploadFile.size()", sourceMedia.getSize(), uploadFile.getSize()));
|
||||||
|
|
||||||
Set<Link> links = uploadFile.getLinks();
|
Set<Link> links = uploadFile.getLinks();
|
||||||
assertNotNull(links, String.format(OBJ_FIELD_REQ, MEDIA, "uploadFile.links"));
|
assertNotNull(links, String.format(OBJ_FIELD_REQ, MEDIA, "uploadFile.links"));
|
||||||
assertTrue(links.size() == 1, String.format(OBJ_FIELD_EQ, MEDIA, "uploadfile.links.size()", "1",
|
assertTrue(links.size() >= 1, String.format(OBJ_FIELD_LIST_SIZE_GE, MEDIA, "uploadfile.links", 1, links.size()));
|
||||||
links.size()));
|
assertTrue(Iterables.all(links, Predicates.or(LinkPredicates.relEquals(Link.Rel.UPLOAD_DEFAULT), LinkPredicates.relEquals(Link.Rel.UPLOAD_ALTERNATE))),
|
||||||
Link uploadLink = getFirst(links, null);
|
String.format(OBJ_FIELD_REQ, MEDIA, "uploadFile.links.first"));
|
||||||
assertTrue(equal(uploadLink.getRel(), Link.Rel.UPLOAD_DEFAULT), String.format(OBJ_FIELD_REQ, MEDIA, "uploadFile.links.first"));
|
|
||||||
|
|
||||||
|
Link uploadLink = Iterables.find(links, LinkPredicates.relEquals(Link.Rel.UPLOAD_DEFAULT));
|
||||||
context.getApi().getUploadClient().upload(uploadLink.getHref(), Payloads.newByteArrayPayload(iso));
|
context.getApi().getUploadClient().upload(uploadLink.getHref(), Payloads.newByteArrayPayload(iso));
|
||||||
|
|
||||||
media = mediaClient.getMedia(media.getHref());
|
media = mediaClient.getMedia(media.getHref());
|
||||||
|
|
||||||
if (media.getTasks().size() == 1) {
|
if (media.getTasks().size() == 1) {
|
||||||
Task uploadTask = Iterables.getOnlyElement(media.getTasks());
|
Task uploadTask = Iterables.getOnlyElement(media.getTasks());
|
||||||
Checks.checkTask(uploadTask);
|
Checks.checkTask(uploadTask);
|
||||||
assertEquals(uploadTask.getStatus(), "running");
|
assertEquals(uploadTask.getStatus(), Task.Status.RUNNING);
|
||||||
assertTrue(retryTaskSuccess.apply(uploadTask), String.format(TASK_COMPLETE_TIMELY, "uploadTask"));
|
assertTrue(retryTaskSuccess.apply(uploadTask), String.format(TASK_COMPLETE_TIMELY, "uploadTask"));
|
||||||
media = mediaClient.getMedia(media.getHref());
|
media = mediaClient.getMedia(media.getHref());
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,7 @@ import com.google.common.collect.ImmutableSet;
|
||||||
*
|
*
|
||||||
* @author danikov
|
* @author danikov
|
||||||
*/
|
*/
|
||||||
@Test(groups = { "unit", "user", "network" }, singleThreaded = true, testName = "NetworkClientExpectTest")
|
@Test(groups = { "unit", "user" }, singleThreaded = true, testName = "NetworkClientExpectTest")
|
||||||
public class NetworkClientExpectTest extends VCloudDirectorAdminClientExpectTest {
|
public class NetworkClientExpectTest extends VCloudDirectorAdminClientExpectTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -36,6 +36,7 @@ import org.jclouds.vcloud.director.v1_5.domain.MetadataEntry;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.MetadataValue;
|
import org.jclouds.vcloud.director.v1_5.domain.MetadataValue;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.Network;
|
import org.jclouds.vcloud.director.v1_5.domain.Network;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.OrgNetwork;
|
import org.jclouds.vcloud.director.v1_5.domain.OrgNetwork;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.domain.Task;
|
||||||
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest;
|
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest;
|
||||||
import org.testng.annotations.AfterClass;
|
import org.testng.annotations.AfterClass;
|
||||||
import org.testng.annotations.BeforeClass;
|
import org.testng.annotations.BeforeClass;
|
||||||
|
@ -48,7 +49,7 @@ import com.google.common.collect.Iterables;
|
||||||
*
|
*
|
||||||
* @author danikov
|
* @author danikov
|
||||||
*/
|
*/
|
||||||
@Test(groups = { "live", "user", "network" }, singleThreaded = true, testName = "NetworkClientLiveTest")
|
@Test(groups = { "live", "user" }, singleThreaded = true, testName = "NetworkClientLiveTest")
|
||||||
public class NetworkClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
public class NetworkClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
||||||
|
|
||||||
public static final String NETWORK = "network";
|
public static final String NETWORK = "network";
|
||||||
|
@ -67,10 +68,14 @@ public class NetworkClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass(alwaysRun = true)
|
@AfterClass(alwaysRun = true)
|
||||||
public void cleanUp() throws Exception {
|
public void cleanUp() {
|
||||||
if (metadataSet) {
|
if (metadataSet) {
|
||||||
adminContext.getApi().getNetworkClient().getMetadataClient()
|
try {
|
||||||
.deleteMetadataEntry(toAdminUri(networkURI), "key");
|
Task delete = adminContext.getApi().getNetworkClient().getMetadataClient().deleteMetadataEntry(toAdminUri(networkURI), "key");
|
||||||
|
taskDoneEventually(delete);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.warn(e, "Error when deleting metadata");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ import com.google.common.collect.Iterables;
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = { "unit", "user", "org" }, singleThreaded = true, testName = "OrgClientExpectTest")
|
@Test(groups = { "unit", "user" }, singleThreaded = true, testName = "OrgClientExpectTest")
|
||||||
public class OrgClientExpectTest extends VCloudDirectorAdminClientExpectTest {
|
public class OrgClientExpectTest extends VCloudDirectorAdminClientExpectTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -40,6 +40,7 @@ import org.jclouds.vcloud.director.v1_5.domain.MetadataValue;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.Org;
|
import org.jclouds.vcloud.director.v1_5.domain.Org;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.OrgList;
|
import org.jclouds.vcloud.director.v1_5.domain.OrgList;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.Reference;
|
import org.jclouds.vcloud.director.v1_5.domain.Reference;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.domain.Task;
|
||||||
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest;
|
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest;
|
||||||
import org.testng.annotations.AfterClass;
|
import org.testng.annotations.AfterClass;
|
||||||
import org.testng.annotations.BeforeClass;
|
import org.testng.annotations.BeforeClass;
|
||||||
|
@ -52,7 +53,7 @@ import com.google.common.collect.Iterables;
|
||||||
*
|
*
|
||||||
* @author grkvlt@apache.org
|
* @author grkvlt@apache.org
|
||||||
*/
|
*/
|
||||||
@Test(groups = { "live", "user", "org" }, singleThreaded = true, testName = "OrgClientLiveTest")
|
@Test(groups = { "live", "user" }, singleThreaded = true, testName = "OrgClientLiveTest")
|
||||||
public class OrgClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
public class OrgClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -73,11 +74,17 @@ public class OrgClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
||||||
@AfterClass(alwaysRun = true)
|
@AfterClass(alwaysRun = true)
|
||||||
public void cleanUp() throws Exception {
|
public void cleanUp() throws Exception {
|
||||||
if (adminMembersSet) {
|
if (adminMembersSet) {
|
||||||
adminContext.getApi().getOrgClient().getMetadataClient()
|
try {
|
||||||
.deleteMetadataEntry(toAdminUri(orgURI), "KEY");
|
Task delete = adminContext.getApi().getOrgClient().getMetadataClient().deleteMetadataEntry(toAdminUri(orgURI), "KEY");
|
||||||
|
taskDoneEventually(delete);
|
||||||
adminContext.getApi().getCatalogClient()
|
} catch (Exception e) {
|
||||||
.deleteCatalog(catalogRef);
|
logger.warn(e, "Error when deleting metadata entry");
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
adminContext.getApi().getCatalogClient().deleteCatalog(catalogRef);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.warn(e, "Error when deleting catalog'%s': %s", catalogRef);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ import com.google.common.collect.ImmutableMultimap;
|
||||||
*
|
*
|
||||||
* @author grkvlt@apache.org
|
* @author grkvlt@apache.org
|
||||||
*/
|
*/
|
||||||
@Test(groups = { "unit", "user", "query" }, singleThreaded = true, testName = "QueryClientExpectTest")
|
@Test(groups = { "unit", "user" }, singleThreaded = true, testName = "QueryClientExpectTest")
|
||||||
public class QueryClientExpectTest extends VCloudDirectorAdminClientExpectTest {
|
public class QueryClientExpectTest extends VCloudDirectorAdminClientExpectTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -61,7 +61,7 @@ import com.google.common.collect.Iterables;
|
||||||
*
|
*
|
||||||
* @author grkvlt@apache.org
|
* @author grkvlt@apache.org
|
||||||
*/
|
*/
|
||||||
@Test(groups = { "live", "user", "query" }, singleThreaded = true, testName = "QueryClientLiveTest")
|
@Test(groups = { "live", "user" }, singleThreaded = true, testName = "QueryClientLiveTest")
|
||||||
public class QueryClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
public class QueryClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -76,9 +76,7 @@ public class QueryClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
||||||
|
|
||||||
@AfterClass(alwaysRun = true)
|
@AfterClass(alwaysRun = true)
|
||||||
public void cleanUp() throws Exception {
|
public void cleanUp() throws Exception {
|
||||||
if (vApp != null) {
|
if (vApp != null) cleanUpVApp(vApp);
|
||||||
cleanUpVApp(vApp);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -43,7 +43,7 @@ import com.google.common.collect.ImmutableMultimap;
|
||||||
*
|
*
|
||||||
* @author grkvlt@apache.org
|
* @author grkvlt@apache.org
|
||||||
*/
|
*/
|
||||||
@Test(groups = { "unit", "user", "task" }, singleThreaded = true, testName = "TaskClientExpectTest")
|
@Test(groups = { "unit", "user" }, singleThreaded = true, testName = "TaskClientExpectTest")
|
||||||
public class TaskClientExpectTest extends VCloudDirectorAdminClientExpectTest {
|
public class TaskClientExpectTest extends VCloudDirectorAdminClientExpectTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -43,7 +43,7 @@ import com.google.common.collect.Iterables;
|
||||||
*
|
*
|
||||||
* @author grkvlt@apache.org
|
* @author grkvlt@apache.org
|
||||||
*/
|
*/
|
||||||
@Test(groups = { "live", "user", "task" }, singleThreaded = true, testName = "TaskClientLiveTest")
|
@Test(groups = { "live", "user" }, singleThreaded = true, testName = "TaskClientLiveTest")
|
||||||
public class TaskClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
public class TaskClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -27,7 +27,7 @@ import org.testng.annotations.Test;
|
||||||
*
|
*
|
||||||
* @author danikov
|
* @author danikov
|
||||||
*/
|
*/
|
||||||
@Test(groups = { "live", "user", "upload" }, singleThreaded = true, testName = "UploadClientLiveTest")
|
@Test(groups = { "live", "user" }, singleThreaded = true, testName = "UploadClientLiveTest")
|
||||||
public class UploadClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
public class UploadClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
||||||
|
|
||||||
public static final String UPLOAD = "upload";
|
public static final String UPLOAD = "upload";
|
||||||
|
|
|
@ -64,7 +64,7 @@ import com.google.common.collect.Multimaps;
|
||||||
*
|
*
|
||||||
* @author grkvlt@apache.org
|
* @author grkvlt@apache.org
|
||||||
*/
|
*/
|
||||||
@Test(groups = { "unit", "user", "vapp" }, singleThreaded = true, testName = "VAppClientExpectTest")
|
@Test(groups = { "unit", "user" }, singleThreaded = true, testName = "VAppClientExpectTest")
|
||||||
public class VAppClientExpectTest extends VCloudDirectorAdminClientExpectTest {
|
public class VAppClientExpectTest extends VCloudDirectorAdminClientExpectTest {
|
||||||
|
|
||||||
private String vAppId = "vapp-d0e2b6b9-4381-4ddc-9572-cdfae54059be";
|
private String vAppId = "vapp-d0e2b6b9-4381-4ddc-9572-cdfae54059be";
|
||||||
|
|
|
@ -129,21 +129,21 @@ import com.google.common.collect.Sets;
|
||||||
*
|
*
|
||||||
* @author grkvlt@apache.org
|
* @author grkvlt@apache.org
|
||||||
*/
|
*/
|
||||||
@Test(groups = { "live", "user", "vapp" }, singleThreaded = true, testName = "VAppClientLiveTest")
|
@Test(groups = { "live", "user" }, singleThreaded = true, testName = "VAppClientLiveTest")
|
||||||
public class VAppClientLiveTest extends AbstractVAppClientLiveTest {
|
public class VAppClientLiveTest extends AbstractVAppClientLiveTest {
|
||||||
|
|
||||||
private MetadataValue metadataValue;
|
private MetadataValue metadataValue;
|
||||||
private String key;
|
private String key;
|
||||||
private URI mediaURI;
|
|
||||||
private URI testUserURI;
|
private URI testUserURI;
|
||||||
|
private boolean mediaCreated = false;
|
||||||
|
private boolean testUserCreated = false;
|
||||||
|
|
||||||
@Override
|
@BeforeClass(alwaysRun = true, dependsOnMethods = { "setupRequiredClients" })
|
||||||
@BeforeClass(alwaysRun = true)
|
protected void setupRequiredEntities() {
|
||||||
protected void setupRequiredClients() {
|
|
||||||
super.setupRequiredClients();
|
|
||||||
|
|
||||||
Set<Link> links = vdcClient.getVdc(vdcURI).getLinks();
|
Set<Link> links = vdcClient.getVdc(vdcURI).getLinks();
|
||||||
Predicate<Link> addMediaLink = and(relEquals("add"), typeEquals(VCloudDirectorMediaType.MEDIA));
|
|
||||||
|
if (mediaURI == null) {
|
||||||
|
Predicate<Link> addMediaLink = and(relEquals(Link.Rel.ADD), typeEquals(VCloudDirectorMediaType.MEDIA));
|
||||||
|
|
||||||
if (contains(links, addMediaLink)) {
|
if (contains(links, addMediaLink)) {
|
||||||
Link addMedia = find(links, addMediaLink);
|
Link addMedia = find(links, addMediaLink);
|
||||||
|
@ -172,8 +172,8 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
mediaURI = media.getHref();
|
mediaURI = media.getHref();
|
||||||
} else {
|
mediaCreated = true;
|
||||||
mediaURI = super.mediaURI;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (adminContext != null) {
|
if (adminContext != null) {
|
||||||
|
@ -187,8 +187,20 @@ public class VAppClientLiveTest extends AbstractVAppClientLiveTest {
|
||||||
@Override
|
@Override
|
||||||
@AfterClass(alwaysRun = true)
|
@AfterClass(alwaysRun = true)
|
||||||
public void cleanUp() {
|
public void cleanUp() {
|
||||||
if (adminContext != null && mediaURI != null) {
|
if (adminContext != null && mediaCreated && mediaURI != null) {
|
||||||
assertTaskDoneEventually(context.getApi().getMediaClient().deleteMedia(mediaURI));
|
try {
|
||||||
|
Task delete = context.getApi().getMediaClient().deleteMedia(mediaURI);
|
||||||
|
taskDoneEventually(delete);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.warn("Error when deleting media: %s", e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (adminContext != null && testUserCreated && testUserURI != null) {
|
||||||
|
try {
|
||||||
|
adminContext.getApi().getUserClient().deleteUser(testUserURI);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.warn("Error when deleting user: %s", e.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -77,7 +77,7 @@ import com.google.common.collect.ImmutableSet;
|
||||||
*
|
*
|
||||||
* @author Adam Lowe
|
* @author Adam Lowe
|
||||||
*/
|
*/
|
||||||
@Test(groups = { "unit", "user", "vapptemplate" }, testName = "VAppTemplateClientExpectTest")
|
@Test(groups = { "unit", "user" }, testName = "VAppTemplateClientExpectTest")
|
||||||
public class VAppTemplateClientExpectTest extends VCloudDirectorAdminClientExpectTest {
|
public class VAppTemplateClientExpectTest extends VCloudDirectorAdminClientExpectTest {
|
||||||
|
|
||||||
public VAppTemplateClientExpectTest() {
|
public VAppTemplateClientExpectTest() {
|
||||||
|
|
|
@ -84,7 +84,7 @@ import com.google.common.collect.Iterables;
|
||||||
*
|
*
|
||||||
* @author Aled Sage
|
* @author Aled Sage
|
||||||
*/
|
*/
|
||||||
@Test(groups = { "live", "user", "vapptemplate" }, singleThreaded = true, testName = "VAppTemplateClientLiveTest")
|
@Test(groups = { "live", "user" }, singleThreaded = true, testName = "VAppTemplateClientLiveTest")
|
||||||
public class VAppTemplateClientLiveTest extends AbstractVAppClientLiveTest {
|
public class VAppTemplateClientLiveTest extends AbstractVAppClientLiveTest {
|
||||||
|
|
||||||
private String key;
|
private String key;
|
||||||
|
@ -93,7 +93,12 @@ public class VAppTemplateClientLiveTest extends AbstractVAppClientLiveTest {
|
||||||
@AfterClass(alwaysRun = true)
|
@AfterClass(alwaysRun = true)
|
||||||
protected void tidyUp() {
|
protected void tidyUp() {
|
||||||
if (key != null) {
|
if (key != null) {
|
||||||
assertTaskSucceeds(vAppTemplateClient.getMetadataClient().deleteMetadataEntry(vAppTemplateURI, key));
|
try {
|
||||||
|
Task delete = vAppTemplateClient.getMetadataClient().deleteMetadataEntry(vAppTemplateURI, key);
|
||||||
|
taskDoneEventually(delete);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.warn(e, "Error when deleting metadata entry '%s'", key);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@ import org.testng.annotations.Test;
|
||||||
*
|
*
|
||||||
* @author danikov
|
* @author danikov
|
||||||
*/
|
*/
|
||||||
@Test(groups = { "unit", "user", "vdc" }, singleThreaded = true, testName = "VdcClientExpectTest")
|
@Test(groups = { "unit", "user" }, singleThreaded = true, testName = "VdcClientExpectTest")
|
||||||
public class VdcClientExpectTest extends VCloudDirectorAdminClientExpectTest {
|
public class VdcClientExpectTest extends VCloudDirectorAdminClientExpectTest {
|
||||||
|
|
||||||
private URI vdcURI;
|
private URI vdcURI;
|
||||||
|
|
|
@ -66,7 +66,7 @@ import com.google.common.collect.Iterables;
|
||||||
*
|
*
|
||||||
* @author danikov
|
* @author danikov
|
||||||
*/
|
*/
|
||||||
@Test(groups = { "live", "user", "vdc" }, singleThreaded = true, testName = "VdcClientLiveTest")
|
@Test(groups = { "live", "user" }, singleThreaded = true, testName = "VdcClientLiveTest")
|
||||||
public class VdcClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
public class VdcClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
||||||
|
|
||||||
public static final String VDC = "vdc";
|
public static final String VDC = "vdc";
|
||||||
|
@ -118,8 +118,12 @@ public class VdcClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (metadataSet) {
|
if (metadataSet) {
|
||||||
adminContext.getApi().getVdcClient().getMetadataClient()
|
try {
|
||||||
.deleteMetadataEntry(toAdminUri(vdcURI), "key");
|
Task delete = adminContext.getApi().getVdcClient().getMetadataClient().deleteMetadataEntry(toAdminUri(vdcURI), "key");
|
||||||
|
taskDoneEventually(delete);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.warn(e, "Error deleting metadata entry");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ import com.google.common.collect.ImmutableSet;
|
||||||
*
|
*
|
||||||
* @author grkvlt@apache.org
|
* @author grkvlt@apache.org
|
||||||
*/
|
*/
|
||||||
@Test(groups = { "unit", "admin", "catalog" }, singleThreaded = true, testName = "CatalogClientExpectTest")
|
@Test(groups = { "unit", "admin" }, singleThreaded = true, testName = "CatalogClientExpectTest")
|
||||||
public class AdminCatalogClientExpectTest extends VCloudDirectorAdminClientExpectTest {
|
public class AdminCatalogClientExpectTest extends VCloudDirectorAdminClientExpectTest {
|
||||||
|
|
||||||
private Reference catalogRef = Reference.builder()
|
private Reference catalogRef = Reference.builder()
|
||||||
|
|
|
@ -54,7 +54,7 @@ import com.google.common.collect.Iterables;
|
||||||
*
|
*
|
||||||
* @author danikov
|
* @author danikov
|
||||||
*/
|
*/
|
||||||
@Test(groups = { "live", "admin", "catalog" }, singleThreaded = true, testName = "CatalogClientLiveTest")
|
@Test(groups = { "live", "admin" }, singleThreaded = true, testName = "CatalogClientLiveTest")
|
||||||
public class AdminCatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
public class AdminCatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
||||||
|
|
||||||
public static final String CATALOG = "admin catalog";
|
public static final String CATALOG = "admin catalog";
|
||||||
|
@ -83,13 +83,10 @@ public class AdminCatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest
|
||||||
@AfterClass(alwaysRun = true)
|
@AfterClass(alwaysRun = true)
|
||||||
protected void tidyUp() {
|
protected void tidyUp() {
|
||||||
if (catalog != null) {
|
if (catalog != null) {
|
||||||
|
try {
|
||||||
catalogClient.deleteCatalog(catalog.getHref());
|
catalogClient.deleteCatalog(catalog.getHref());
|
||||||
try { //TODO: predicate to retry for a short while?
|
} catch (Exception e) {
|
||||||
catalogClient.getCatalog(catalog.getHref());
|
logger.warn(e, "Error deleting admin catalog '%s'", catalog.getName());
|
||||||
fail("The Catalog should have been deleted");
|
|
||||||
} catch (VCloudDirectorException vcde) {
|
|
||||||
checkError(vcde.getError());
|
|
||||||
assertEquals(vcde.getError().getMajorErrorCode(), Integer.valueOf(403), "The majorErrorCode should be 403 since the item has been deleted");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ import com.google.common.collect.ImmutableSet;
|
||||||
*
|
*
|
||||||
* @author danikov
|
* @author danikov
|
||||||
*/
|
*/
|
||||||
@Test(groups = { "unit", "admin", "network"}, singleThreaded = true, testName = "AdminNetworkClientExpectTest")
|
@Test(groups = { "unit", "admin" }, singleThreaded = true, testName = "AdminNetworkClientExpectTest")
|
||||||
public class AdminNetworkClientExpectTest extends VCloudDirectorAdminClientExpectTest {
|
public class AdminNetworkClientExpectTest extends VCloudDirectorAdminClientExpectTest {
|
||||||
|
|
||||||
Reference networkRef = Reference.builder()
|
Reference networkRef = Reference.builder()
|
||||||
|
|
|
@ -51,7 +51,7 @@ import org.testng.annotations.Test;
|
||||||
*
|
*
|
||||||
* @author danikov
|
* @author danikov
|
||||||
*/
|
*/
|
||||||
@Test(groups = { "live", "admin", "network" }, singleThreaded = true, testName = "AdminNetworkLiveTest")
|
@Test(groups = { "live", "admin" }, singleThreaded = true, testName = "AdminNetworkLiveTest")
|
||||||
public class AdminNetworkClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
public class AdminNetworkClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
||||||
|
|
||||||
public static final String NETWORK = "AdminNetwork";
|
public static final String NETWORK = "AdminNetwork";
|
||||||
|
|
|
@ -43,7 +43,7 @@ import org.testng.annotations.Test;
|
||||||
*
|
*
|
||||||
* @author danikov
|
* @author danikov
|
||||||
*/
|
*/
|
||||||
@Test(groups = { "unit", "user", "org"}, singleThreaded = true, testName = "AdminOrgClientExpectTest")
|
@Test(groups = { "unit", "user" }, singleThreaded = true, testName = "AdminOrgClientExpectTest")
|
||||||
public class AdminOrgClientExpectTest extends VCloudDirectorAdminClientExpectTest {
|
public class AdminOrgClientExpectTest extends VCloudDirectorAdminClientExpectTest {
|
||||||
|
|
||||||
private Reference orgRef = Reference.builder()
|
private Reference orgRef = Reference.builder()
|
||||||
|
|
|
@ -47,7 +47,7 @@ import com.google.common.collect.Iterables;
|
||||||
*
|
*
|
||||||
* @author danikov
|
* @author danikov
|
||||||
*/
|
*/
|
||||||
@Test(groups = { "live", "admin", "org" }, singleThreaded = true, testName = "AdminOrgClientLiveTest")
|
@Test(groups = { "live", "admin" }, singleThreaded = true, testName = "AdminOrgClientLiveTest")
|
||||||
public class AdminOrgClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
public class AdminOrgClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
||||||
|
|
||||||
public static final String ORG = "admin org";
|
public static final String ORG = "admin org";
|
||||||
|
|
|
@ -39,7 +39,7 @@ import com.google.common.collect.ImmutableMultimap;
|
||||||
*
|
*
|
||||||
* @author Aled Sage
|
* @author Aled Sage
|
||||||
*/
|
*/
|
||||||
@Test(groups = { "unit", "admin", "query" }, singleThreaded = true, testName = "AdminQueryClientExpectTest")
|
@Test(groups = { "unit", "admin" }, singleThreaded = true, testName = "AdminQueryClientExpectTest")
|
||||||
public class AdminQueryClientExpectTest extends VCloudDirectorAdminClientExpectTest {
|
public class AdminQueryClientExpectTest extends VCloudDirectorAdminClientExpectTest {
|
||||||
|
|
||||||
// TODO Write expect tests for all other admin-query operations
|
// TODO Write expect tests for all other admin-query operations
|
||||||
|
|
|
@ -40,7 +40,7 @@ import org.testng.annotations.Test;
|
||||||
*
|
*
|
||||||
* @author Aled Sage
|
* @author Aled Sage
|
||||||
*/
|
*/
|
||||||
@Test(groups = { "live", "admin", "query" }, singleThreaded = true, testName = "AdminQueryClientLiveTest")
|
@Test(groups = { "live", "admin" }, singleThreaded = true, testName = "AdminQueryClientLiveTest")
|
||||||
public class AdminQueryClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
public class AdminQueryClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -35,7 +35,7 @@ import org.testng.annotations.Test;
|
||||||
*
|
*
|
||||||
* @author danikov
|
* @author danikov
|
||||||
*/
|
*/
|
||||||
@Test(groups = { "unit", "admin", "vdc" }, singleThreaded = true, testName = "AdminVdcClientExpectTest")
|
@Test(groups = { "unit", "admin" }, singleThreaded = true, testName = "AdminVdcClientExpectTest")
|
||||||
public class AdminVdcClientExpectTest extends VCloudDirectorAdminClientExpectTest {
|
public class AdminVdcClientExpectTest extends VCloudDirectorAdminClientExpectTest {
|
||||||
|
|
||||||
private Reference vdcRef = Reference.builder()
|
private Reference vdcRef = Reference.builder()
|
||||||
|
|
|
@ -45,7 +45,7 @@ import org.testng.annotations.Test;
|
||||||
*
|
*
|
||||||
* @author danikov
|
* @author danikov
|
||||||
*/
|
*/
|
||||||
@Test(groups = { "live", "admin", "vdc" }, singleThreaded = true, testName = "AdminVdcClientLiveTest")
|
@Test(groups = { "live", "admin" }, singleThreaded = true, testName = "AdminVdcClientLiveTest")
|
||||||
public class AdminVdcClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
public class AdminVdcClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
||||||
|
|
||||||
public static final String VDC = "admin vdc";
|
public static final String VDC = "admin vdc";
|
||||||
|
@ -75,7 +75,7 @@ public class AdminVdcClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
||||||
if (metadataKey != null) {
|
if (metadataKey != null) {
|
||||||
try {
|
try {
|
||||||
Task task = metadataClient.deleteMetadataEntry(adminVdcUri, metadataKey);
|
Task task = metadataClient.deleteMetadataEntry(adminVdcUri, metadataKey);
|
||||||
assertTaskSucceeds(task);
|
taskDoneEventually(task);
|
||||||
} catch (VCloudDirectorException e) {
|
} catch (VCloudDirectorException e) {
|
||||||
logger.warn(e, "Error deleting metadata-value (perhaps it doesn't exist?); continuing...");
|
logger.warn(e, "Error deleting metadata-value (perhaps it doesn't exist?); continuing...");
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ import org.testng.annotations.Test;
|
||||||
*
|
*
|
||||||
* @author danikov
|
* @author danikov
|
||||||
*/
|
*/
|
||||||
@Test(groups = { "unit", "admin", "group"}, singleThreaded = true, testName = "GroupClientExpectTest")
|
@Test(groups = { "unit", "admin" }, singleThreaded = true, testName = "GroupClientExpectTest")
|
||||||
public class GroupClientExpectTest extends VCloudDirectorAdminClientExpectTest {
|
public class GroupClientExpectTest extends VCloudDirectorAdminClientExpectTest {
|
||||||
|
|
||||||
private Reference groupRef = Reference.builder()
|
private Reference groupRef = Reference.builder()
|
||||||
|
|
|
@ -38,7 +38,7 @@ import org.testng.annotations.Test;
|
||||||
*
|
*
|
||||||
* @author danikov
|
* @author danikov
|
||||||
*/
|
*/
|
||||||
@Test(groups = { "live", "admin", "group" }, singleThreaded = true, testName = "GroupClientLiveTest")
|
@Test(groups = { "live", "admin" }, singleThreaded = true, testName = "GroupClientLiveTest")
|
||||||
public class GroupClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
public class GroupClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
||||||
|
|
||||||
public static final String GROUP = "admin group";
|
public static final String GROUP = "admin group";
|
||||||
|
|
|
@ -37,7 +37,7 @@ import org.testng.annotations.Test;
|
||||||
*
|
*
|
||||||
* @author danikov
|
* @author danikov
|
||||||
*/
|
*/
|
||||||
@Test(groups = { "unit", "admin", "adminUser"}, singleThreaded = true, testName = "UserClientExpectTest")
|
@Test(groups = { "unit", "admin" }, singleThreaded = true, testName = "UserClientExpectTest")
|
||||||
public class UserClientExpectTest extends VCloudDirectorAdminClientExpectTest {
|
public class UserClientExpectTest extends VCloudDirectorAdminClientExpectTest {
|
||||||
|
|
||||||
private Reference orgRef = Reference.builder()
|
private Reference orgRef = Reference.builder()
|
||||||
|
|
|
@ -30,7 +30,6 @@ import static org.testng.AssertJUnit.assertFalse;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
|
||||||
import org.jclouds.rest.AuthorizationException;
|
import org.jclouds.rest.AuthorizationException;
|
||||||
import org.jclouds.vcloud.director.v1_5.VCloudDirectorException;
|
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.OrgPasswordPolicySettings;
|
import org.jclouds.vcloud.director.v1_5.domain.OrgPasswordPolicySettings;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.Reference;
|
import org.jclouds.vcloud.director.v1_5.domain.Reference;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.Role.DefaultRoles;
|
import org.jclouds.vcloud.director.v1_5.domain.Role.DefaultRoles;
|
||||||
|
@ -49,7 +48,7 @@ import com.google.common.collect.Iterables;
|
||||||
*
|
*
|
||||||
* @author danikov
|
* @author danikov
|
||||||
*/
|
*/
|
||||||
@Test(groups = { "live", "admin", "adminUser" }, singleThreaded = true, testName = "UserClientLiveTest")
|
@Test(groups = { "live", "admin" }, singleThreaded = true, testName = "UserClientLiveTest")
|
||||||
public class UserClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
public class UserClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
||||||
|
|
||||||
public static final String USER = "admin user";
|
public static final String USER = "admin user";
|
||||||
|
@ -77,8 +76,8 @@ public class UserClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
try {
|
try {
|
||||||
userClient.deleteUser(user.getHref());
|
userClient.deleteUser(user.getHref());
|
||||||
} catch (VCloudDirectorException e) {
|
} catch (Exception e) {
|
||||||
// ignore; user probably already deleted
|
logger.warn(e, "Error deleting user '%s'", user.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -90,16 +89,14 @@ public class UserClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
||||||
checkUser(newUser);
|
checkUser(newUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(description = "GET /admin/user/{id}",
|
@Test(description = "GET /admin/user/{id}", dependsOnMethods = { "testCreateUser" })
|
||||||
dependsOnMethods = { "testCreateUser" })
|
|
||||||
public void testGetUser() {
|
public void testGetUser() {
|
||||||
user = userClient.getUser(user.getHref());
|
user = userClient.getUser(user.getHref());
|
||||||
|
|
||||||
checkUser(user);
|
checkUser(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(description = "PUT /admin/user/{id}",
|
@Test(description = "PUT /admin/user/{id}", dependsOnMethods = { "testGetUser" })
|
||||||
dependsOnMethods = { "testGetUser" })
|
|
||||||
public void testUpdateUser() {
|
public void testUpdateUser() {
|
||||||
User oldUser = user.toBuilder().build();
|
User oldUser = user.toBuilder().build();
|
||||||
User newUser = user.toBuilder()
|
User newUser = user.toBuilder()
|
||||||
|
@ -181,7 +178,9 @@ public class UserClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
||||||
try {
|
try {
|
||||||
sessionClient.loginUserInOrgWithPassword(URI.create(endpoint + "/sessions"), user.getName(), orgRef.getName(), "wrongpassword!");
|
sessionClient.loginUserInOrgWithPassword(URI.create(endpoint + "/sessions"), user.getName(), orgRef.getName(), "wrongpassword!");
|
||||||
fail("Managed to login using the wrong password!");
|
fail("Managed to login using the wrong password!");
|
||||||
} catch(AuthorizationException ex) {
|
} catch (AuthorizationException e) {
|
||||||
|
} catch (Exception e) {
|
||||||
|
fail("Expected AuthorizationException", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,7 +190,9 @@ public class UserClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
||||||
try {
|
try {
|
||||||
sessionClient.loginUserInOrgWithPassword(URI.create(endpoint + "/sessions"), user.getName(), orgRef.getName(), "newPassword");
|
sessionClient.loginUserInOrgWithPassword(URI.create(endpoint + "/sessions"), user.getName(), orgRef.getName(), "newPassword");
|
||||||
fail("Managed to login to locked account!");
|
fail("Managed to login to locked account!");
|
||||||
} catch(AuthorizationException ex) {
|
} catch (AuthorizationException e) {
|
||||||
|
} catch (Exception e) {
|
||||||
|
fail("Expected AuthorizationException", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
userClient.unlockUser(user.getHref());
|
userClient.unlockUser(user.getHref());
|
||||||
|
|
|
@ -303,21 +303,31 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseVersionedServ
|
||||||
assertTrue(retryTaskSuccessLong.apply(task), String.format(TASK_COMPLETE_TIMELY, task));
|
assertTrue(retryTaskSuccessLong.apply(task), String.format(TASK_COMPLETE_TIMELY, task));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void assertTaskStatusEventually(Task task, Task.Status running, ImmutableSet<Task.Status> immutableSet) {
|
protected boolean taskStatusEventually(Task task, Task.Status running, ImmutableSet<Task.Status> immutableSet) {
|
||||||
TaskClient taskClient = context.getApi().getTaskClient();
|
TaskClient taskClient = context.getApi().getTaskClient();
|
||||||
TaskStatusEquals predicate = new TaskStatusEquals(taskClient, running, immutableSet);
|
TaskStatusEquals predicate = new TaskStatusEquals(taskClient, running, immutableSet);
|
||||||
RetryablePredicate<Task> retryablePredicate = new RetryablePredicate<Task>(predicate, TASK_TIMEOUT_SECONDS * 1000L);
|
RetryablePredicate<Task> retryablePredicate = new RetryablePredicate<Task>(predicate, TASK_TIMEOUT_SECONDS * 1000L);
|
||||||
assertTrue(retryablePredicate.apply(task), "Task must enter status "+running);
|
return retryablePredicate.apply(task);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void assertTaskDoneEventually(Task task) {
|
protected void assertTaskStatusEventually(Task task, Task.Status running, ImmutableSet<Task.Status> immutableSet) {
|
||||||
|
assertTrue(taskStatusEventually(task, running, immutableSet),
|
||||||
|
String.format("Task '%s' must reach status %s", task.getOperationName(), running));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean taskDoneEventually(Task task) {
|
||||||
TaskClient taskClient = context.getApi().getTaskClient();
|
TaskClient taskClient = context.getApi().getTaskClient();
|
||||||
TaskStatusEquals predicate = new TaskStatusEquals(
|
TaskStatusEquals predicate = new TaskStatusEquals(
|
||||||
taskClient,
|
taskClient,
|
||||||
ImmutableSet.of(Task.Status.ABORTED, Task.Status.CANCELED, Task.Status.ERROR, Task.Status.SUCCESS),
|
ImmutableSet.of(Task.Status.ABORTED, Task.Status.CANCELED, Task.Status.ERROR, Task.Status.SUCCESS),
|
||||||
Collections.<Task.Status>emptySet());
|
Collections.<Task.Status>emptySet());
|
||||||
RetryablePredicate<Task> retryablePredicate = new RetryablePredicate<Task>(predicate, LONG_TASK_TIMEOUT_SECONDS * 1000L);
|
RetryablePredicate<Task> retryablePredicate = new RetryablePredicate<Task>(predicate, LONG_TASK_TIMEOUT_SECONDS * 1000L);
|
||||||
assertTrue(retryablePredicate.apply(task), "Task must be done");
|
return retryablePredicate.apply(task);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void assertTaskDoneEventually(Task task) {
|
||||||
|
assertTrue(taskDoneEventually(task),
|
||||||
|
String.format("Task '%s' must complete", task.getOperationName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -407,9 +417,12 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseVersionedServ
|
||||||
|
|
||||||
protected void cleanUpVAppTemplate(VAppTemplate vAppTemplate) {
|
protected void cleanUpVAppTemplate(VAppTemplate vAppTemplate) {
|
||||||
VAppTemplateClient vappTemplateClient = context.getApi().getVAppTemplateClient();
|
VAppTemplateClient vappTemplateClient = context.getApi().getVAppTemplateClient();
|
||||||
|
try {
|
||||||
Task task = vappTemplateClient.deleteVappTemplate(vAppTemplate.getHref());
|
Task task = vappTemplateClient.deleteVappTemplate(vAppTemplate.getHref());
|
||||||
assertTaskSucceeds(task);
|
taskDoneEventually(task);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.warn(e, "Error deleting template '%s'", vAppTemplate.getName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void cleanUpVApp(VApp vApp) {
|
protected void cleanUpVApp(VApp vApp) {
|
||||||
|
@ -434,7 +447,9 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseVersionedServ
|
||||||
// Otherwise, get error on delete "entity is busy completing an operation.
|
// Otherwise, get error on delete "entity is busy completing an operation.
|
||||||
if (vApp.getTasks() != null) {
|
if (vApp.getTasks() != null) {
|
||||||
for (Task task : vApp.getTasks()) {
|
for (Task task : vApp.getTasks()) {
|
||||||
assertTaskDoneEventually(task);
|
if (!taskDoneEventually(task)) {
|
||||||
|
logger.warn("Task '%s' did not complete", task.getOperationName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -442,7 +457,7 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseVersionedServ
|
||||||
if (vApp.getStatus().equals(Status.POWERED_ON.getValue())) {
|
if (vApp.getStatus().equals(Status.POWERED_ON.getValue())) {
|
||||||
try {
|
try {
|
||||||
Task shutdownTask = vAppClient.shutdown(vAppURI);
|
Task shutdownTask = vAppClient.shutdown(vAppURI);
|
||||||
retryTaskSuccess.apply(shutdownTask);
|
taskDoneEventually(shutdownTask);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// keep going; cleanup as much as possible
|
// keep going; cleanup as much as possible
|
||||||
logger.warn(e, "Continuing cleanup after error shutting down VApp %s", vApp.getName());
|
logger.warn(e, "Continuing cleanup after error shutting down VApp %s", vApp.getName());
|
||||||
|
@ -454,7 +469,7 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseVersionedServ
|
||||||
try {
|
try {
|
||||||
UndeployVAppParams params = UndeployVAppParams.builder().build();
|
UndeployVAppParams params = UndeployVAppParams.builder().build();
|
||||||
Task undeployTask = vAppClient.undeploy(vAppURI, params);
|
Task undeployTask = vAppClient.undeploy(vAppURI, params);
|
||||||
retryTaskSuccess.apply(undeployTask);
|
taskDoneEventually(undeployTask);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// keep going; cleanup as much as possible
|
// keep going; cleanup as much as possible
|
||||||
logger.warn(e, "Continuing cleanup after error undeploying VApp %s", vApp.getName());
|
logger.warn(e, "Continuing cleanup after error undeploying VApp %s", vApp.getName());
|
||||||
|
@ -463,7 +478,7 @@ public abstract class BaseVCloudDirectorClientLiveTest extends BaseVersionedServ
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Task task = vAppClient.deleteVApp(vAppURI);
|
Task task = vAppClient.deleteVApp(vAppURI);
|
||||||
assertTaskSucceeds(task);
|
taskDoneEventually(task);
|
||||||
vAppNames.remove(vApp.getName());
|
vAppNames.remove(vApp.getName());
|
||||||
logger.info("Deleted VApp %s", vApp.getName());
|
logger.info("Deleted VApp %s", vApp.getName());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
|
@ -40,7 +40,7 @@ import com.google.common.collect.ImmutableMultimap;
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = "unit", testName = "SessionClientExpectTest")
|
@Test(groups = { "unit", "user" }, testName = "SessionClientExpectTest")
|
||||||
// only needed as SessionClient is not registered in rest.properties
|
// only needed as SessionClient is not registered in rest.properties
|
||||||
@RegisterContext(sync = SessionClient.class, async = SessionAsyncClient.class)
|
@RegisterContext(sync = SessionClient.class, async = SessionAsyncClient.class)
|
||||||
public class SessionClientExpectTest extends BaseRestClientExpectTest<SessionClient> {
|
public class SessionClientExpectTest extends BaseRestClientExpectTest<SessionClient> {
|
||||||
|
|
|
@ -48,7 +48,7 @@ import com.google.inject.Module;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Listeners(FormatApiResultsListener.class)
|
@Listeners(FormatApiResultsListener.class)
|
||||||
@Test(groups = { "live", "user", "login" }, testName = "SessionClientLiveTest")
|
@Test(groups = { "live", "user" }, testName = "SessionClientLiveTest")
|
||||||
public class SessionClientLiveTest extends BaseVersionedServiceLiveTest {
|
public class SessionClientLiveTest extends BaseVersionedServiceLiveTest {
|
||||||
public SessionClientLiveTest() {
|
public SessionClientLiveTest() {
|
||||||
provider = "vcloud-director";
|
provider = "vcloud-director";
|
||||||
|
@ -73,7 +73,7 @@ public class SessionClientLiveTest extends BaseVersionedServiceLiveTest {
|
||||||
private SessionClient client;
|
private SessionClient client;
|
||||||
private SessionWithToken sessionWithToken;
|
private SessionWithToken sessionWithToken;
|
||||||
|
|
||||||
@Test(testName = "POST /sessions")
|
@Test(description = "POST /sessions")
|
||||||
public void testLogin() {
|
public void testLogin() {
|
||||||
String user = identity.substring(0, identity.lastIndexOf('@'));
|
String user = identity.substring(0, identity.lastIndexOf('@'));
|
||||||
String org = identity.substring(identity.lastIndexOf('@') + 1);
|
String org = identity.substring(identity.lastIndexOf('@') + 1);
|
||||||
|
@ -86,13 +86,13 @@ public class SessionClientLiveTest extends BaseVersionedServiceLiveTest {
|
||||||
assertNotNull(sessionWithToken.getToken());
|
assertNotNull(sessionWithToken.getToken());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(testName = "GET /session", dependsOnMethods = "testLogin")
|
@Test(description = "GET /session", dependsOnMethods = "testLogin")
|
||||||
public void testGetSession() {
|
public void testGetSession() {
|
||||||
assertEquals(client.getSessionWithToken(sessionWithToken.getSession().getHref(), sessionWithToken.getToken()),
|
assertEquals(client.getSessionWithToken(sessionWithToken.getSession().getHref(), sessionWithToken.getToken()),
|
||||||
sessionWithToken.getSession());
|
sessionWithToken.getSession());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(testName = "DELETE /session", dependsOnMethods = "testGetSession")
|
@Test(description = "DELETE /session", dependsOnMethods = "testGetSession")
|
||||||
public void testLogout() {
|
public void testLogout() {
|
||||||
client.logoutSessionWithToken(sessionWithToken.getSession().getHref(), sessionWithToken.getToken());
|
client.logoutSessionWithToken(sessionWithToken.getSession().getHref(), sessionWithToken.getToken());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue