Integer.MAX_VALUE - 100L, null, true, false); ContainerHostRemovalTaskState computeEndpointRemovaleStare = new ContainerHostRemovalTaskState(); computeEndpointRemovaleStare.resourceLinks = new HashSet<>(Collections.singletonList( dockerHost.documentSelfLink)); ContainerHostRemovalTaskState state = new ContainerHostRemovalTaskState(); state.resourceLinks = new HashSet<>(Collections.singletonList( cs.documentSelfLink)); state = new ContainerHostRemovalTaskState(); state.resourceLinks = new HashSet<>(Collections.singletonList( computeHost.documentSelfLink));
/** * Do not delete the compute which is created with the endpoint. * This compute is created without "__trustCertLink" custom property. * If there is such compute we forbid the automatic deletion of trust * certificates. */ @Test public void testTrustCertRemovedAfterContainerHostRemoval() throws Throwable { // create a host without trustCertLink createDockerHost(dockerHostDesc, resourcePool, Integer.MAX_VALUE - 100L, null, true, false); //get trust certificates initial size List<String> trustCertList = getDocumentLinksOfType(SslTrustCertificateState.class); int trustCertInitialSize = trustCertList.size(); // create a host removal task ContainerHostRemovalTaskState state = new ContainerHostRemovalTaskState(); state.resourceLinks = new HashSet<>(Collections.singletonList( computeHost.documentSelfLink)); state = doPost(state, ContainerHostRemovalTaskFactoryService.SELF_LINK); assertNotNull("task is null", state); waitForTaskSuccess(state.documentSelfLink, ContainerHostRemovalTaskState.class); //validation validateHostRemoved(new LinkedList<>(Collections.singletonList( computeHost.documentSelfLink))); trustCertList = getDocumentLinksOfType(SslTrustCertificateState.class); assertEquals(trustCertInitialSize, trustCertList.size()); }
private void removeContainerHosts(ComputeRemovalTaskState state, List<String> containerHosts, List<String> deleteZonesLinks) { ContainerHostRemovalTaskState hostRemovalState = new ContainerHostRemovalTaskState(); hostRemovalState.resourceLinks = new HashSet<>(containerHosts); hostRemovalState.skipComputeHostRemoval = true; boolean errorState = state.taskSubStage == SubStage.ERROR; hostRemovalState.serviceTaskCallback = ServiceTaskCallback.create(getSelfLink(), TaskStage.STARTED, errorState ? SubStage.ERROR : SubStage.REMOVED_CONTAINER_HOSTS, TaskStage.FAILED, SubStage.ERROR); hostRemovalState.documentSelfLink = getSelfId(); hostRemovalState.customProperties = state.customProperties; hostRemovalState.requestTrackerLink = state.requestTrackerLink; hostRemovalState.taskSubStage = ContainerHostRemovalTaskState.SubStage.SUSPENDED_HOSTS; sendRequest(Operation.createPost(this, ContainerHostRemovalTaskFactoryService.SELF_LINK) .setBody(hostRemovalState) .setContextId(getSelfId()) .setCompletion((o, ex) -> { if (ex != null) { failTask("Failed to create container host removal operation task", ex); return; } proceedTo(SubStage.REMOVING_CONTAINER_HOSTS, (patchState) -> { patchState.deletePlacementZonesLinks = deleteZonesLinks; }); })); }
@Test public void testContainerHostRemovalResourceOperationCycle() throws Throwable { request = startRequest(request); waitForRequestToComplete(request); request = getDocument(RequestBrokerState.class, request.documentSelfLink); assertNotNull(request); // verify the resources are created as expected: assertEquals(request.resourceCount, request.resourceLinks.size()); List<String> containerStateLinks = findResourceLinks(ContainerState.class, request.resourceLinks); // create a host removal task ContainerHostRemovalTaskState state = new ContainerHostRemovalTaskState(); state.resourceLinks = new HashSet<>(Collections.singletonList( computeHost.documentSelfLink)); state = doPost(state, ContainerHostRemovalTaskFactoryService.SELF_LINK); assertNotNull("task is null", state); waitForTaskSuccess(state.documentSelfLink, ContainerHostRemovalTaskState.class); validateHostRemoved(containerStateLinks); }