use of com.sequenceiq.cloudbreak.cluster.api.ClusterStatusService in project cloudbreak by hortonworks.
the class ClusterServiceTest method setupClusterApi.
private void setupClusterApi(Stack stack, HealthCheckResult healthCheckResult, String statusReason) {
ClusterApi connector = mock(ClusterApi.class);
ClusterStatusService clusterStatusService = mock(ClusterStatusService.class);
when(clusterStatusService.isClusterManagerRunning()).thenReturn(true);
when(connector.clusterStatusService()).thenReturn(clusterStatusService);
Map<HostName, Set<HealthCheck>> clusterManagerStateMap = new HashMap<>();
if (healthCheckResult != null) {
clusterManagerStateMap.put(HostName.hostName(FQDN1), Sets.newHashSet(new HealthCheck(HealthCheckType.HOST, healthCheckResult, Optional.ofNullable(statusReason))));
}
ExtendedHostStatuses extendedHostStatuses = new ExtendedHostStatuses(clusterManagerStateMap);
when(clusterStatusService.getExtendedHostStatuses(any())).thenReturn(extendedHostStatuses);
when(clusterApiConnectors.getConnector(stack)).thenReturn(connector);
}
use of com.sequenceiq.cloudbreak.cluster.api.ClusterStatusService in project cloudbreak by hortonworks.
the class ClusterServiceTest method testIsRangerRazEnabledOnClusterThrowsExceptionIfCmIsNotRunning.
@Test
void testIsRangerRazEnabledOnClusterThrowsExceptionIfCmIsNotRunning() {
Stack stack = setupStack(STACK_ID);
ClusterApi clusterApi = mock(ClusterApi.class);
ClusterStatusService clusterStatusService = mock(ClusterStatusService.class);
when(clusterApiConnectors.getConnector(stack)).thenReturn(clusterApi);
when(clusterApi.clusterStatusService()).thenReturn(clusterStatusService);
when(clusterStatusService.isClusterManagerRunning()).thenReturn(false);
BadRequestException exception = assertThrows(BadRequestException.class, () -> underTest.isRangerRazEnabledOnCluster(stack));
assertEquals(String.format("Cloudera Manager is not running for cluster: %s", CLUSTER_NAME), exception.getMessage());
}
use of com.sequenceiq.cloudbreak.cluster.api.ClusterStatusService in project cloudbreak by hortonworks.
the class ClusterServiceTest method testIsRangerRazEnabledOnClusterReturnsTrueWhenCmIsRunning.
@Test
void testIsRangerRazEnabledOnClusterReturnsTrueWhenCmIsRunning() {
Stack stack = setupStack(STACK_ID);
ClusterApi clusterApi = mock(ClusterApi.class);
ClusterStatusService clusterStatusService = mock(ClusterStatusService.class);
ClusterModificationService clusterModificationService = mock(ClusterModificationService.class);
when(clusterApiConnectors.getConnector(stack)).thenReturn(clusterApi);
when(clusterApi.clusterStatusService()).thenReturn(clusterStatusService);
when(clusterApi.clusterModificationService()).thenReturn(clusterModificationService);
when(clusterStatusService.isClusterManagerRunning()).thenReturn(true);
when(clusterModificationService.isServicePresent(anyString(), eq(RANGER_RAZ))).thenReturn(true);
assertTrue(underTest.isRangerRazEnabledOnCluster(stack));
}
use of com.sequenceiq.cloudbreak.cluster.api.ClusterStatusService in project cloudbreak by hortonworks.
the class ClusterServiceTest method testIsRangerRazEnabledOnClusterReturnsFalseIfCmIsRunning.
@Test
void testIsRangerRazEnabledOnClusterReturnsFalseIfCmIsRunning() {
Stack stack = setupStack(STACK_ID);
ClusterApi clusterApi = mock(ClusterApi.class);
ClusterStatusService clusterStatusService = mock(ClusterStatusService.class);
ClusterModificationService clusterModificationService = mock(ClusterModificationService.class);
when(clusterApiConnectors.getConnector(stack)).thenReturn(clusterApi);
when(clusterApi.clusterStatusService()).thenReturn(clusterStatusService);
when(clusterApi.clusterModificationService()).thenReturn(clusterModificationService);
when(clusterStatusService.isClusterManagerRunning()).thenReturn(true);
when(clusterModificationService.isServicePresent(anyString(), eq(RANGER_RAZ))).thenReturn(false);
assertFalse(underTest.isRangerRazEnabledOnCluster(stack));
}
Aggregations