Search in sources :

Example 6 with StackStatus

use of com.sequenceiq.freeipa.entity.StackStatus in project cloudbreak by hortonworks.

the class FreeIpaDeletionServiceTest method setUp.

@BeforeEach
void setUp() {
    stack = new Stack();
    stack.setId(STACK_ID);
    stack.setName(STACK_NAME);
    StackStatus stackStatus = new StackStatus();
    stackStatus.setStatus(Status.AVAILABLE);
    stack.setStackStatus(stackStatus);
}
Also used : StackStatus(com.sequenceiq.freeipa.entity.StackStatus) Stack(com.sequenceiq.freeipa.entity.Stack) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 7 with StackStatus

use of com.sequenceiq.freeipa.entity.StackStatus in project cloudbreak by hortonworks.

the class FreeIpaDescribeServiceTest method setUp.

@BeforeEach
void setUp() {
    stack = new Stack();
    stack.setId(STACK_ID);
    stack.setName(STACK_NAME);
    StackStatus stackStatus = new StackStatus();
    stackStatus.setStatus(Status.AVAILABLE);
    stack.setStackStatus(stackStatus);
}
Also used : StackStatus(com.sequenceiq.freeipa.entity.StackStatus) Stack(com.sequenceiq.freeipa.entity.Stack) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 8 with StackStatus

use of com.sequenceiq.freeipa.entity.StackStatus in project cloudbreak by hortonworks.

the class UpgradeValidationServiceTest method testStackNotAvailable.

@Test
public void testStackNotAvailable() {
    Stack stack = mock(Stack.class);
    when(stack.isAvailable()).thenReturn(Boolean.FALSE);
    StackStatus stackStatus = new StackStatus();
    stackStatus.setStatus(Status.DELETED_ON_PROVIDER_SIDE);
    when(stack.getStackStatus()).thenReturn(stackStatus);
    Set<InstanceMetaData> allInstances = Set.of(createAvailableInstance("im1"), createAvailableInstance("im2"));
    assertThrows(BadRequestException.class, () -> underTest.validateStackForUpgrade(allInstances, stack));
}
Also used : InstanceMetaData(com.sequenceiq.freeipa.entity.InstanceMetaData) StackStatus(com.sequenceiq.freeipa.entity.StackStatus) Stack(com.sequenceiq.freeipa.entity.Stack) Test(org.junit.jupiter.api.Test)

Example 9 with StackStatus

use of com.sequenceiq.freeipa.entity.StackStatus in project cloudbreak by hortonworks.

the class FreeIpaClientFactoryTest method getFreeIpaClientForStackShouldReturnClientWhenStackStatusIsValid.

@Test
void getFreeIpaClientForStackShouldReturnClientWhenStackStatusIsValid() throws FreeIpaClientException {
    Stack stack = createStack();
    stack.setGatewayport(80);
    FreeIpa freeIpa = new FreeIpa();
    freeIpa.setAdminPassword(new Secret("", ""));
    when(freeIpaService.findByStack(stack)).thenReturn(freeIpa);
    when(stackService.getByIdWithListsInTransaction(stack.getId())).thenReturn(stack);
    when(tlsSecurityService.buildTLSClientConfig(any(), any(), any())).thenReturn(new HttpClientConfig(FREEIPP_FQDN));
    Status unreachableState = Status.AVAILABLE;
    StackStatus stackStatus = new StackStatus(stack, unreachableState, "The FreeIPA instance is reachable.", DetailedStackStatus.AVAILABLE);
    stack.setStackStatus(stackStatus);
    when(clusterProxyService.isCreateConfigForClusterProxy(stack)).thenReturn(false);
    FreeIpaClientException exception = Assertions.assertThrows(FreeIpaClientException.class, () -> underTest.getFreeIpaClientForStack(stack));
    verify(clusterProxyService, times(1)).isCreateConfigForClusterProxy(stack);
    verify(tlsSecurityService, times(1)).buildTLSClientConfig(any(), any(), any());
    Assertions.assertEquals(FreeIpaClientException.class, exception.getCause().getClass());
}
Also used : Secret(com.sequenceiq.cloudbreak.service.secret.domain.Secret) StackStatus(com.sequenceiq.freeipa.entity.StackStatus) InstanceStatus(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceStatus) Status(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.Status) DetailedStackStatus(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.DetailedStackStatus) HttpClientConfig(com.sequenceiq.cloudbreak.client.HttpClientConfig) FreeIpa(com.sequenceiq.freeipa.entity.FreeIpa) StackStatus(com.sequenceiq.freeipa.entity.StackStatus) DetailedStackStatus(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.DetailedStackStatus) FreeIpaClientException(com.sequenceiq.freeipa.client.FreeIpaClientException) Stack(com.sequenceiq.freeipa.entity.Stack) Test(org.junit.jupiter.api.Test)

Example 10 with StackStatus

use of com.sequenceiq.freeipa.entity.StackStatus in project cloudbreak by hortonworks.

the class FreeIpaClientFactoryTest method getFreeIpaClientForStackForLegacyHealthCheckShouldReturnClientWhenStackStatusIsUnreachable.

@Test
void getFreeIpaClientForStackForLegacyHealthCheckShouldReturnClientWhenStackStatusIsUnreachable() {
    Stack stack = createStack();
    stack.setGatewayport(80);
    FreeIpa freeIpa = new FreeIpa();
    freeIpa.setAdminPassword(new Secret("", ""));
    when(freeIpaService.findByStack(stack)).thenReturn(freeIpa);
    when(stackService.getByIdWithListsInTransaction(stack.getId())).thenReturn(stack);
    when(tlsSecurityService.buildTLSClientConfig(any(), any(), any())).thenReturn(new HttpClientConfig(FREEIPP_FQDN));
    Status unreachableState = Status.FREEIPA_UNREACHABLE_STATUSES.stream().findAny().get();
    StackStatus stackStatus = new StackStatus(stack, unreachableState, "The FreeIPA instance is unreachable.", DetailedStackStatus.UNREACHABLE);
    stack.setStackStatus(stackStatus);
    FreeIpaClientException exception = Assertions.assertThrows(FreeIpaClientException.class, () -> underTest.getFreeIpaClientForStackForLegacyHealthCheck(stack, FREEIPP_FQDN));
    verify(clusterProxyService, times(1)).isCreateConfigForClusterProxy(stack);
    verify(tlsSecurityService, times(1)).buildTLSClientConfig(any(), any(), any());
    Assertions.assertEquals(FreeIpaClientException.class, exception.getCause().getClass());
}
Also used : Secret(com.sequenceiq.cloudbreak.service.secret.domain.Secret) StackStatus(com.sequenceiq.freeipa.entity.StackStatus) InstanceStatus(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceStatus) Status(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.Status) DetailedStackStatus(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.DetailedStackStatus) HttpClientConfig(com.sequenceiq.cloudbreak.client.HttpClientConfig) FreeIpa(com.sequenceiq.freeipa.entity.FreeIpa) StackStatus(com.sequenceiq.freeipa.entity.StackStatus) DetailedStackStatus(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.DetailedStackStatus) FreeIpaClientException(com.sequenceiq.freeipa.client.FreeIpaClientException) Stack(com.sequenceiq.freeipa.entity.Stack) Test(org.junit.jupiter.api.Test)

Aggregations

StackStatus (com.sequenceiq.freeipa.entity.StackStatus)24 Stack (com.sequenceiq.freeipa.entity.Stack)17 DetailedStackStatus (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.DetailedStackStatus)14 Test (org.junit.jupiter.api.Test)9 Status (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.Status)5 InstanceStatus (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceStatus)5 FreeIpa (com.sequenceiq.freeipa.entity.FreeIpa)4 InstanceGroup (com.sequenceiq.freeipa.entity.InstanceGroup)4 HttpClientConfig (com.sequenceiq.cloudbreak.client.HttpClientConfig)3 Secret (com.sequenceiq.cloudbreak.service.secret.domain.Secret)3 FreeIpaClientException (com.sequenceiq.freeipa.client.FreeIpaClientException)3 InstanceMetaData (com.sequenceiq.freeipa.entity.InstanceMetaData)3 StackDetails (com.sequenceiq.cloudbreak.structuredevent.event.StackDetails)2 CDPOperationDetails (com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPOperationDetails)2 HashSet (java.util.HashSet)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2 StackTags (com.sequenceiq.cloudbreak.cloud.model.StackTags)1 AwsInstanceTemplate (com.sequenceiq.cloudbreak.cloud.model.instance.AwsInstanceTemplate)1 Json (com.sequenceiq.cloudbreak.common.json.Json)1 CDPStructuredFlowEvent (com.sequenceiq.cloudbreak.structuredevent.event.cdp.CDPStructuredFlowEvent)1