Search in sources :

Example 1 with TestRequestSender

use of com.vmware.xenon.common.test.TestRequestSender in project photon-model by vmware.

the class TestVSphereComputeDiskDay2Service method sendRequest.

private void sendRequest(ResourceOperationRequest request, DiskService.DiskType diskType, VerificationHost.WaitHandler handler) {
    Operation attachDiskOp = Operation.createPatch(UriUtils.buildUri(this.host, VSphereComputeDiskManagementService.SELF_LINK)).setBody(request).setReferer(this.host.getReferer());
    TestRequestSender sender = new TestRequestSender(this.host);
    sender.sendRequest(attachDiskOp);
    this.host.log(String.format("Waiting for %s disk attach to complete", diskType.name()));
    this.host.waitFor(String.format("%s %s disk failed.", request.operation, diskType.name()), handler);
}
Also used : TestRequestSender(com.vmware.xenon.common.test.TestRequestSender) Operation(com.vmware.xenon.common.Operation) ResourceOperation(com.vmware.photon.controller.model.adapters.registry.operations.ResourceOperation)

Example 2 with TestRequestSender

use of com.vmware.xenon.common.test.TestRequestSender in project photon-model by vmware.

the class AWSVolumeTypeDiscoveryServiceTest method testVolumeTypeDiscovery.

@Test
public void testVolumeTypeDiscovery() {
    Operation get = Operation.createGet(this.host, AWSVolumeTypeDiscoveryService.SELF_LINK + "?deviceType=ebs");
    get = new TestRequestSender(this.host).sendAndWait(get);
    VolumeTypeList volumes = get.getBody(AWSVolumeTypeDiscoveryService.VolumeTypeList.class);
    Assert.assertEquals("The expected number of supported ebs volumes are not matching " + "the actual number volumes from the discovery service", 5, volumes.volumeTypes.size());
}
Also used : VolumeTypeList(com.vmware.photon.controller.model.adapters.awsadapter.enumeration.AWSVolumeTypeDiscoveryService.VolumeTypeList) TestRequestSender(com.vmware.xenon.common.test.TestRequestSender) Operation(com.vmware.xenon.common.Operation) Test(org.junit.Test)

Example 3 with TestRequestSender

use of com.vmware.xenon.common.test.TestRequestSender in project photon-model by vmware.

the class AzureSubscriptionsEnumerationServiceTest method createAzureCostComputesForSubscriptions.

private void createAzureCostComputesForSubscriptions(Collection<AzureSubscription> subscriptions) {
    AzureSubscriptionsEnumerationRequest request = getAzureCostComputeEnumRequestForSubscriptions(subscriptions);
    TestRequestSender sender = new TestRequestSender(this.host);
    Operation op = Operation.createPatch(this.host, AzureSubscriptionsEnumerationService.SELF_LINK).setBody(request);
    sender.sendAndWait(op);
}
Also used : TestRequestSender(com.vmware.xenon.common.test.TestRequestSender) Operation(com.vmware.xenon.common.Operation) AzureSubscriptionsEnumerationRequest(com.vmware.photon.controller.model.adapters.azure.ea.enumeration.AzureSubscriptionsEnumerationService.AzureSubscriptionsEnumerationRequest)

Example 4 with TestRequestSender

use of com.vmware.xenon.common.test.TestRequestSender in project photon-model by vmware.

the class AzureSubscriptionEndpointsEnumerationServiceTest method createAzureEndpointsForSubscriptions.

private void createAzureEndpointsForSubscriptions(Collection<AzureSubscription> subscriptions) {
    AzureSubscriptionEndpointsEnumerationRequest request = new AzureSubscriptionEndpointsEnumerationRequest();
    request.resourceReference = UriUtils.buildUri(this.host, this.computeLink);
    request.azureSubscriptions = subscriptions;
    TestRequestSender sender = new TestRequestSender(this.host);
    Operation op = Operation.createPatch(this.host, AzureSubscriptionEndpointsEnumerationService.SELF_LINK).setBody(request);
    sender.sendAndWait(op);
}
Also used : AzureSubscriptionEndpointsEnumerationRequest(com.vmware.photon.controller.model.adapters.azure.ea.enumeration.AzureSubscriptionEndpointsEnumerationService.AzureSubscriptionEndpointsEnumerationRequest) TestRequestSender(com.vmware.xenon.common.test.TestRequestSender) Operation(com.vmware.xenon.common.Operation)

Example 5 with TestRequestSender

use of com.vmware.xenon.common.test.TestRequestSender in project photon-model by vmware.

the class BaseVSphereAdapterTest method deleteSnapshotAndWait.

protected void deleteSnapshotAndWait(ComputeState computeState) throws Throwable {
    // Get the snapshot associated with the compute
    SnapshotState snapshotState = querySnapshotState(computeState.documentSelfLink, true);
    String taskLink = UUID.randomUUID().toString();
    ResourceOperationRequest snapshotRequest = getDeleteOrRevertSnapshotRequest(ResourceOperation.DELETE_SNAPSHOT.operation, "DELETE", computeState.documentSelfLink, snapshotState.documentSelfLink, taskLink);
    Operation deleteSnapshotOp = Operation.createPatch(UriUtils.buildUri(this.host, VSphereAdapterSnapshotService.SELF_LINK)).setBody(snapshotRequest).setReferer(this.host.getReferer()).setCompletion((o, e) -> Assert.assertNull(e));
    TestRequestSender sender = new TestRequestSender(this.host);
    sender.sendRequest(deleteSnapshotOp);
    this.host.log("Waiting for the snapshot to be deleted");
    this.host.waitFor("Delete snapshot request failed", () -> {
        SnapshotState finalSnapshotState = querySnapshotState(computeState.documentSelfLink, true);
        ComputeState finalComputeState = this.host.getServiceState(null, ComputeState.class, UriUtils.buildUri(this.host, computeState.documentSelfLink));
        String hasSnapshot = finalComputeState.customProperties.get(ComputeProperties.CUSTOM_PROP_COMPUTE_HAS_SNAPSHOTS);
        // snapshot. So hasSnapshot will still be true.
        if (hasSnapshot != null && Boolean.parseBoolean(hasSnapshot) && finalSnapshotState == null) {
            return true;
        } else {
            return false;
        }
    });
    this.host.log("Delete snapshot operation completed successfully");
}
Also used : ComputeState(com.vmware.photon.controller.model.resources.ComputeService.ComputeState) SnapshotState(com.vmware.photon.controller.model.resources.SnapshotService.SnapshotState) TestRequestSender(com.vmware.xenon.common.test.TestRequestSender) ResourceOperationRequest(com.vmware.photon.controller.model.adapters.registry.operations.ResourceOperationRequest) ResourceOperation(com.vmware.photon.controller.model.adapters.registry.operations.ResourceOperation) Operation(com.vmware.xenon.common.Operation)

Aggregations

Operation (com.vmware.xenon.common.Operation)15 TestRequestSender (com.vmware.xenon.common.test.TestRequestSender)15 ResourceOperation (com.vmware.photon.controller.model.adapters.registry.operations.ResourceOperation)10 ResourceOperationRequest (com.vmware.photon.controller.model.adapters.registry.operations.ResourceOperationRequest)7 ComputeState (com.vmware.photon.controller.model.resources.ComputeService.ComputeState)6 SnapshotState (com.vmware.photon.controller.model.resources.SnapshotService.SnapshotState)5 ArrayList (java.util.ArrayList)3 Test (org.junit.Test)3 QueryResultsProcessor (com.vmware.xenon.common.QueryResultsProcessor)2 QueryTask (com.vmware.xenon.services.common.QueryTask)2 Query (com.vmware.xenon.services.common.QueryTask.Query)2 VolumeTypeList (com.vmware.photon.controller.model.adapters.awsadapter.enumeration.AWSVolumeTypeDiscoveryService.VolumeTypeList)1 AzureSubscriptionEndpointCreationRequest (com.vmware.photon.controller.model.adapters.azure.ea.enumeration.AzureSubscriptionEndpointCreationService.AzureSubscriptionEndpointCreationRequest)1 AzureSubscriptionEndpointsEnumerationRequest (com.vmware.photon.controller.model.adapters.azure.ea.enumeration.AzureSubscriptionEndpointsEnumerationService.AzureSubscriptionEndpointsEnumerationRequest)1 AzureSubscriptionsEnumerationRequest (com.vmware.photon.controller.model.adapters.azure.ea.enumeration.AzureSubscriptionsEnumerationService.AzureSubscriptionsEnumerationRequest)1 ResourceOperationSpec (com.vmware.photon.controller.model.adapters.registry.operations.ResourceOperationSpecService.ResourceOperationSpec)1 ComputeService (com.vmware.photon.controller.model.resources.ComputeService)1 EndpointState (com.vmware.photon.controller.model.resources.EndpointService.EndpointState)1 ProvisionDiskTaskService (com.vmware.photon.controller.model.tasks.ProvisionDiskTaskService)1