Search in sources :

Example 16 with InstanceMetaData

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

the class RepairInstancesServiceTest method createStack.

private Stack createStack(Status stackStatus, List<InstanceStatus> instanceStatuses, int requestedInstancesWithoutInstanceIds) {
    Stack stack = new Stack();
    stack.setId(STACK_ID);
    stack.setEnvironmentCrn(ENVIRONMENT_ID1);
    StackStatus s = new StackStatus();
    s.setStatus(stackStatus);
    stack.setStackStatus(s);
    int i = 1;
    Set<InstanceMetaData> instanceMetaDataSet = new HashSet<>();
    for (InstanceStatus instanceStatus : instanceStatuses) {
        InstanceMetaData instanceMetaData = new InstanceMetaData();
        instanceMetaData.setInstanceId("i-" + i);
        instanceMetaData.setInstanceStatus(instanceStatus);
        instanceMetaDataSet.add(instanceMetaData);
        i++;
    }
    for (i = 0; i < requestedInstancesWithoutInstanceIds; i++) {
        InstanceMetaData instanceMetaData = new InstanceMetaData();
        instanceMetaData.setInstanceStatus(InstanceStatus.REQUESTED);
        instanceMetaDataSet.add(instanceMetaData);
    }
    InstanceGroup instanceGroup = new InstanceGroup();
    instanceGroup.setInstanceMetaData(instanceMetaDataSet);
    instanceGroup.setNodeCount(instanceMetaDataSet.size());
    stack.setInstanceGroups(Set.of(instanceGroup));
    return stack;
}
Also used : InstanceMetaData(com.sequenceiq.freeipa.entity.InstanceMetaData) InstanceStatus(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.instance.InstanceStatus) DetailedStackStatus(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.common.DetailedStackStatus) StackStatus(com.sequenceiq.freeipa.entity.StackStatus) Stack(com.sequenceiq.freeipa.entity.Stack) HashSet(java.util.HashSet) InstanceGroup(com.sequenceiq.freeipa.entity.InstanceGroup)

Example 17 with InstanceMetaData

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

the class FreeIpaInstanceHealthDetailsServiceTest method testCheckFreeIpaHealthUnresponsiveNodeThrows.

@Test
public void testCheckFreeIpaHealthUnresponsiveNodeThrows() throws Exception {
    FreeIpaHealthCheckClient mockIpaHealthClient = Mockito.mock(FreeIpaHealthCheckClient.class);
    Mockito.when(healthCheckAvailabilityChecker.isCdpFreeIpaHeathAgentAvailable(any())).thenReturn(true);
    Mockito.when(freeIpaHealthCheckClientFactory.getClient(any(), any())).thenReturn(mockIpaHealthClient);
    Mockito.when(mockIpaHealthClient.nodeHealth()).thenThrow(ipaClientException);
    InstanceMetaData instanceMetaData = getInstance();
    Stack stack = getStack(Set.of(instanceMetaData));
    Assert.assertThrows(FreeIpaClientException.class, () -> underTest.checkFreeIpaHealth(stack, instanceMetaData));
}
Also used : InstanceMetaData(com.sequenceiq.freeipa.entity.InstanceMetaData) FreeIpaHealthCheckClient(com.sequenceiq.freeipa.client.FreeIpaHealthCheckClient) Stack(com.sequenceiq.freeipa.entity.Stack) Test(org.junit.jupiter.api.Test)

Example 18 with InstanceMetaData

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

the class FreeIpaInstanceHealthDetailsServiceTest method testGetInstanceHealthDetailsHealthyNode.

@Test
public void testGetInstanceHealthDetailsHealthyNode() throws Exception {
    FreeIpaHealthCheckClient mockIpaHealthClient = Mockito.mock(FreeIpaHealthCheckClient.class);
    Mockito.when(healthCheckAvailabilityChecker.isCdpFreeIpaHeathAgentAvailable(any())).thenReturn(true);
    Mockito.when(freeIpaHealthCheckClientFactory.getClient(any(), any())).thenReturn(mockIpaHealthClient);
    Mockito.when(mockIpaHealthClient.nodeHealth()).thenReturn(getGoodPayload(HOST));
    InstanceMetaData instanceMetaData = getInstance();
    Stack stack = getStack(Set.of(instanceMetaData));
    NodeHealthDetails response = underTest.getInstanceHealthDetails(stack, instanceMetaData);
    assertEquals(InstanceStatus.CREATED, response.getStatus());
    assertEquals(INSTANCE_ID, response.getInstanceId());
    assertEquals(HOST, response.getName());
    Assertions.assertTrue(response.getIssues().isEmpty());
}
Also used : InstanceMetaData(com.sequenceiq.freeipa.entity.InstanceMetaData) FreeIpaHealthCheckClient(com.sequenceiq.freeipa.client.FreeIpaHealthCheckClient) NodeHealthDetails(com.sequenceiq.freeipa.api.v1.freeipa.stack.model.health.NodeHealthDetails) Stack(com.sequenceiq.freeipa.entity.Stack) Test(org.junit.jupiter.api.Test)

Example 19 with InstanceMetaData

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

the class FreeIpaInstanceHealthDetailsServiceTest method testCheckFreeIpaHealthThrowsWhenFqdnIsMissing.

@Test
public void testCheckFreeIpaHealthThrowsWhenFqdnIsMissing() {
    Mockito.when(healthCheckAvailabilityChecker.isCdpFreeIpaHeathAgentAvailable(any())).thenReturn(true);
    InstanceMetaData instanceMetaData = getInstance();
    instanceMetaData.setDiscoveryFQDN(null);
    Stack stack = getStack(Set.of(instanceMetaData));
    Assert.assertThrows(FreeIpaClientException.class, () -> underTest.checkFreeIpaHealth(stack, instanceMetaData));
}
Also used : InstanceMetaData(com.sequenceiq.freeipa.entity.InstanceMetaData) Stack(com.sequenceiq.freeipa.entity.Stack) Test(org.junit.jupiter.api.Test)

Example 20 with InstanceMetaData

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

the class FreeIpaInstanceHealthDetailsServiceTest method testCheckFreeIpaHealthLegacyHealthyNode.

@Test
public void testCheckFreeIpaHealthLegacyHealthyNode() throws Exception {
    FreeIpaClient mockIpaClient = Mockito.mock(FreeIpaClient.class);
    Mockito.when(healthCheckAvailabilityChecker.isCdpFreeIpaHeathAgentAvailable(any())).thenReturn(false);
    Mockito.when(mockIpaClient.getHostname()).thenReturn("test.host");
    Mockito.when(freeIpaClientFactory.getFreeIpaClientForStackForLegacyHealthCheck(any(), any())).thenReturn(mockIpaClient);
    Mockito.when(mockIpaClient.serverConnCheck(anyString(), anyString())).thenReturn(getLegacyGoodPayload(HOST));
    InstanceMetaData instanceMetaData = getInstance();
    Stack stack = getStack(Set.of(instanceMetaData));
    RPCResponse<Boolean> response = underTest.checkFreeIpaHealth(stack, instanceMetaData);
    Assertions.assertTrue(response.getResult());
}
Also used : InstanceMetaData(com.sequenceiq.freeipa.entity.InstanceMetaData) FreeIpaClient(com.sequenceiq.freeipa.client.FreeIpaClient) Stack(com.sequenceiq.freeipa.entity.Stack) Test(org.junit.jupiter.api.Test)

Aggregations

InstanceMetaData (com.sequenceiq.freeipa.entity.InstanceMetaData)163 Stack (com.sequenceiq.freeipa.entity.Stack)104 Test (org.junit.jupiter.api.Test)77 InstanceGroup (com.sequenceiq.freeipa.entity.InstanceGroup)30 List (java.util.List)19 Logger (org.slf4j.Logger)19 LoggerFactory (org.slf4j.LoggerFactory)19 Map (java.util.Map)18 Collectors (java.util.stream.Collectors)18 Inject (javax.inject.Inject)18 Set (java.util.Set)16 CloudInstance (com.sequenceiq.cloudbreak.cloud.model.CloudInstance)13 GatewayConfig (com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)13 Node (com.sequenceiq.cloudbreak.common.orchestration.Node)12 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)11 StackService (com.sequenceiq.freeipa.service.stack.StackService)10 ArrayList (java.util.ArrayList)10 Selectable (com.sequenceiq.cloudbreak.common.event.Selectable)9 HealthDetailsFreeIpaResponse (com.sequenceiq.freeipa.api.v1.freeipa.stack.model.health.HealthDetailsFreeIpaResponse)9 Operation (com.sequenceiq.freeipa.entity.Operation)9