@Test public void testCleanupOnScale() { Stack stack = spy(aStack()); Optional<KerberosConfig> kerberosConfig = Optional.of(mock(KerberosConfig.class)); when(kerberosConfigService.get(ENVIRONMENT_CRN, STACK_NAME)).thenReturn(kerberosConfig); when(environmentConfigProvider.isChildEnvironment(ENVIRONMENT_CRN)).thenReturn(false); when(kerberosDetailService.keytabsShouldBeUpdated(CLOUD_PLATFORM, false, kerberosConfig)).thenReturn(true); OperationStatus operationStatus = new OperationStatus("opId", OperationType.CLEANUP, null, null, null, null, 0L, null); ArgumentCaptor<CleanupRequest> captor = ArgumentCaptor.forClass(CleanupRequest.class); when(freeIpaV1Endpoint.internalCleanup(captor.capture(), anyString())).thenReturn(operationStatus); when(freeIpaOperationChecker.pollWithAbsoluteTimeout(any(), any(), anyLong(), anyLong(), anyInt())).thenReturn(pollingResult); victim.cleanupOnScale(stack, Set.of("asdf", "qwer"), Set.of("1.1.1.1", "1.1.1.2")); CleanupRequest cleanupRequest = captor.getValue(); assertEquals(STACK_NAME, cleanupRequest.getClusterName()); assertEquals(ENVIRONMENT_CRN, cleanupRequest.getEnvironmentCrn()); assertEquals(Set.of(REMOVE_USERS, REMOVE_ROLES), cleanupRequest.getCleanupStepsToSkip()); assertEquals(Set.of(KERBEROS_USER_PREFIX + stack.getName(), KEYTAB_USER_PREFIX + stack.getName(), LDAP_USER_PREFIX + stack.getName()), cleanupRequest.getUsers()); assertEquals(Set.of(ROLE_NAME_PREFIX + stack.getName()), cleanupRequest.getRoles()); assertEquals(Set.of("1.1.1.1", "1.1.1.2"), cleanupRequest.getIps()); assertEquals(Set.of("asdf", "qwer"), cleanupRequest.getHosts()); }
public void cleanupOnScale(Stack stack, Set<String> hostNames, Set<String> ips) { validateCleanupParametersSet(hostNames, ips); LOGGER.info("Cleanup on scale invoked with hostnames {} and IPs {}", hostNames, ips); cleanup(stack, STEPS_TO_SKIP_ON_SCALE, hostNames, ips); }
FreeIpaCleanupService { public void cleanupOnScale(Stack stack, Set<String> hostNames, Set<String> ips) { validateCleanupParametersSet(hostNames, ips); LOGGER.info("Cleanup on scale invoked with hostnames {} and IPs {}", hostNames, ips); cleanup(stack, STEPS_TO_SKIP_ON_SCALE, hostNames, ips); } }
FreeIpaCleanupService { public void cleanupOnScale(Stack stack, Set<String> hostNames, Set<String> ips) { validateCleanupParametersSet(hostNames, ips); LOGGER.info("Cleanup on scale invoked with hostnames {} and IPs {}", hostNames, ips); cleanup(stack, STEPS_TO_SKIP_ON_SCALE, hostNames, ips); }  }
FreeIpaCleanupService { public void cleanupOnScale(Stack stack, Set<String> hostNames, Set<String> ips) { validateCleanupParametersSet(hostNames, ips); LOGGER.info("Cleanup on scale invoked with hostnames {} and IPs {}", hostNames, ips); cleanup(stack, STEPS_TO_SKIP_ON_SCALE, hostNames, ips); }  void cleanup(Stack stack); void cleanupOnScale(Stack stack, Set<String> hostNames, Set<String> ips); void cleanupOnRecover(Stack stack, Set<String> hostNames, Set<String> ips); void cleanupDnsOnly(Stack stack, Set<String> hostNames, Set<String> ips); }
FreeIpaCleanupService { public void cleanupOnScale(Stack stack, Set<String> hostNames, Set<String> ips) { validateCleanupParametersSet(hostNames, ips); LOGGER.info("Cleanup on scale invoked with hostnames {} and IPs {}", hostNames, ips); cleanup(stack, STEPS_TO_SKIP_ON_SCALE, hostNames, ips); }  void cleanup(Stack stack); void cleanupOnScale(Stack stack, Set<String> hostNames, Set<String> ips); void cleanupOnRecover(Stack stack, Set<String> hostNames, Set<String> ips); void cleanupDnsOnly(Stack stack, Set<String> hostNames, Set<String> ips);  }