use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Responses in project cloudbreak by hortonworks.
the class UpgradePreconditionServiceTest method testCheckForUpgradeableAttachedClustersShouldNotReturnErrorMessageWhenThereIsNoNonUpgradeableCluster.
@Test
public void testCheckForUpgradeableAttachedClustersShouldNotReturnErrorMessageWhenThereIsNoNonUpgradeableCluster() {
StackViewV4Response dataHubStack1 = createStackResponse(Status.STOPPED, "stack-1", "stack-crn-1");
dataHubStack1.setCluster(createClusterResponse(Status.STOPPED, BlueprintBasedUpgradeOption.UPGRADE_ENABLED));
StackViewV4Response dataHubStack2 = createStackResponse(Status.DELETE_COMPLETED, "stack-2", "stack-crn-2");
dataHubStack2.setCluster(createClusterResponse(Status.DELETE_COMPLETED, BlueprintBasedUpgradeOption.UPGRADE_ENABLED));
StackViewV4Response dataHubStack3 = createStackResponse(Status.STOPPED, "stack-3", "stack-crn-3");
dataHubStack3.setCluster(createClusterResponse(Status.STOPPED, BlueprintBasedUpgradeOption.UPGRADE_ENABLED));
StackViewV4Responses stackViewV4Responses = new StackViewV4Responses(Set.of(dataHubStack1, dataHubStack2, dataHubStack3));
String actual = underTest.checkForRunningAttachedClusters(stackViewV4Responses, new Stack());
String actualNonUpgradeable = underTest.checkForNonUpgradeableAttachedClusters(stackViewV4Responses);
assertEquals("", actual);
assertEquals("", actualNonUpgradeable);
verifyNoInteractions(spotInstanceUsageCondition);
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Responses in project cloudbreak by hortonworks.
the class UpgradeServiceTest method upgradeNotAllowedWhenConnectedDataHubClusterIsAvailable.
@Test
public void upgradeNotAllowedWhenConnectedDataHubClusterIsAvailable() throws CloudbreakImageNotFoundException, CloudbreakImageCatalogException {
Stack stack = getStack();
Image image = getImage("id-1");
setUpMocks(stack, image, true, "id-1", "id-2");
Result<Map<HostGroupName, Set<InstanceMetaData>>, RepairValidation> repairStartResult = Result.success(new HashMap<>());
when(clusterRepairService.repairWithDryRun(1L)).thenReturn(repairStartResult);
StackViewV4Response stackViewV4Response = new StackViewV4Response();
stackViewV4Response.setStatus(Status.STOPPED);
ClusterViewV4Response clusterViewV4Response = new ClusterViewV4Response();
clusterViewV4Response.setStatus(Status.AVAILABLE);
stackViewV4Response.setCluster(clusterViewV4Response);
when(distroXV1Endpoint.list(any(), anyString())).thenReturn(new StackViewV4Responses(Set.of(stackViewV4Response)));
when(stackService.getByNameOrCrnInWorkspace(eq(ofName), eq(WORKSPACE_ID))).thenReturn(stack);
UpgradeOptionV4Response result = underTest.getOsUpgradeOptionByStackNameOrCrn(WORKSPACE_ID, ofName, user);
verify(clusterRepairService).repairWithDryRun(eq(stack.getId()));
verify(distroXV1Endpoint).list(eq(null), eq("env-crn"));
verify(componentConfigProviderService).getImage(1L);
verify(imageService).determineImageFromCatalog(eq(WORKSPACE_ID), captor.capture(), eq("aws"), eq("AWS"), eq(stack.getCluster().getBlueprint()), eq(false), eq(false), eq(user), any());
assertThat(result.getUpgrade().getImageName()).isEqualTo("id-2");
assertThat(result.getReason()).isEqualTo("Please stop connected DataHub clusters before upgrade.");
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Responses in project cloudbreak by hortonworks.
the class UpgradeServiceTest method upgradeNotAllowedWhenConnectedDataHubStackIsAvailable.
@Test
public void upgradeNotAllowedWhenConnectedDataHubStackIsAvailable() throws CloudbreakImageNotFoundException, CloudbreakImageCatalogException {
Stack stack = getStack();
Image image = getImage("id-1");
setUpMocks(stack, image, true, "id-1", "id-2");
Result<Map<HostGroupName, Set<InstanceMetaData>>, RepairValidation> repairStartResult = Result.success(new HashMap<>());
when(clusterRepairService.repairWithDryRun(1L)).thenReturn(repairStartResult);
StackViewV4Response stackViewV4Response = new StackViewV4Response();
stackViewV4Response.setStatus(Status.AVAILABLE);
when(distroXV1Endpoint.list(any(), anyString())).thenReturn(new StackViewV4Responses(Set.of(stackViewV4Response)));
when(stackService.getByNameOrCrnInWorkspace(eq(ofName), eq(WORKSPACE_ID))).thenReturn(stack);
UpgradeOptionV4Response result = underTest.getOsUpgradeOptionByStackNameOrCrn(WORKSPACE_ID, ofName, user);
verify(clusterRepairService).repairWithDryRun(eq(stack.getId()));
verify(distroXV1Endpoint).list(eq(null), eq("env-crn"));
verify(componentConfigProviderService).getImage(1L);
verify(imageService).determineImageFromCatalog(eq(WORKSPACE_ID), captor.capture(), eq("aws"), eq("AWS"), eq(stack.getCluster().getBlueprint()), eq(false), eq(false), eq(user), any());
assertThat(result.getUpgrade().getImageName()).isEqualTo("id-2");
assertThat(result.getReason()).isEqualTo("Please stop connected DataHub clusters before upgrade.");
}
Aggregations