use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.views.ClusterViewV4Response in project cloudbreak by hortonworks.
the class UpgradeServiceTest method upgradeAllowedWhenConnectedDataHubStackAndClusterStoppedOrDeleted.
@Test
public void upgradeAllowedWhenConnectedDataHubStackAndClusterStoppedOrDeleted() 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 datahubStack1 = new StackViewV4Response();
datahubStack1.setStatus(Status.STOPPED);
ClusterViewV4Response datahubCluster1 = new ClusterViewV4Response();
datahubCluster1.setStatus(Status.STOPPED);
datahubStack1.setCluster(datahubCluster1);
StackViewV4Response datahubStack2 = new StackViewV4Response();
datahubStack2.setStatus(Status.DELETE_COMPLETED);
ClusterViewV4Response datahubCluster2 = new ClusterViewV4Response();
datahubCluster2.setStatus(Status.DELETE_COMPLETED);
datahubStack2.setCluster(datahubCluster2);
StackViewV4Response datahubStack3 = new StackViewV4Response();
datahubStack3.setStatus(Status.STOPPED);
when(distroXV1Endpoint.list(any(), anyString())).thenReturn(new StackViewV4Responses(Set.of(datahubStack1, datahubStack2, datahubStack3)));
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(null);
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.views.ClusterViewV4Response in project cloudbreak by hortonworks.
the class UpgradePreconditionServiceTest method createClusterResponse.
private ClusterViewV4Response createClusterResponse(Status clusterStatus, BlueprintBasedUpgradeOption upgradeable) {
ClusterViewV4Response dataHubCluster = new ClusterViewV4Response();
dataHubCluster.setStatus(clusterStatus);
BlueprintV4ViewResponse blueprint = new BlueprintV4ViewResponse();
blueprint.setUpgradeable(upgradeable);
dataHubCluster.setBlueprint(blueprint);
return dataHubCluster;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.views.ClusterViewV4Response 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.views.ClusterViewV4Response in project cloudbreak by hortonworks.
the class ClusterApiViewToClusterViewV4ResponseConverter method convert.
public ClusterViewV4Response convert(ClusterApiView source) {
ClusterViewV4Response clusterViewResponse = new ClusterViewV4Response();
clusterViewResponse.setName(source.getName());
clusterViewResponse.setDescription(source.getDescription());
clusterViewResponse.setId(source.getId());
clusterViewResponse.setServerIp(source.getClusterManagerIp());
clusterViewResponse.setBlueprint(blueprintViewToBlueprintV4ViewResponseConverter.convert(source.getBlueprint()));
clusterViewResponse.setStatus(source.getStatus());
clusterViewResponse.setHostGroups(convertHostGroupsToJson(source.getHostGroups()));
clusterViewResponse.setCertExpirationState(source.getCertExpirationState());
datalakeService.addSharedServiceResponse(source, clusterViewResponse);
return clusterViewResponse;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.views.ClusterViewV4Response in project cloudbreak by hortonworks.
the class DatalakeService method addSharedServiceResponse.
public void addSharedServiceResponse(ClusterApiView cluster, ClusterViewV4Response clusterResponse) {
SharedServiceV4Response sharedServiceResponse = new SharedServiceV4Response();
if (cluster.getStack().getDatalakeCrn() != null) {
LOGGER.debug("Add shared service response by datalakeCrn");
Optional<ResourceBasicView> datalakeStack = stackService.getResourceBasicViewByResourceCrn(cluster.getStack().getDatalakeCrn());
datalakeStack.ifPresent(s -> {
sharedServiceResponse.setSharedClusterId(s.getId());
sharedServiceResponse.setSharedClusterName(s.getName());
});
}
clusterResponse.setSharedServiceResponse(sharedServiceResponse);
}
Aggregations