@Test(dataProvider = "SuccessCombinations") public void testEndToEndSuccess(boolean isReplicated, int existingContainers) throws Throwable { ContainerTemplateService.State templateStartState = TestHelper.getContainerTemplateServiceStartState(); templateStartState.isReplicated = isReplicated; ContainerTemplateService.State containerTemplate = TestHelper.createContainerTemplateService(testEnvironment, templateStartState); VmService.State vmState = new VmService.State(); for (int i = 0; i < existingContainers; i++) { vmState.documentSelfLink = dockerVms.get(i); TestHelper.createContainerService(testEnvironment, containerTemplate, vmState); } startState.containerTemplateDocumentLink = containerTemplate.documentSelfLink; startState.dockerVmDocumentLinks.clear(); startState.dockerVmDocumentLinks.addAll(dockerVms); startState.singletonVmServiceLink = dockerVms.get(0); CreateContainerSpecTaskService.State finalState = testEnvironment.callServiceAndWaitForState( CreateContainerSpecTaskFactoryService.SELF_LINK, startState, CreateContainerSpecTaskService.State.class, (state) -> TaskUtils.finalTaskStages.contains(state.taskState.stage)); TestHelper.assertTaskStateFinished(finalState.taskState); validateAllocatedContainers(isReplicated, containerTemplate.documentSelfLink); }
/** * Updates the vm associated to the vmServiceLink with the vm Identifier. * * @param currentState * @param vmId */ private void updateVmId(final State currentState, String vmId) { Operation.CompletionHandler completionHandler = new Operation.CompletionHandler() { @Override public void handle(Operation operation, Throwable throwable) { if (null != throwable) { failTask(throwable); return; } queryContainers(currentState); } }; VmService.State vmPatchState = new VmService.State(); vmPatchState.vmId = vmId; Operation patchOperation = Operation.createPatch(UriUtils.buildUri(getHost(), currentState.vmServiceLink)) .setBody(vmPatchState) .setCompletion(completionHandler); sendRequest(patchOperation); }