Search in sources :

Example 6 with NameOrCrn

use of com.sequenceiq.cloudbreak.api.endpoint.v4.dto.NameOrCrn in project cloudbreak by hortonworks.

the class ClusterCommonServiceTest method testRotateAutoTlsCertificatesWithNodeFailure.

@Test
public void testRotateAutoTlsCertificatesWithNodeFailure() {
    NameOrCrn cluster = NameOrCrn.ofName("cluster");
    Stack stack = new Stack();
    stack.setName("cluster");
    stack.setStackStatus(new StackStatus(stack, NODE_FAILURE));
    when(stackService.getByNameOrCrnInWorkspace(cluster, 1L)).thenReturn(stack);
    CertificatesRotationV4Request certificatesRotationV4Request = new CertificatesRotationV4Request();
    BadRequestException badRequestException = assertThrows(BadRequestException.class, () -> underTest.rotateAutoTlsCertificates(cluster, 1L, certificatesRotationV4Request));
    assertEquals("Stack 'cluster' is currently in 'NODE_FAILURE' state. Certificates rotation can only be made when the underlying stack is 'AVAILABLE'.", badRequestException.getMessage());
}
Also used : StackStatus(com.sequenceiq.cloudbreak.domain.stack.StackStatus) CertificatesRotationV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.CertificatesRotationV4Request) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) NameOrCrn(com.sequenceiq.cloudbreak.api.endpoint.v4.dto.NameOrCrn) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.jupiter.api.Test)

Example 7 with NameOrCrn

use of com.sequenceiq.cloudbreak.api.endpoint.v4.dto.NameOrCrn in project cloudbreak by hortonworks.

the class StackOperationsTest method testChangeImageCatalogThrowsExceptionWhenFlowInProgress.

@Test
public void testChangeImageCatalogThrowsExceptionWhenFlowInProgress() {
    NameOrCrn nameOrCrn = NameOrCrn.ofName(stack.getName());
    when(stackService.getByNameOrCrnInWorkspace(nameOrCrn, stack.getWorkspace().getId())).thenReturn(stack);
    when(flowLogService.isOtherFlowRunning(stack.getId())).thenReturn(true);
    assertThrows(CloudbreakServiceException.class, () -> underTest.changeImageCatalog(nameOrCrn, stack.getWorkspace().getId(), IMAGE_CATALOG));
}
Also used : NameOrCrn(com.sequenceiq.cloudbreak.api.endpoint.v4.dto.NameOrCrn) Test(org.junit.Test)

Example 8 with NameOrCrn

use of com.sequenceiq.cloudbreak.api.endpoint.v4.dto.NameOrCrn in project cloudbreak by hortonworks.

the class StackOperationsTest method testGenerateImageCatalog.

@Test
public void testGenerateImageCatalog() {
    NameOrCrn nameOrCrn = NameOrCrn.ofName(stack.getName());
    CloudbreakImageCatalogV3 imageCatalog = mock(CloudbreakImageCatalogV3.class);
    when(stackService.getByNameOrCrnInWorkspace(nameOrCrn, stack.getWorkspace().getId())).thenReturn(stack);
    when(generateImageCatalogService.generateImageCatalogForStack(stack)).thenReturn(imageCatalog);
    CloudbreakImageCatalogV3 actual = underTest.generateImageCatalog(nameOrCrn, stack.getWorkspace().getId());
    assertEquals(imageCatalog, actual);
}
Also used : CloudbreakImageCatalogV3(com.sequenceiq.cloudbreak.cloud.model.catalog.CloudbreakImageCatalogV3) NameOrCrn(com.sequenceiq.cloudbreak.api.endpoint.v4.dto.NameOrCrn) Test(org.junit.Test)

Example 9 with NameOrCrn

use of com.sequenceiq.cloudbreak.api.endpoint.v4.dto.NameOrCrn in project cloudbreak by hortonworks.

the class StackOperationsTest method testGetWhenNameOrCrnCrnFilledThenProperGetCalled.

@Test
public void testGetWhenNameOrCrnCrnFilledThenProperGetCalled() {
    StackV4Response expected = stackResponse();
    NameOrCrn nameOrCrn = NameOrCrn.ofCrn(stack.getResourceCrn());
    when(stackCommonService.findStackByNameOrCrnAndWorkspaceId(nameOrCrn, stack.getWorkspace().getId(), STACK_ENTRIES, STACK_TYPE)).thenReturn(expected);
    StackV4Response result = underTest.get(nameOrCrn, stack.getWorkspace().getId(), STACK_ENTRIES, STACK_TYPE);
    assertEquals(expected, result);
    verify(stackCommonService, times(1)).findStackByNameOrCrnAndWorkspaceId(nameOrCrn, stack.getWorkspace().getId(), STACK_ENTRIES, STACK_TYPE);
}
Also used : StackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response) NameOrCrn(com.sequenceiq.cloudbreak.api.endpoint.v4.dto.NameOrCrn) Test(org.junit.Test)

Example 10 with NameOrCrn

use of com.sequenceiq.cloudbreak.api.endpoint.v4.dto.NameOrCrn in project cloudbreak by hortonworks.

the class DistroXUpgradeV1Controller method upgradeCluster.

private DistroXUpgradeV1Response upgradeCluster(String clusterNameOrCrn, DistroXUpgradeV1Request distroxUpgradeRequest, NameOrCrn nameOrCrn, InternalUpgradeSettings internalUpgradeSettings) {
    String userCrn = ThreadBasedUserCrnProvider.getUserCrn();
    UpgradeV4Request request = upgradeConverter.convert(distroxUpgradeRequest, internalUpgradeSettings);
    Long workspaceId = restRequestThreadLocalService.getRequestedWorkspaceId();
    if (request.isDryRun() || request.isShowAvailableImagesSet()) {
        LOGGER.info("Checking for upgrade for cluster [{}] with request: {}", clusterNameOrCrn, request);
        UpgradeV4Response upgradeV4Response = upgradeAvailabilityService.checkForUpgrade(nameOrCrn, workspaceId, request, userCrn);
        return upgradeConverter.convert(upgradeV4Response);
    } else {
        LOGGER.info("Triggering upgrade for cluster [{}] with request: {}", clusterNameOrCrn, request);
        UpgradeV4Response upgradeV4Response = upgradeService.triggerUpgrade(nameOrCrn, workspaceId, userCrn, request);
        return upgradeConverter.convert(upgradeV4Response);
    }
}
Also used : UpgradeV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.upgrade.UpgradeV4Response) UpgradeV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.tags.upgrade.UpgradeV4Request)

Aggregations

NameOrCrn (com.sequenceiq.cloudbreak.api.endpoint.v4.dto.NameOrCrn)19 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)11 Test (org.junit.Test)8 StackViewV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Response)7 Test (org.junit.jupiter.api.Test)6 UpgradeV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.upgrade.UpgradeV4Response)4 FlowIdentifier (com.sequenceiq.flow.api.model.FlowIdentifier)4 UpdateStackV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.autoscales.request.UpdateStackV4Request)3 CertificatesRotationV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.CertificatesRotationV4Request)3 InternalUpgradeSettings (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.InternalUpgradeSettings)3 StackV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response)3 StackViewV4Responses (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackViewV4Responses)3 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)3 StackStatus (com.sequenceiq.cloudbreak.domain.stack.StackStatus)3 InternalOnly (com.sequenceiq.authorization.annotation.InternalOnly)2 UpdateClusterV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.UpdateClusterV4Request)2 ImageInfoV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.image.ImageInfoV4Response)2 CredentialResponse (com.sequenceiq.environment.api.v1.credential.model.response.CredentialResponse)2 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)2 StackImageChangeV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackImageChangeV4Request)1