use of com.vmware.photon.controller.model.tasks.EndpointRemovalTaskService.EndpointRemovalTaskState in project photon-model by vmware.
the class TestAWSEnumerationDocumentCountInLongRun method testDocumentCountsDuringEnumeration.
/**
* Test flow:
* 1. Provision instances on AWS
* 2. Periodically run enumeration for a specified duration.
* 3. Assert that there is only one document each for the all the resources enumerated during the test.
* 4. Delete all the instances that were provisioned at the start of the test.
* 5. Run enumeration.
* 6. Assert that all the documents enumerated during the test got deleted.
* @throws Throwable
*/
@Test
public void testDocumentCountsDuringEnumeration() throws Throwable {
this.host.log("Running test: " + this.currentTestName);
if (this.isMock) {
// Just make a call to the enumeration service and make sure that the adapter patches
// the parent with completion.
enumerateResources(this.host, this.computeHost, this.endpointState, this.isMock, TEST_CASE_MOCK_MODE);
return;
}
// Provision instances on AWS
this.instanceIds = provisionAWSVMWithEC2Client(this.client, this.host, this.numberOfInstancesToProvision, T2_MICRO_INSTANCE_TYPE, this.subnetId, this.securityGroupId);
this.instancesToCleanUp.addAll(this.instanceIds);
waitForProvisioningToComplete(this.instanceIds, this.host, this.client, 0);
// create 2nd endpoint with same auth credentials
initResourcePoolAndComputeHostTwo();
// run enumeration on both the endpoints.
enumerateResources(this.host, this.computeHostTwo, this.endpointStateTwo, this.isMock, TEST_CASE_INITIAL);
enumerateResources(this.host, this.computeHost, this.endpointState, this.isMock, TEST_CASE_INITIAL);
// delete 2nd endpoint
EndpointRemovalTaskState completeState = TestAWSSetupUtils.deleteEndpointState(this.host, this.endpointStateTwo, true);
assertTrue(completeState.taskInfo.stage == TaskState.TaskStage.FINISHED);
// validate compute descriptions's of 1st endpoint
validateComputeDescForEndpoint();
// Periodically run enumeration, specified by enumerationFrequencyInMinutes parameter.
runEnumerationAndLogNodeStatsPeriodically();
this.host.log(Level.INFO, "Waiting for multiple enumeration runs...");
// Keep the host running for some time, specified by testRunDurationInMinutes parameter.
this.host.waitFor("Timeout while waiting for test run duration", () -> {
TimeUnit.MINUTES.sleep(this.testRunDurationInMinutes);
this.host.getScheduledExecutor().shutdown();
this.host.getScheduledExecutor().awaitTermination(EXECUTOR_TERMINATION_WAIT_DURATION_MINUTES, TimeUnit.MINUTES);
return true;
});
this.host.waitFor("Timeout while waiting for last enumeration to clear out.", () -> {
TimeUnit.MINUTES.sleep(1);
return true;
});
verifyResourceDuplicates();
// Store document links and ids for enumerated resources to obtain expected number of documents
// and actual number of documents.
storeDocumentLinksAndIds(this.instanceIds);
// Asserts to check if the document counts are correct after multiple enumerations
assertDocumentCounts();
// Assert that all networkInterfaceLinks in computestates are valid.
assertNetworkInterfaceLinksAreValid();
// Delete AWS resources that were provisioned
deleteVMsUsingEC2Client(this.client, this.host, this.instanceIds);
// Run enumeration after deleting instances
enumerateResources(this.host, this.computeHost, this.endpointState, this.isMock, TEST_CASE_DELETE_VM);
// Clear the document links and ids stored previously
clearStoredDocumentLinksAndIds();
// Store document links and ids for enumerated resources to obtain expected number of documents
// and actual number of documents.
storeDocumentLinksAndIds(this.instanceIds);
// Asserts to check if all the documents enumerated during test are deleted deleting instances.
this.postDeletion = true;
assertDocumentCounts();
}
use of com.vmware.photon.controller.model.tasks.EndpointRemovalTaskService.EndpointRemovalTaskState in project photon-model by vmware.
the class TestAWSSetupUtils method deleteEndpointState.
/**
* Delete endpoint using EndpointRemovalTaskService.
*/
public static EndpointRemovalTaskState deleteEndpointState(VerificationHost host, EndpointState endpointState, boolean disableGroomer) throws Throwable {
EndpointRemovalTaskState removalTaskState = createEndpointRemovalTaskState(endpointState, disableGroomer);
EndpointRemovalTaskState returnState = TestUtils.doPost(host, removalTaskState, EndpointRemovalTaskState.class, UriUtils.buildUri(host, EndpointRemovalTaskService.FACTORY_LINK));
return host.waitForFinishedTask(EndpointRemovalTaskState.class, returnState.documentSelfLink);
}
use of com.vmware.photon.controller.model.tasks.EndpointRemovalTaskService.EndpointRemovalTaskState in project photon-model by vmware.
the class TestAWSSetupUtils method createEndpointRemovalTaskState.
private static EndpointRemovalTaskState createEndpointRemovalTaskState(EndpointState endpoint, boolean disableGroomer) {
EndpointRemovalTaskState endpointRemovalTaskState = new EndpointRemovalTaskState();
endpointRemovalTaskState.endpointLink = endpoint.documentSelfLink;
endpointRemovalTaskState.tenantLinks = endpoint.tenantLinks;
endpointRemovalTaskState.disableGroomer = disableGroomer;
return endpointRemovalTaskState;
}
use of com.vmware.photon.controller.model.tasks.EndpointRemovalTaskService.EndpointRemovalTaskState in project photon-model by vmware.
the class EndpointRemovalTaskServiceTest method createEndpointRemovalTaskState.
private static EndpointRemovalTaskState createEndpointRemovalTaskState(EndpointState endpoint) {
EndpointRemovalTaskState endpointRemovalTaskState = new EndpointRemovalTaskState();
endpointRemovalTaskState.endpointLink = endpoint.documentSelfLink;
endpointRemovalTaskState.tenantLinks = endpoint.tenantLinks;
return endpointRemovalTaskState;
}
Aggregations