Search in sources :

Example 6 with ResourceEnumerationTaskState

use of com.vmware.photon.controller.model.tasks.ResourceEnumerationTaskService.ResourceEnumerationTaskState in project photon-model by vmware.

the class GCPTestUtil method enumerateResources.

/**
 * Method to run enumeration on GCP endpoint.
 * @param host The test service host.
 * @param peerURI The peer uri.
 * @param enumTask The enumeration task to run.
 * @param testCase The test case name.
 * @throws Throwable Exception when running enumeration tasks.
 */
public static void enumerateResources(VerificationHost host, URI peerURI, ResourceEnumerationTaskState enumTask, String testCase) throws Throwable {
    // Perform resource enumeration on the GCP end point.
    // Pass the references to the GCP compute host.
    host.log("Performing resource enumeration");
    ResourceEnumerationTaskState enumTaskState = performResourceEnumeration(host, peerURI, enumTask);
    // Wait for the enumeration task to be completed.
    host.waitForFinishedTask(ResourceEnumerationTaskState.class, createServiceURI(host, peerURI, enumTaskState.documentSelfLink));
    host.log("\n==%s==Total Time Spent in Enumeration==\n", testCase + getVMCount(host, peerURI));
    ServiceStats enumerationStats = host.getServiceState(null, ServiceStats.class, UriUtils.buildStatsUri(createServiceURI(host, peerURI, GCPEnumerationAdapterService.SELF_LINK)));
    host.log(Utils.toJsonHtml(enumerationStats));
}
Also used : ResourceEnumerationTaskState(com.vmware.photon.controller.model.tasks.ResourceEnumerationTaskService.ResourceEnumerationTaskState) ServiceStats(com.vmware.xenon.common.ServiceStats)

Example 7 with ResourceEnumerationTaskState

use of com.vmware.photon.controller.model.tasks.ResourceEnumerationTaskService.ResourceEnumerationTaskState in project photon-model by vmware.

the class TestGCPEnumerationTask method runEnumeration.

/**
 * Run the enumeration and wait until it ends.
 * @throws Throwable Exception during running and waiting enumeration.
 */
private void runEnumeration() throws Throwable {
    ResourceEnumerationTaskState enumTask = createResourceEnumerationTask(this.outPool.documentSelfLink, this.computeHost.documentSelfLink, GCPEnumerationAdapterService.SELF_LINK, this.isMock, this.computeHost.tenantLinks);
    ResourceEnumerationTaskState enumTaskState = performResourceEnumeration(this.host, null, enumTask);
    this.host.waitForFinishedTask(ResourceEnumerationTaskState.class, enumTaskState.documentSelfLink);
}
Also used : ResourceEnumerationTaskState(com.vmware.photon.controller.model.tasks.ResourceEnumerationTaskService.ResourceEnumerationTaskState)

Example 8 with ResourceEnumerationTaskState

use of com.vmware.photon.controller.model.tasks.ResourceEnumerationTaskService.ResourceEnumerationTaskState in project photon-model by vmware.

the class TestGCPEnumerationAtScale method testEnumerationAtScale.

@Test
public void testEnumerationAtScale() throws Throwable {
    if (!this.isMock) {
        int baseLineInstancesNumber = getInstanceNumber(this.compute, this.projectID, this.zoneID);
        // Check input here.
        if (baseLineInstancesNumber >= this.gcpAccountLimit) {
            this.host.log("The number of existing instances is already larger than or equal to" + "the account limit.");
            return;
        }
        if (this.modifyRate > 100) {
            this.host.log("The modify Rate cannot be over 100 percent");
            return;
        }
        // Gets names of stale instances remaining on GCP due to read time out failures
        this.staleInstanceNames = getStaleInstanceNames(this.compute, this.projectID, this.zoneID);
        ResourceEnumerationTaskState enumTask = createResourceEnumerationTask(this.outPool.documentSelfLink, this.computeHost.documentSelfLink, GCPEnumerationAdapterService.SELF_LINK, this.isMock, this.computeHost.tenantLinks);
        enumerateResources(this.host, null, enumTask, TEST_CASE_BASELINE_VMS);
        if (this.instanceCountAtScale + baseLineInstancesNumber > this.gcpAccountLimit) {
            this.host.log("Requested number of resources will exceed account limit. Reducing" + " number of requested instances");
            this.instanceCountAtScale = this.gcpAccountLimit - baseLineInstancesNumber;
        }
        // Create {instanceCountAtScale} VMs on AWS
        this.host.log("Running scale test by provisioning %d instances", this.instanceCountAtScale);
        this.instancesToCleanUp = provisionInstances(this.host, this.compute, this.userEmail, this.projectID, this.zoneID, this.instanceCountAtScale, this.batchSize, this.waitIntervalInMillisecond);
        // Record the time taken to discover creates of the instances.
        enumerateResources(this.host, null, enumTask, TEST_CASE_INITIAL_RUN_AT_SCALE);
        // UPDATE some percent of the spawned instances to have a tag
        int numberOfInstances = (int) ((this.instanceCountAtScale / HUNDRED) * this.modifyRate);
        this.host.log("Stopping %d instances", numberOfInstances);
        List<String> instanceNames = this.instancesToCleanUp.subList(0, numberOfInstances);
        this.instancesToCleanUp = this.instancesToCleanUp.subList(numberOfInstances, this.instancesToCleanUp.size());
        stopInstances(this.host, this.compute, this.projectID, this.zoneID, instanceNames, this.batchSize, this.waitIntervalInMillisecond);
        // Record the time taken to discover updates to a subset of the instances.
        enumerateResources(this.host, null, enumTask, TEST_CASE_DISCOVER_UPDATES_AT_SCALE);
        // DELETE some percent of the instances
        this.host.log("Deleting %d instances", numberOfInstances);
        List<String> instancesLeft = deleteInstances(this.host, this.compute, this.projectID, this.zoneID, instanceNames, this.batchSize, this.waitIntervalInMillisecond);
        this.instancesToCleanUp.addAll(instancesLeft);
        // Record time spent in enumeration to discover the deleted instances and delete them.
        enumerateResources(this.host, null, enumTask, TEST_CASE_DISCOVER_DELETES_AT_SCALE);
        // Deleting stale instances from failed test runs.
        if (this.staleInstanceNames != null) {
            host.log(Level.INFO, "Deleting " + this.staleInstanceNames.size() + " stale instances from previous test runs...");
            this.instancesToCleanUp.addAll(this.staleInstanceNames);
        }
    }
}
Also used : ResourceEnumerationTaskState(com.vmware.photon.controller.model.tasks.ResourceEnumerationTaskService.ResourceEnumerationTaskState) Test(org.junit.Test)

Example 9 with ResourceEnumerationTaskState

use of com.vmware.photon.controller.model.tasks.ResourceEnumerationTaskService.ResourceEnumerationTaskState in project photon-model by vmware.

the class TestAWSSetupUtils method performResourceEnumeration.

/**
 * Method to perform compute resource enumeration on the AWS endpoint.
 *
 * @param resourcePoolLink
 *            The link to the AWS resource pool.
 * @param computeDescriptionLink
 *            The link to the compute description for the AWS host.
 * @param parentComputeLink
 *            The compute state associated with the AWS host.
 * @return
 * @throws Throwable
 */
public static ResourceEnumerationTaskState performResourceEnumeration(VerificationHost host, ComputeState computeHost, EndpointState endpointState, URI peerURI, EnumSet<TaskOption> options) throws Throwable {
    // Kick of a Resource Enumeration task to enumerate the instances on the AWS endpoint
    ResourceEnumerationTaskState enumerationTaskState = new ResourceEnumerationTaskState();
    enumerationTaskState.parentComputeLink = computeHost.documentSelfLink;
    enumerationTaskState.enumerationAction = EnumerationAction.START;
    enumerationTaskState.adapterManagementReference = UriUtils.buildUri(AWSEnumerationAdapterService.SELF_LINK);
    enumerationTaskState.resourcePoolLink = computeHost.resourcePoolLink;
    if (options != null) {
        enumerationTaskState.options = options;
    } else {
        enumerationTaskState.options = EnumSet.noneOf(TaskOption.class);
    }
    enumerationTaskState.tenantLinks = endpointState.tenantLinks;
    enumerationTaskState.endpointLink = endpointState.documentSelfLink;
    URI uri = createServiceURI(host, peerURI, ResourceEnumerationTaskService.FACTORY_LINK);
    return TestUtils.doPost(host, enumerationTaskState, ResourceEnumerationTaskState.class, uri);
}
Also used : ResourceEnumerationTaskState(com.vmware.photon.controller.model.tasks.ResourceEnumerationTaskService.ResourceEnumerationTaskState) TaskOption(com.vmware.photon.controller.model.tasks.TaskOption) URI(java.net.URI) ProvisioningUtils.createServiceURI(com.vmware.photon.controller.model.tasks.ProvisioningUtils.createServiceURI)

Example 10 with ResourceEnumerationTaskState

use of com.vmware.photon.controller.model.tasks.ResourceEnumerationTaskService.ResourceEnumerationTaskState in project photon-model by vmware.

the class TestUtils method createResourceEnumerationTask.

/**
 * Create a resource enumeration task.
 * @param resourcePoolLink Link to the resource pool that hosts all resources.
 * @param parentComputeLink Link to the compute host.
 * @param adapterServiceLink Link to the enumeration adapter service.
 * @param isMock If request is mock.
 * @param tenantLinks Links to the tenants.
 * @return The created resource enumeration task.
 */
public static ResourceEnumerationTaskState createResourceEnumerationTask(String resourcePoolLink, String parentComputeLink, String adapterServiceLink, boolean isMock, List<String> tenantLinks) {
    ResourceEnumerationTaskState enumerationTaskState = new ResourceEnumerationTaskState();
    enumerationTaskState.parentComputeLink = parentComputeLink;
    enumerationTaskState.enumerationAction = EnumerationAction.START;
    enumerationTaskState.adapterManagementReference = UriUtils.buildUri(adapterServiceLink);
    enumerationTaskState.resourcePoolLink = resourcePoolLink;
    if (isMock) {
        enumerationTaskState.options = EnumSet.of(TaskOption.IS_MOCK);
    }
    if (tenantLinks != null) {
        enumerationTaskState.tenantLinks = tenantLinks;
    }
    return enumerationTaskState;
}
Also used : ResourceEnumerationTaskState(com.vmware.photon.controller.model.tasks.ResourceEnumerationTaskService.ResourceEnumerationTaskState)

Aggregations

ResourceEnumerationTaskState (com.vmware.photon.controller.model.tasks.ResourceEnumerationTaskService.ResourceEnumerationTaskState)10 ENDPOINT_LINK_PROP_NAME (com.vmware.photon.controller.model.ComputeProperties.ENDPOINT_LINK_PROP_NAME)1 UriPaths (com.vmware.photon.controller.model.UriPaths)1 AdapterTypePath (com.vmware.photon.controller.model.UriPaths.AdapterTypePath)1 EndpointConfigRequest (com.vmware.photon.controller.model.adapterapi.EndpointConfigRequest)1 RequestType (com.vmware.photon.controller.model.adapterapi.EndpointConfigRequest.RequestType)1 PhotonModelAdaptersConfigAccessService (com.vmware.photon.controller.model.adapters.registry.PhotonModelAdaptersConfigAccessService)1 PhotonModelAdapterConfig (com.vmware.photon.controller.model.adapters.registry.PhotonModelAdaptersRegistryService.PhotonModelAdapterConfig)1 CUSTOM_PROP_ENDPOINT_LINK (com.vmware.photon.controller.model.constants.PhotonModelConstants.CUSTOM_PROP_ENDPOINT_LINK)1 SOURCE_TASK_LINK (com.vmware.photon.controller.model.constants.PhotonModelConstants.SOURCE_TASK_LINK)1 ComputeDescriptionService (com.vmware.photon.controller.model.resources.ComputeDescriptionService)1 ComputeDescription (com.vmware.photon.controller.model.resources.ComputeDescriptionService.ComputeDescription)1 ComputeService (com.vmware.photon.controller.model.resources.ComputeService)1 ComputeState (com.vmware.photon.controller.model.resources.ComputeService.ComputeState)1 EndpointService (com.vmware.photon.controller.model.resources.EndpointService)1 EndpointState (com.vmware.photon.controller.model.resources.EndpointService.EndpointState)1 ResourcePoolService (com.vmware.photon.controller.model.resources.ResourcePoolService)1 ResourcePoolState (com.vmware.photon.controller.model.resources.ResourcePoolService.ResourcePoolState)1 CertificateInfo (com.vmware.photon.controller.model.support.CertificateInfo)1 CertificateInfoServiceErrorResponse (com.vmware.photon.controller.model.support.CertificateInfoServiceErrorResponse)1