use of com.sequenceiq.freeipa.entity.Stack in project cloudbreak by hortonworks.
the class FreeIpaInstanceHealthDetailsServiceTest method testGetInstanceHealthDetailsLegacyUnhealthyNode.
@Test
public void testGetInstanceHealthDetailsLegacyUnhealthyNode() throws Exception {
FreeIpaClient mockIpaClient = Mockito.mock(FreeIpaClient.class);
Mockito.when(healthCheckAvailabilityChecker.isCdpFreeIpaHeathAgentAvailable(any())).thenReturn(false);
Mockito.when(mockIpaClient.getHostname()).thenReturn(HOST);
Mockito.when(freeIpaClientFactory.getFreeIpaClientForStackForLegacyHealthCheck(any(), any())).thenReturn(mockIpaClient);
Mockito.when(mockIpaClient.serverConnCheck(anyString(), anyString())).thenReturn(getLegacyErrorPayload(HOST));
InstanceMetaData instanceMetaData = getInstance();
Stack stack = getStack(Set.of(instanceMetaData));
NodeHealthDetails response = underTest.getInstanceHealthDetails(stack, instanceMetaData);
assertEquals(InstanceStatus.UNHEALTHY, response.getStatus());
assertEquals(INSTANCE_ID, response.getInstanceId());
assertEquals(HOST, response.getName());
assertFalse(response.getIssues().isEmpty());
}
use of com.sequenceiq.freeipa.entity.Stack in project cloudbreak by hortonworks.
the class FreeIpaInstanceHealthDetailsServiceTest method testGetInstanceHealthDetailsUnresponsiveNodeThrows.
@Test
public void testGetInstanceHealthDetailsUnresponsiveNodeThrows() 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.getInstanceHealthDetails(stack, instanceMetaData));
}
use of com.sequenceiq.freeipa.entity.Stack in project cloudbreak by hortonworks.
the class FreeIpaInstanceHealthDetailsServiceTest method testGetInstanceHealthDetailsLegacyUnresponsiveNodeThrows.
@Test
public void testGetInstanceHealthDetailsLegacyUnresponsiveNodeThrows() throws Exception {
FreeIpaClient mockIpaClient = Mockito.mock(FreeIpaClient.class);
Mockito.when(healthCheckAvailabilityChecker.isCdpFreeIpaHeathAgentAvailable(any())).thenReturn(false);
Mockito.when(mockIpaClient.getHostname()).thenReturn(HOST);
Mockito.when(freeIpaClientFactory.getFreeIpaClientForStackForLegacyHealthCheck(any(), any())).thenReturn(mockIpaClient);
Mockito.when(mockIpaClient.serverConnCheck(anyString(), anyString())).thenThrow(ipaClientException);
InstanceMetaData instanceMetaData = getInstance();
Stack stack = getStack(Set.of(instanceMetaData));
Assert.assertThrows(FreeIpaClientException.class, () -> underTest.getInstanceHealthDetails(stack, instanceMetaData));
}
use of com.sequenceiq.freeipa.entity.Stack in project cloudbreak by hortonworks.
the class FreeIpaInstanceHealthDetailsServiceTest method testCheckLegacyFreeIpaHealthThrowsWhenFqdnIsMissing.
@Test
public void testCheckLegacyFreeIpaHealthThrowsWhenFqdnIsMissing() {
Mockito.when(healthCheckAvailabilityChecker.isCdpFreeIpaHeathAgentAvailable(any())).thenReturn(false);
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 FreeIpaRecommendationServiceTest method createStack.
private Stack createStack(String instanceType) {
Stack stack = new Stack();
stack.setCloudPlatform("AWS");
stack.setRegion("eu-central-1");
InstanceGroup instanceGroup = new InstanceGroup();
instanceGroup.setGroupName("master");
Template template = new Template();
template.setInstanceType(instanceType);
instanceGroup.setTemplate(template);
stack.getInstanceGroups().add(instanceGroup);
return stack;
}
Aggregations