@Test void deleteSdxClustersForEnvironmentWhenSdxIsEmptyButDatalakeNot() { PollingConfig pollingConfig = PollingConfig.builder() .withSleepTime(0) .withSleepTimeUnit(TimeUnit.SECONDS) .withTimeout(10) .withTimeoutTimeUnit(TimeUnit.SECONDS) .build(); Environment environment = new Environment(); environment.setName("envName"); environment.setResourceCrn(Crn.builder().setAccountId("asd") .setResource("asd") .setResourceType(Crn.ResourceType.ENVIRONMENT) .setService(Crn.Service.ENVIRONMENTS) .setPartition(Crn.Partition.CDP) .build().toString()); when(environmentResourceDeletionService.getAttachedSdxClusterCrns(environment)).thenReturn(emptySet()); when(environmentResourceDeletionService.getDatalakeClusterNames(environment)).thenReturn(Set.of("name")); underTest.deleteSdxClustersForEnvironment(pollingConfig, environment, true); verify(stackV4Endpoint).deleteInternal(eq(0L), eq("name"), eq(true), nullable(String.class)); verify(sdxEndpoint, times(0)).deleteByCrn(anyString(), anyBoolean()); }
public void deleteSdxClustersForEnvironment(PollingConfig pollingConfig, Environment environment, boolean force) { Set<String> sdxCrnsOrDatalakeName = environmentResourceDeletionService.getAttachedSdxClusterCrns(environment); boolean legacySdxEndpoint = false; if (sdxCrnsOrDatalakeName.isEmpty()) { sdxCrnsOrDatalakeName = environmentResourceDeletionService.getDatalakeClusterNames(environment); legacySdxEndpoint = true; } LOGGER.info("Found {} Data Lake clusters for environment {}.", sdxCrnsOrDatalakeName.size(), environment.getName()); if (sdxCrnsOrDatalakeName.isEmpty()) { LOGGER.info("No Data Lake clusters found for environment."); } else { waitSdxClustersDeletion(pollingConfig, environment, sdxCrnsOrDatalakeName, legacySdxEndpoint, force); LOGGER.info("Data Lake deletion finished."); } }
SdxDeleteService { public void deleteSdxClustersForEnvironment(PollingConfig pollingConfig, Environment environment, boolean force) { Set<String> sdxCrnsOrDatalakeName = environmentResourceDeletionService.getAttachedSdxClusterCrns(environment); boolean legacySdxEndpoint = false; if (sdxCrnsOrDatalakeName.isEmpty()) { sdxCrnsOrDatalakeName = environmentResourceDeletionService.getDatalakeClusterNames(environment); legacySdxEndpoint = true; } LOGGER.info("Found {} Data Lake clusters for environment {}.", sdxCrnsOrDatalakeName.size(), environment.getName()); if (sdxCrnsOrDatalakeName.isEmpty()) { LOGGER.info("No Data Lake clusters found for environment."); } else { waitSdxClustersDeletion(pollingConfig, environment, sdxCrnsOrDatalakeName, legacySdxEndpoint, force); LOGGER.info("Data Lake deletion finished."); } } }
SdxDeleteService { public void deleteSdxClustersForEnvironment(PollingConfig pollingConfig, Environment environment, boolean force) { Set<String> sdxCrnsOrDatalakeName = environmentResourceDeletionService.getAttachedSdxClusterCrns(environment); boolean legacySdxEndpoint = false; if (sdxCrnsOrDatalakeName.isEmpty()) { sdxCrnsOrDatalakeName = environmentResourceDeletionService.getDatalakeClusterNames(environment); legacySdxEndpoint = true; } LOGGER.info("Found {} Data Lake clusters for environment {}.", sdxCrnsOrDatalakeName.size(), environment.getName()); if (sdxCrnsOrDatalakeName.isEmpty()) { LOGGER.info("No Data Lake clusters found for environment."); } else { waitSdxClustersDeletion(pollingConfig, environment, sdxCrnsOrDatalakeName, legacySdxEndpoint, force); LOGGER.info("Data Lake deletion finished."); } } SdxDeleteService(SdxEndpoint sdxEndpoint, StackV4Endpoint stackV4Endpoint, EnvironmentResourceDeletionService environmentResourceDeletionService); }
SdxDeleteService { public void deleteSdxClustersForEnvironment(PollingConfig pollingConfig, Environment environment, boolean force) { Set<String> sdxCrnsOrDatalakeName = environmentResourceDeletionService.getAttachedSdxClusterCrns(environment); boolean legacySdxEndpoint = false; if (sdxCrnsOrDatalakeName.isEmpty()) { sdxCrnsOrDatalakeName = environmentResourceDeletionService.getDatalakeClusterNames(environment); legacySdxEndpoint = true; } LOGGER.info("Found {} Data Lake clusters for environment {}.", sdxCrnsOrDatalakeName.size(), environment.getName()); if (sdxCrnsOrDatalakeName.isEmpty()) { LOGGER.info("No Data Lake clusters found for environment."); } else { waitSdxClustersDeletion(pollingConfig, environment, sdxCrnsOrDatalakeName, legacySdxEndpoint, force); LOGGER.info("Data Lake deletion finished."); } } SdxDeleteService(SdxEndpoint sdxEndpoint, StackV4Endpoint stackV4Endpoint, EnvironmentResourceDeletionService environmentResourceDeletionService); void deleteSdxClustersForEnvironment(PollingConfig pollingConfig, Environment environment, boolean force); }
SdxDeleteService { public void deleteSdxClustersForEnvironment(PollingConfig pollingConfig, Environment environment, boolean force) { Set<String> sdxCrnsOrDatalakeName = environmentResourceDeletionService.getAttachedSdxClusterCrns(environment); boolean legacySdxEndpoint = false; if (sdxCrnsOrDatalakeName.isEmpty()) { sdxCrnsOrDatalakeName = environmentResourceDeletionService.getDatalakeClusterNames(environment); legacySdxEndpoint = true; } LOGGER.info("Found {} Data Lake clusters for environment {}.", sdxCrnsOrDatalakeName.size(), environment.getName()); if (sdxCrnsOrDatalakeName.isEmpty()) { LOGGER.info("No Data Lake clusters found for environment."); } else { waitSdxClustersDeletion(pollingConfig, environment, sdxCrnsOrDatalakeName, legacySdxEndpoint, force); LOGGER.info("Data Lake deletion finished."); } } SdxDeleteService(SdxEndpoint sdxEndpoint, StackV4Endpoint stackV4Endpoint, EnvironmentResourceDeletionService environmentResourceDeletionService); void deleteSdxClustersForEnvironment(PollingConfig pollingConfig, Environment environment, boolean force);  }