Search in sources :

Example 1 with NODE_FAILURE

use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status.NODE_FAILURE in project cloudbreak by hortonworks.

the class UpdateNodeCountValidatorTest method validateClusterStatusDownscaleNodeFailureTargetedUpscaleNotSupported.

@Test
void validateClusterStatusDownscaleNodeFailureTargetedUpscaleNotSupported() {
    when(targetedUpscaleSupportService.targetedUpscaleEntitlementsEnabled(any())).thenReturn(Boolean.FALSE);
    Stack stack = new Stack();
    stack.setName("stack");
    Cluster cluster = mock(Cluster.class);
    stack.setCluster(cluster);
    stack.setStackStatus(new StackStatus(stack, DetailedStackStatus.NODE_FAILURE));
    BadRequestException e = Assertions.assertThrows(BadRequestException.class, () -> underTest.validateClusterStatus(stack, false));
    assertEquals("Data Hub 'stack' is currently in 'NODE_FAILURE' state. Node count can only be updated if it's running.", e.getMessage());
}
Also used : StackStatus(com.sequenceiq.cloudbreak.domain.stack.StackStatus) DetailedStackStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 2 with NODE_FAILURE

use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status.NODE_FAILURE in project cloudbreak by hortonworks.

the class UpdateNodeCountValidatorTest method validateClusterStatusDownscaleNodeFailureTargetedUpscaleSupported.

@Test
void validateClusterStatusDownscaleNodeFailureTargetedUpscaleSupported() {
    when(targetedUpscaleSupportService.targetedUpscaleEntitlementsEnabled(any())).thenReturn(Boolean.TRUE);
    Stack stack = new Stack();
    stack.setName("stack");
    Cluster cluster = mock(Cluster.class);
    stack.setCluster(cluster);
    stack.setStackStatus(new StackStatus(stack, DetailedStackStatus.NODE_FAILURE));
    BadRequestException e = Assertions.assertThrows(BadRequestException.class, () -> underTest.validateClusterStatus(stack, false));
    assertEquals("Data Hub 'stack' is currently in 'NODE_FAILURE' state. Node count can only be updated if it's running.", e.getMessage());
}
Also used : StackStatus(com.sequenceiq.cloudbreak.domain.stack.StackStatus) DetailedStackStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 3 with NODE_FAILURE

use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status.NODE_FAILURE 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 4 with NODE_FAILURE

use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status.NODE_FAILURE in project cloudbreak by hortonworks.

the class UpdateNodeCountValidatorTest method validateStackStatusDownscaleNodeFailureTargetedUpscaleSupported.

@Test
void validateStackStatusDownscaleNodeFailureTargetedUpscaleSupported() {
    when(targetedUpscaleSupportService.targetedUpscaleEntitlementsEnabled(any())).thenReturn(Boolean.TRUE);
    Stack stack = new Stack();
    stack.setName("stack");
    stack.setStackStatus(new StackStatus(stack, DetailedStackStatus.NODE_FAILURE));
    BadRequestException e = Assertions.assertThrows(BadRequestException.class, () -> underTest.validateStackStatus(stack, false));
    assertEquals("Data Hub 'stack' is currently in 'NODE_FAILURE' state. Node count can only be updated if it's running.", e.getMessage());
}
Also used : StackStatus(com.sequenceiq.cloudbreak.domain.stack.StackStatus) DetailedStackStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 5 with NODE_FAILURE

use of com.sequenceiq.cloudbreak.api.endpoint.v4.common.Status.NODE_FAILURE in project cloudbreak by hortonworks.

the class UpdateNodeCountValidatorTest method validateClusterStatusUpscaleNodeFailureTargetedUpscaleNotSupported.

@Test
void validateClusterStatusUpscaleNodeFailureTargetedUpscaleNotSupported() {
    when(targetedUpscaleSupportService.targetedUpscaleEntitlementsEnabled(any())).thenReturn(Boolean.FALSE);
    Stack stack = new Stack();
    stack.setName("stack");
    Cluster cluster = mock(Cluster.class);
    stack.setCluster(cluster);
    stack.setStackStatus(new StackStatus(stack, DetailedStackStatus.NODE_FAILURE));
    BadRequestException e = Assertions.assertThrows(BadRequestException.class, () -> underTest.validateClusterStatus(stack, false));
    assertEquals("Data Hub 'stack' is currently in 'NODE_FAILURE' state. Node count can only be updated if it's running.", e.getMessage());
}
Also used : StackStatus(com.sequenceiq.cloudbreak.domain.stack.StackStatus) DetailedStackStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) BadRequestException(com.sequenceiq.cloudbreak.common.exception.BadRequestException) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)7 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)7 StackStatus (com.sequenceiq.cloudbreak.domain.stack.StackStatus)7 Test (org.junit.jupiter.api.Test)7 DetailedStackStatus (com.sequenceiq.cloudbreak.api.endpoint.v4.common.DetailedStackStatus)6 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)6 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)3 NameOrCrn (com.sequenceiq.cloudbreak.api.endpoint.v4.dto.NameOrCrn)1 CertificatesRotationV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.CertificatesRotationV4Request)1