Search in sources :

Example 31 with StackViewV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Response 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 32 with StackViewV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Response 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.");
}
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) 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 33 with StackViewV4Response

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Response in project cloudbreak by hortonworks.

the class StackApiViewToStackViewV4ResponseConverter method addUser.

private void addUser(StackApiView source, StackViewV4Response stackJson) {
    if (source.getUserView() != null) {
        try {
            UserViewV4Response userViewResponse = userViewToUserViewV4ResponseConverter.convert(source.getUserView());
            stackJson.setUser(userViewResponse);
        } catch (Exception ex) {
            LOGGER.warn("User could not be added to stack response.", ex);
        }
    }
}
Also used : UserViewV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.views.UserViewV4Response)

Aggregations

StackViewV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Response)32 StackViewV4Responses (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Responses)18 Test (org.junit.jupiter.api.Test)13 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)10 Test (org.junit.Test)8 NameOrCrn (com.sequenceiq.cloudbreak.api.endpoint.v4.dto.NameOrCrn)6 UpgradeOptionV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.upgrade.UpgradeOptionV4Response)3 Image (com.sequenceiq.cloudbreak.cloud.model.Image)3 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)3 InstanceMetaData (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData)3 RepairValidation (com.sequenceiq.cloudbreak.service.cluster.model.RepairValidation)3 StatedImage (com.sequenceiq.cloudbreak.service.image.StatedImage)3 SdxCluster (com.sequenceiq.datalake.entity.SdxCluster)3 DistroXMultiDeleteV1Request (com.sequenceiq.distrox.api.v1.distrox.model.cluster.DistroXMultiDeleteV1Request)3 CredentialResponse (com.sequenceiq.environment.api.v1.credential.model.response.CredentialResponse)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)3 ClusterViewV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.views.ClusterViewV4Response)2 StackApiView (com.sequenceiq.cloudbreak.domain.view.StackApiView)2