mirror of https://github.com/apache/jclouds.git
Issue #830: more VAppTemplate live test fixes
This commit is contained in:
parent
fad4cee803
commit
1b5aa81f00
|
@ -119,11 +119,10 @@ public interface VAppTemplateAsyncClient {
|
||||||
* @see VAppTemplateClient#disableDownloadVappTemplate(URI)
|
* @see VAppTemplateClient#disableDownloadVappTemplate(URI)
|
||||||
*/
|
*/
|
||||||
@POST
|
@POST
|
||||||
@Consumes(TASK)
|
|
||||||
@Path("/action/disableDownload")
|
@Path("/action/disableDownload")
|
||||||
@JAXBResponseParser
|
@JAXBResponseParser
|
||||||
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
|
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
|
||||||
ListenableFuture<Task> disableDownloadVappTemplate(@EndpointParam URI templateURI);
|
ListenableFuture<Void> disableDownloadVappTemplate(@EndpointParam URI templateURI);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see VAppTemplateClient#enableDownloadVappTemplate(URI)
|
* @see VAppTemplateClient#enableDownloadVappTemplate(URI)
|
||||||
|
|
|
@ -85,7 +85,7 @@ public interface VAppTemplateClient {
|
||||||
* @param templateUri the URI of the template
|
* @param templateUri the URI of the template
|
||||||
* @return the task performing the action
|
* @return the task performing the action
|
||||||
*/
|
*/
|
||||||
Task disableDownloadVappTemplate(URI templateUri);
|
void disableDownloadVappTemplate(URI templateUri);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enables downloading of the ovf of a vApp template.
|
* Enables downloading of the ovf of a vApp template.
|
||||||
|
|
|
@ -174,13 +174,12 @@ public class VAppTemplateClientExpectTest extends BaseVCloudDirectorRestClientEx
|
||||||
URI uri = URI.create(endpoint + templateId);
|
URI uri = URI.create(endpoint + templateId);
|
||||||
|
|
||||||
VAppTemplateClient client = requestsSendResponses(loginRequest, sessionResponse,
|
VAppTemplateClient client = requestsSendResponses(loginRequest, sessionResponse,
|
||||||
new VcloudHttpRequestPrimer().apiCommand("POST", templateId + "/action/disableDownload").acceptMedia(TASK).httpRequestBuilder().build(),
|
new VcloudHttpRequestPrimer().apiCommand("POST", templateId + "/action/disableDownload").httpRequestBuilder().build(),
|
||||||
new VcloudHttpResponsePrimer().xmlFilePayload("/task/task.xml", TASK).httpResponseBuilder().build()
|
new VcloudHttpResponsePrimer().httpResponseBuilder().build()
|
||||||
).getVAppTemplateClient();
|
).getVAppTemplateClient();
|
||||||
|
|
||||||
assertNotNull(client);
|
assertNotNull(client);
|
||||||
Task task = client.disableDownloadVappTemplate(uri);
|
client.disableDownloadVappTemplate(uri);
|
||||||
assertNotNull(task);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expectedExceptions = VCloudDirectorException.class)
|
@Test(expectedExceptions = VCloudDirectorException.class)
|
||||||
|
@ -189,7 +188,7 @@ public class VAppTemplateClientExpectTest extends BaseVCloudDirectorRestClientEx
|
||||||
URI uri = URI.create(endpoint + templateId);
|
URI uri = URI.create(endpoint + templateId);
|
||||||
|
|
||||||
VAppTemplateClient client = orderedRequestsSendResponses(loginRequest, sessionResponse,
|
VAppTemplateClient client = orderedRequestsSendResponses(loginRequest, sessionResponse,
|
||||||
new VcloudHttpRequestPrimer().apiCommand("POST", templateId + "/action/disableDownload").acceptMedia(TASK).httpRequestBuilder().build(),
|
new VcloudHttpRequestPrimer().apiCommand("POST", templateId + "/action/disableDownload").httpRequestBuilder().build(),
|
||||||
new VcloudHttpResponsePrimer().xmlFilePayload("/vapptemplate/error400.xml", ERROR).httpResponseBuilder().statusCode(400).build()).getVAppTemplateClient();
|
new VcloudHttpResponsePrimer().xmlFilePayload("/vapptemplate/error400.xml", ERROR).httpResponseBuilder().statusCode(400).build()).getVAppTemplateClient();
|
||||||
|
|
||||||
client.disableDownloadVappTemplate(uri);
|
client.disableDownloadVappTemplate(uri);
|
||||||
|
|
|
@ -20,6 +20,8 @@ package org.jclouds.vcloud.director.v1_5.features;
|
||||||
|
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
import static org.testng.Assert.assertFalse;
|
import static org.testng.Assert.assertFalse;
|
||||||
|
import static org.testng.Assert.assertTrue;
|
||||||
|
import static org.testng.Assert.fail;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -31,6 +33,7 @@ import org.jclouds.vcloud.director.v1_5.domain.Checks;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.CustomizationSection;
|
import org.jclouds.vcloud.director.v1_5.domain.CustomizationSection;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.GuestCustomizationSection;
|
import org.jclouds.vcloud.director.v1_5.domain.GuestCustomizationSection;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.LeaseSettingsSection;
|
import org.jclouds.vcloud.director.v1_5.domain.LeaseSettingsSection;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.domain.Link;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.Metadata;
|
import org.jclouds.vcloud.director.v1_5.domain.Metadata;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.MetadataEntry;
|
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;
|
||||||
|
@ -316,6 +319,7 @@ public class VAppTemplateClientLiveTest extends BaseVCloudDirectorClientLiveTest
|
||||||
.build();
|
.build();
|
||||||
Set<VAppNetworkConfiguration> vappNetworkConfigurations = ImmutableSet.of(vappNetworkConfiguration);
|
Set<VAppNetworkConfiguration> vappNetworkConfigurations = ImmutableSet.of(vappNetworkConfiguration);
|
||||||
NetworkConfigSection networkConfigSection = NetworkConfigSection.builder()
|
NetworkConfigSection networkConfigSection = NetworkConfigSection.builder()
|
||||||
|
.info("my info")
|
||||||
.networkConfigs(vappNetworkConfigurations)
|
.networkConfigs(vappNetworkConfigurations)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
@ -363,16 +367,34 @@ public class VAppTemplateClientLiveTest extends BaseVCloudDirectorClientLiveTest
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDisableVAppTemplateDownload() throws Exception {
|
public void testDisableVAppTemplateDownload() throws Exception {
|
||||||
// TODO Need assertion that command had effect
|
vappTemplateClient.disableDownloadVappTemplate(vAppTemplateURI);
|
||||||
final Task task = vappTemplateClient.disableDownloadVappTemplate(vAppTemplateURI);
|
|
||||||
retryTaskSuccess.apply(task);
|
// Assert that "download" link is now not offered
|
||||||
|
VAppTemplate vAppTemplate = vappTemplateClient.getVAppTemplate(vAppTemplateURI);
|
||||||
|
Set<Link> links = vAppTemplate.getLinks();
|
||||||
|
assertFalse(hasLinkMatchingRel(links, "download.*"), "Should not offer download link after disabling download: "+vAppTemplate);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEnableVAppTemplateDownload() throws Exception {
|
public void testEnableVAppTemplateDownload() throws Exception {
|
||||||
// TODO Need assertion that command had effect
|
// First disable so that enable really has some work to do...
|
||||||
|
vappTemplateClient.disableDownloadVappTemplate(vAppTemplateURI);
|
||||||
final Task task = vappTemplateClient.enableDownloadVappTemplate(vAppTemplateURI);
|
final Task task = vappTemplateClient.enableDownloadVappTemplate(vAppTemplateURI);
|
||||||
retryTaskSuccess.apply(task);
|
retryTaskSuccess.apply(task);
|
||||||
|
|
||||||
|
// Assert that "download" link is now offered
|
||||||
|
VAppTemplate vAppTemplate = vappTemplateClient.getVAppTemplate(vAppTemplateURI);
|
||||||
|
Set<Link> links = vAppTemplate.getLinks();
|
||||||
|
assertTrue(hasLinkMatchingRel(links, "download.*"), "Should offer download link after enabling download: "+vAppTemplate);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean hasLinkMatchingRel(Set<Link> links, String regex) {
|
||||||
|
for (Link link : links) {
|
||||||
|
if (link.getRel() != null && link.getRel().matches(regex)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -393,4 +415,26 @@ public class VAppTemplateClientLiveTest extends BaseVCloudDirectorClientLiveTest
|
||||||
final Task task = vappTemplateClient.relocateVappTemplate(vAppTemplateURI, relocateParams);
|
final Task task = vappTemplateClient.relocateVappTemplate(vAppTemplateURI, relocateParams);
|
||||||
retryTaskSuccess.apply(task);
|
retryTaskSuccess.apply(task);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCompletedTaskNotIncludedInVAppTemplate() throws Exception {
|
||||||
|
// Kick off a task, and wait for it to complete
|
||||||
|
vappTemplateClient.disableDownloadVappTemplate(vAppTemplateURI);
|
||||||
|
final Task task = vappTemplateClient.enableDownloadVappTemplate(vAppTemplateURI);
|
||||||
|
retryTaskSuccess.apply(task);
|
||||||
|
|
||||||
|
// Ask the VAppTemplate for its tasks, and the status of the matching task if it exists
|
||||||
|
VAppTemplate vAppTemplate = vappTemplateClient.getVAppTemplate(vAppTemplateURI);
|
||||||
|
Set<Task> tasks = vAppTemplate.getTasks();
|
||||||
|
if (tasks != null) {
|
||||||
|
for (Task contender : tasks) {
|
||||||
|
if (task.getId().equals(contender.getId())) {
|
||||||
|
String status = contender.getStatus();
|
||||||
|
if (status.equals(Task.Status.QUEUED) || status.equals(Task.Status.PRE_RUNNING) || status.equals(Task.Status.RUNNING)) {
|
||||||
|
fail("Task "+contender+" reported complete, but is included in VAppTemplate in status "+status);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue