use of com.sequenceiq.freeipa.entity.Stack in project cloudbreak by hortonworks.
the class FreeIpaInstanceHealthDetailsServiceTest method getStack.
private Stack getStack(Set<InstanceMetaData> instanceMetaData) {
Stack stack = new Stack();
stack.setResourceCrn(ENVIRONMENT_ID);
InstanceGroup instanceGroup = new InstanceGroup();
stack.getInstanceGroups().add(instanceGroup);
instanceGroup.setInstanceGroupType(InstanceGroupType.MASTER);
instanceGroup.setInstanceMetaData(instanceMetaData);
return stack;
}
use of com.sequenceiq.freeipa.entity.Stack 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));
}
use of com.sequenceiq.freeipa.entity.Stack 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());
}
use of com.sequenceiq.freeipa.entity.Stack 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));
}
use of com.sequenceiq.freeipa.entity.Stack 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());
}
Aggregations