Search in sources :

Example 1 with PollingConfig

use of com.sequenceiq.environment.util.PollingConfig in project cloudbreak by hortonworks.

the class SdxDeleteServiceTest method deleteSdxClustersForEnvironmentFail.

@Test
void deleteSdxClustersForEnvironmentFail() {
    PollingConfig pollingConfig = getPollingConfig();
    EnvironmentView environment = getEnvironmentView();
    String sdxCrn1 = "crn:cdp:datalake:us-west-1:tenant:datalake:crn1";
    String sdxCrn2 = "crn:cdp:sdxsvc:us-west-1:tenant:instance:crn2";
    when(environmentResourceDeletionService.getAttachedSdxClusterCrns(environment)).thenReturn(Set.of(sdxCrn1, sdxCrn2));
    when(platformAwareSdxConnector.getAttemptResultForDeletion(any(), any(), any())).thenReturn(AttemptResults.breakFor(new IllegalStateException()));
    assertThatThrownBy(() -> underTest.deleteSdxClustersForEnvironment(pollingConfig, environment, true)).isInstanceOf(UserBreakException.class).hasCauseInstanceOf(IllegalStateException.class);
    verify(platformAwareSdxConnector).delete(eq(sdxCrn1), eq(true));
    verify(platformAwareSdxConnector).delete(eq(sdxCrn2), eq(true));
    verifyNoMoreInteractions(platformAwareSdxConnector);
}
Also used : UserBreakException(com.dyngr.exception.UserBreakException) EnvironmentView(com.sequenceiq.environment.environment.domain.EnvironmentView) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) PollingConfig(com.sequenceiq.environment.util.PollingConfig) Test(org.junit.jupiter.api.Test)

Example 2 with PollingConfig

use of com.sequenceiq.environment.util.PollingConfig in project cloudbreak by hortonworks.

the class SdxDeleteServiceTest method deleteSdxClustersForEnvironmentNoSdxFound.

@Test
void deleteSdxClustersForEnvironmentNoSdxFound() {
    PollingConfig pollingConfig = getPollingConfig();
    EnvironmentView environment = getEnvironmentView();
    when(environmentResourceDeletionService.getAttachedSdxClusterCrns(environment)).thenReturn(Set.of());
    underTest.deleteSdxClustersForEnvironment(pollingConfig, environment, true);
}
Also used : EnvironmentView(com.sequenceiq.environment.environment.domain.EnvironmentView) PollingConfig(com.sequenceiq.environment.util.PollingConfig) Test(org.junit.jupiter.api.Test)

Example 3 with PollingConfig

use of com.sequenceiq.environment.util.PollingConfig in project cloudbreak by hortonworks.

the class DatahubDeletionServiceTest method deleteDatahubClustersForEnvironmentNoDatahubFound.

@Test
void deleteDatahubClustersForEnvironmentNoDatahubFound() {
    PollingConfig pollingConfig = PollingConfig.builder().withSleepTime(0).withSleepTimeUnit(TimeUnit.SECONDS).withTimeout(0).withTimeoutTimeUnit(TimeUnit.SECONDS).build();
    Environment environment = new Environment();
    environment.setResourceCrn(ENV_CRN);
    StackViewV4Responses responses = new StackViewV4Responses(Set.of());
    when(datahubService.list(anyString())).thenReturn(responses);
    underTest.deleteDatahubClustersForEnvironment(pollingConfig, environment, true);
    verify(datahubService, never()).deleteMultiple(anyString(), any(), anyBoolean());
}
Also used : Environment(com.sequenceiq.environment.environment.domain.Environment) StackViewV4Responses(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Responses) PollingConfig(com.sequenceiq.environment.util.PollingConfig) Test(org.junit.jupiter.api.Test)

Example 4 with PollingConfig

use of com.sequenceiq.environment.util.PollingConfig in project cloudbreak by hortonworks.

the class SdxDeleteServiceTest method deleteSdxClustersForEnvironmentWhenSdxIsEmptyButDatalakeNot.

@Test
void deleteSdxClustersForEnvironmentWhenSdxIsEmptyButDatalakeNot() {
    PollingConfig pollingConfig = getPollingConfig();
    EnvironmentView environment = getEnvironmentView();
    when(environmentResourceDeletionService.getAttachedSdxClusterCrns(environment)).thenReturn(emptySet());
    when(environmentResourceDeletionService.getDatalakeClusterNames(environment)).thenReturn(Set.of("name"));
    when(regionAwareInternalCrnGenerator.getInternalCrnForServiceAsString()).thenReturn("crn");
    when(regionAwareInternalCrnGeneratorFactory.iam()).thenReturn(regionAwareInternalCrnGenerator);
    when(stackV4Endpoint.list(anyLong(), anyString(), anyBoolean())).thenReturn(new StackViewV4Responses());
    underTest.deleteSdxClustersForEnvironment(pollingConfig, environment, true);
    verify(stackV4Endpoint).deleteInternal(eq(0L), eq("name"), eq(true), nullable(String.class));
}
Also used : EnvironmentView(com.sequenceiq.environment.environment.domain.EnvironmentView) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) StackViewV4Responses(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Responses) PollingConfig(com.sequenceiq.environment.util.PollingConfig) Test(org.junit.jupiter.api.Test)

Example 5 with PollingConfig

use of com.sequenceiq.environment.util.PollingConfig in project cloudbreak by hortonworks.

the class SdxDeleteServiceTest method deleteSdxClustersForEnvironment.

@Test
void deleteSdxClustersForEnvironment() {
    PollingConfig pollingConfig = getPollingConfig();
    EnvironmentView environment = getEnvironmentView();
    String sdxCrn1 = "crn:cdp:datalake:us-west-1:tenant:datalake:crn1";
    String sdxCrn2 = "crn:cdp:sdxsvc:us-west-1:tenant:instance:crn2";
    when(environmentResourceDeletionService.getAttachedSdxClusterCrns(environment)).thenReturn(Set.of(sdxCrn1, sdxCrn2));
    when(platformAwareSdxConnector.getAttemptResultForDeletion(any(), any(), any())).thenReturn(AttemptResults.finishWith(null));
    underTest.deleteSdxClustersForEnvironment(pollingConfig, environment, true);
    verify(platformAwareSdxConnector).delete(eq(sdxCrn1), eq(true));
    verify(platformAwareSdxConnector).delete(eq(sdxCrn2), eq(true));
    verifyNoMoreInteractions(platformAwareSdxConnector);
}
Also used : EnvironmentView(com.sequenceiq.environment.environment.domain.EnvironmentView) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) PollingConfig(com.sequenceiq.environment.util.PollingConfig) Test(org.junit.jupiter.api.Test)

Aggregations

PollingConfig (com.sequenceiq.environment.util.PollingConfig)9 Test (org.junit.jupiter.api.Test)7 EnvironmentView (com.sequenceiq.environment.environment.domain.EnvironmentView)5 StackViewV4Responses (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Responses)4 Environment (com.sequenceiq.environment.environment.domain.Environment)3 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)3 UserBreakException (com.dyngr.exception.UserBreakException)2 StackViewV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Response)2 DistroXMultiDeleteV1Request (com.sequenceiq.distrox.api.v1.distrox.model.cluster.DistroXMultiDeleteV1Request)2 EnvironmentDeletionDto (com.sequenceiq.environment.environment.dto.EnvironmentDeletionDto)2 EnvironmentDto (com.sequenceiq.environment.environment.dto.EnvironmentDto)2 EnvClusterDeleteFailedEvent (com.sequenceiq.environment.environment.flow.deletion.event.EnvClusterDeleteFailedEvent)2 EnvDeleteEvent (com.sequenceiq.environment.environment.flow.deletion.event.EnvDeleteEvent)2 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)1 ExceptionResponse (com.sequenceiq.cloudbreak.common.exception.ExceptionResponse)1 ClientErrorException (javax.ws.rs.ClientErrorException)1