use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Responses in project cloudbreak by hortonworks.
the class DatahubPollerServiceTest method testStopAttachedDatahubWhenDatahubIsAvailable.
@Test
void testStopAttachedDatahubWhenDatahubIsAvailable() {
StackViewV4Response stackView = getStackView(Status.AVAILABLE);
when(datahubService.list(ENV_CRN)).thenReturn(new StackViewV4Responses(Set.of(stackView)));
when(datahubService.getByCrn(anyString(), anySet())).thenReturn(getStack(Status.AVAILABLE), getStack(Status.AVAILABLE), getStack(Status.STOPPED));
underTest.stopAttachedDatahubClusters(ENV_ID, ENV_CRN);
verify(datahubService, times(1)).putStopByCrns(eq(ENV_CRN), anyList());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Responses in project cloudbreak by hortonworks.
the class DatahubPollerServiceTest method testStartAttachedDatahubWhenDatahubIsStopped.
@Test
void testStartAttachedDatahubWhenDatahubIsStopped() {
StackViewV4Response stackView = getStackView(Status.STOPPED);
when(datahubService.list(ENV_CRN)).thenReturn(new StackViewV4Responses(Set.of(stackView)));
when(datahubService.getByCrn(anyString(), anySet())).thenReturn(getStack(Status.STOPPED), getStack(Status.STOPPED), getStack(Status.AVAILABLE));
underTest.startAttachedDatahubClusters(ENV_ID, ENV_CRN);
verify(datahubService, times(1)).putStartByCrns(eq(ENV_CRN), anyList());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Responses 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());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Responses in project cloudbreak by hortonworks.
the class StackUpgradeOperationsTest method testCheckForClusterUpgradeShouldNotValidateUpgradeableDataHubsWhenDataHubUpgradeEntitlementIsGranted.
@Test
void testCheckForClusterUpgradeShouldNotValidateUpgradeableDataHubsWhenDataHubUpgradeEntitlementIsGranted() {
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 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(entitlementService.datahubRuntimeUpgradeEnabled(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");
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, times(0)).checkForNonUpgradeableAttachedClusters(stackViewV4Responses);
verifyNoInteractions(clusterDBValidationService);
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Responses in project cloudbreak by hortonworks.
the class StackUpgradeOperationsTest method testCheckForClusterUpgradeShouldReturnUpgradeCandidatesWhenTheUpgradeIsRuntimeUpgradeAndTheStackTypeIsDataLakeAndReplaceVmEnabled.
@Test
void testCheckForClusterUpgradeShouldReturnUpgradeCandidatesWhenTheUpgradeIsRuntimeUpgradeAndTheStackTypeIsDataLakeAndReplaceVmEnabled() {
Stack stack = createStack(StackType.DATALAKE);
StackViewV4Responses stackViewV4Responses = new StackViewV4Responses();
UpgradeV4Request request = createUpgradeRequest(null);
UpgradeV4Response upgradeResponse = createUpgradeResponse();
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(upgradeResponse);
when(entitlementService.runtimeUpgradeEnabled(ACCOUNT_ID)).thenReturn(true);
when(stackOperations.listByEnvironmentCrn(eq(WORKSPACE_ID), eq(ENVIRONMENT_CRN), any())).thenReturn(stackViewV4Responses);
UpgradeV4Response actual = underTest.checkForClusterUpgrade(ACCOUNT_ID, stack, WORKSPACE_ID, request);
assertEquals(upgradeResponse, 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, upgradeResponse, 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