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));
}
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"));
}
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"));
}
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());
}
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);
}
Aggregations