Search in sources :

Example 1 with ClusterViewV4Response

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);
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) StackViewV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Response) RepairValidation(com.sequenceiq.cloudbreak.service.cluster.model.RepairValidation) UpgradeOptionV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.upgrade.UpgradeOptionV4Response) ClusterViewV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.views.ClusterViewV4Response) Image(com.sequenceiq.cloudbreak.cloud.model.Image) StatedImage(com.sequenceiq.cloudbreak.service.image.StatedImage) StackViewV4Responses(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Responses) Map(java.util.Map) HashMap(java.util.HashMap) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.jupiter.api.Test)

Example 2 with ClusterViewV4Response

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;
}
Also used : BlueprintV4ViewResponse(com.sequenceiq.cloudbreak.api.endpoint.v4.blueprint.responses.BlueprintV4ViewResponse) ClusterViewV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.views.ClusterViewV4Response)

Example 3 with ClusterViewV4Response

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.");
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) StackViewV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Response) RepairValidation(com.sequenceiq.cloudbreak.service.cluster.model.RepairValidation) UpgradeOptionV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.upgrade.UpgradeOptionV4Response) ClusterViewV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.views.ClusterViewV4Response) Image(com.sequenceiq.cloudbreak.cloud.model.Image) StatedImage(com.sequenceiq.cloudbreak.service.image.StatedImage) StackViewV4Responses(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Responses) Map(java.util.Map) HashMap(java.util.HashMap) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.jupiter.api.Test)

Example 4 with ClusterViewV4Response

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;
}
Also used : ClusterViewV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.views.ClusterViewV4Response)

Example 5 with ClusterViewV4Response

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);
}
Also used : ResourceBasicView(com.sequenceiq.cloudbreak.common.dal.ResourceBasicView) SharedServiceV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.sharedservice.SharedServiceV4Response)

Aggregations

ClusterViewV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.views.ClusterViewV4Response)4 StackViewV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Response)2 StackViewV4Responses (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Responses)2 UpgradeOptionV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.upgrade.UpgradeOptionV4Response)2 Image (com.sequenceiq.cloudbreak.cloud.model.Image)2 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)2 InstanceMetaData (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData)2 RepairValidation (com.sequenceiq.cloudbreak.service.cluster.model.RepairValidation)2 StatedImage (com.sequenceiq.cloudbreak.service.image.StatedImage)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 Test (org.junit.jupiter.api.Test)2 BlueprintV4ViewResponse (com.sequenceiq.cloudbreak.api.endpoint.v4.blueprint.responses.BlueprintV4ViewResponse)1 SharedServiceV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.sharedservice.SharedServiceV4Response)1 ResourceBasicView (com.sequenceiq.cloudbreak.common.dal.ResourceBasicView)1