Search in sources :

Example 21 with StackViewV4Responses

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Responses 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 22 with StackViewV4Responses

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Responses in project cloudbreak by hortonworks.

the class DatahubDeletionServiceTest method deleteDatahubClustersForEnvironmentFail.

@Test
void deleteDatahubClustersForEnvironmentFail() {
    PollingConfig pollingConfig = PollingConfig.builder().withSleepTime(0).withSleepTimeUnit(TimeUnit.SECONDS).withTimeout(10).withTimeoutTimeUnit(TimeUnit.SECONDS).build();
    Environment environment = new Environment();
    environment.setResourceCrn(ENV_CRN);
    StackViewV4Response datahub1 = new StackViewV4Response();
    datahub1.setCrn("crn1");
    StackViewV4Response datahub2 = new StackViewV4Response();
    datahub2.setCrn("crn2");
    datahub2.setStatus(Status.DELETE_FAILED);
    when(datahubService.list(anyString())).thenReturn(new StackViewV4Responses(Set.of(datahub1, datahub2)), new StackViewV4Responses(Set.of(datahub2)), new StackViewV4Responses(Set.of(datahub2)));
    assertThatThrownBy(() -> underTest.deleteDatahubClustersForEnvironment(pollingConfig, environment, true)).isInstanceOf(UserBreakException.class).hasCauseInstanceOf(IllegalStateException.class);
    ArgumentCaptor<DistroXMultiDeleteV1Request> captor = ArgumentCaptor.forClass(DistroXMultiDeleteV1Request.class);
    verify(datahubService).deleteMultiple(anyString(), captor.capture(), eq(true));
    DistroXMultiDeleteV1Request multiDeleteRequest = captor.getValue();
    assertThat(multiDeleteRequest.getCrns()).hasSameElementsAs(Set.of("crn1", "crn2"));
}
Also used : StackViewV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Response) UserBreakException(com.dyngr.exception.UserBreakException) Environment(com.sequenceiq.environment.environment.domain.Environment) DistroXMultiDeleteV1Request(com.sequenceiq.distrox.api.v1.distrox.model.cluster.DistroXMultiDeleteV1Request) StackViewV4Responses(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Responses) PollingConfig(com.sequenceiq.environment.util.PollingConfig) Test(org.junit.jupiter.api.Test)

Example 23 with StackViewV4Responses

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Responses in project cloudbreak by hortonworks.

the class DatahubDeletionServiceTest method deleteDatahubClustersForEnvironment.

@Test
void deleteDatahubClustersForEnvironment() {
    PollingConfig pollingConfig = PollingConfig.builder().withSleepTime(0).withSleepTimeUnit(TimeUnit.SECONDS).withTimeout(10).withTimeoutTimeUnit(TimeUnit.SECONDS).build();
    Environment environment = new Environment();
    environment.setResourceCrn(ENV_CRN);
    StackViewV4Response distrox1 = new StackViewV4Response();
    distrox1.setCrn("crn1");
    StackViewV4Response distrox2 = new StackViewV4Response();
    distrox2.setCrn("crn2");
    when(datahubService.list(anyString())).thenReturn(new StackViewV4Responses(Set.of(distrox1, distrox2)), new StackViewV4Responses(Set.of(distrox2)), new StackViewV4Responses(Set.of()));
    underTest.deleteDatahubClustersForEnvironment(pollingConfig, environment, true);
    ArgumentCaptor<DistroXMultiDeleteV1Request> captor = ArgumentCaptor.forClass(DistroXMultiDeleteV1Request.class);
    verify(datahubService).deleteMultiple(anyString(), captor.capture(), eq(true));
    DistroXMultiDeleteV1Request multiDeleteRequest = captor.getValue();
    assertThat(multiDeleteRequest.getCrns()).hasSameElementsAs(Set.of("crn1", "crn2"));
}
Also used : StackViewV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Response) Environment(com.sequenceiq.environment.environment.domain.Environment) DistroXMultiDeleteV1Request(com.sequenceiq.distrox.api.v1.distrox.model.cluster.DistroXMultiDeleteV1Request) StackViewV4Responses(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Responses) PollingConfig(com.sequenceiq.environment.util.PollingConfig) Test(org.junit.jupiter.api.Test)

Example 24 with StackViewV4Responses

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Responses in project cloudbreak by hortonworks.

the class DatahubPollerServiceTest method testStartAttachedDatahubWhenNoAttachedDatahub.

@Test
void testStartAttachedDatahubWhenNoAttachedDatahub() {
    when(datahubService.list(ENV_CRN)).thenReturn(new StackViewV4Responses(Collections.emptySet()));
    underTest.startAttachedDatahubClusters(ENV_ID, ENV_CRN);
    verify(datahubService, times(0)).putStartByCrns(eq(ENV_CRN), anyList());
}
Also used : StackViewV4Responses(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Responses) Test(org.junit.jupiter.api.Test)

Example 25 with StackViewV4Responses

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Responses in project cloudbreak by hortonworks.

the class StackUpgradeOperationsTest method testCheckForClusterUpgradeShouldReturnCompositeErrorWhenBothAttachedDataHubValidationsFail.

@Test
void testCheckForClusterUpgradeShouldReturnCompositeErrorWhenBothAttachedDataHubValidationsFail() {
    Stack stack = createStack(StackType.DATALAKE);
    StackViewV4Responses stackViewV4Responses = new StackViewV4Responses();
    UpgradeV4Request request = createUpgradeRequest(null);
    UpgradeV4Response upgradeResponseToReturn = createUpgradeResponse();
    UpgradeV4Response expectedResponse = createUpgradeResponse();
    expectedResponse.setReason("There are attached Data Hub clusters that are non-upgradeable There are attached Data Hub clusters in incorrect state");
    when(instanceGroupService.getByStackAndFetchTemplates(STACK_ID)).thenReturn(Collections.emptySet());
    when(upgradeService.isOsUpgrade(request)).thenReturn(false);
    StackInstanceCount instanceCount = mock(StackInstanceCount.class);
    when(instanceCount.getInstanceCount()).thenReturn(INSTANCE_COUNT);
    when(instanceMetaDataService.countByStackId(STACK_ID)).thenReturn(instanceCount);
    when(limitConfiguration.getUpgradeNodeCountLimit()).thenReturn(NODE_LIMIT);
    when(clusterUpgradeAvailabilityService.checkForUpgradesByName(stack, false, true, request.getInternalUpgradeSettings())).thenReturn(upgradeResponseToReturn);
    when(entitlementService.runtimeUpgradeEnabled(ACCOUNT_ID)).thenReturn(true);
    when(stackOperations.listByEnvironmentCrn(eq(WORKSPACE_ID), eq(ENVIRONMENT_CRN), any())).thenReturn(stackViewV4Responses);
    when(upgradePreconditionService.checkForRunningAttachedClusters(stackViewV4Responses, stack)).thenReturn("There are attached Data Hub clusters in incorrect state");
    when(upgradePreconditionService.checkForNonUpgradeableAttachedClusters(stackViewV4Responses)).thenReturn("There are attached Data Hub clusters that are non-upgradeable");
    UpgradeV4Response actual = underTest.checkForClusterUpgrade(ACCOUNT_ID, stack, WORKSPACE_ID, request);
    assertEquals(expectedResponse, actual);
    verify(instanceGroupService).getByStackAndFetchTemplates(STACK_ID);
    verify(upgradeService).isOsUpgrade(request);
    verify(instanceGroupService).getByStackAndFetchTemplates(STACK_ID);
    verify(limitConfiguration).getUpgradeNodeCountLimit();
    verify(clusterUpgradeAvailabilityService).checkForUpgradesByName(stack, false, true, request.getInternalUpgradeSettings());
    verify(clusterUpgradeAvailabilityService).filterUpgradeOptions(ACCOUNT_ID, upgradeResponseToReturn, request, true);
    verify(entitlementService).runtimeUpgradeEnabled(ACCOUNT_ID);
    verify(stackOperations).listByEnvironmentCrn(eq(WORKSPACE_ID), eq(ENVIRONMENT_CRN), any());
    verify(upgradePreconditionService).checkForRunningAttachedClusters(stackViewV4Responses, stack);
    verify(upgradePreconditionService).checkForNonUpgradeableAttachedClusters(stackViewV4Responses);
    verifyNoInteractions(clusterDBValidationService);
}
Also used : UpgradeV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.upgrade.UpgradeV4Response) StackInstanceCount(com.sequenceiq.cloudbreak.domain.projection.StackInstanceCount) UpgradeV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.tags.upgrade.UpgradeV4Request) StackViewV4Responses(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Responses) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.jupiter.api.Test)

Aggregations

StackViewV4Responses (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Responses)33 Test (org.junit.jupiter.api.Test)19 StackViewV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Response)18 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)14 Test (org.junit.Test)8 PollingConfig (com.sequenceiq.environment.util.PollingConfig)4 NameOrCrn (com.sequenceiq.cloudbreak.api.endpoint.v4.dto.NameOrCrn)3 UpgradeV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.tags.upgrade.UpgradeV4Request)3 UpgradeOptionV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.upgrade.UpgradeOptionV4Response)3 UpgradeV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.upgrade.UpgradeV4Response)3 Image (com.sequenceiq.cloudbreak.cloud.model.Image)3 StackInstanceCount (com.sequenceiq.cloudbreak.domain.projection.StackInstanceCount)3 InstanceMetaData (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData)3 RepairValidation (com.sequenceiq.cloudbreak.service.cluster.model.RepairValidation)3 StatedImage (com.sequenceiq.cloudbreak.service.image.StatedImage)3 Environment (com.sequenceiq.environment.environment.domain.Environment)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 ClusterViewV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.views.ClusterViewV4Response)2 DistroXMultiDeleteV1Request (com.sequenceiq.distrox.api.v1.distrox.model.cluster.DistroXMultiDeleteV1Request)2