use of com.cloudera.api.swagger.model.ApiHost in project cloudbreak by hortonworks.
the class ClouderaManagerClusterStatusServiceTest method filtersAppropriateHealthCheckForHost.
@Test
public void filtersAppropriateHealthCheckForHost() throws ApiException {
hostsAre(new ApiHost().hostname("host").addHealthChecksItem(new ApiHealthCheck().name("fake_check").summary(ApiHealthSummary.BAD)).addHealthChecksItem(new ApiHealthCheck().name(HOST_SCM_HEALTH).summary(ApiHealthSummary.CONCERNING)).addHealthChecksItem(new ApiHealthCheck().name("another").summary(ApiHealthSummary.BAD)));
assertTrue(subject.getExtendedHostStatuses(Optional.of("7.2.12")).isHostHealthy(hostName("host")));
}
use of com.cloudera.api.swagger.model.ApiHost in project cloudbreak by hortonworks.
the class ClouderaManagerClusterStatusServiceTest method collectsExtendedHostHealthIfAvailable.
@Test
public void collectsExtendedHostHealthIfAvailable() throws ApiException {
hostsAre(new ApiHost().hostname("host1").addHealthChecksItem(new ApiHealthCheck().name(HOST_SCM_HEALTH).summary(ApiHealthSummary.GOOD)).addHealthChecksItem(new ApiHealthCheck().name(HOST_AGENT_CERTIFICATE_EXPIRY).summary(ApiHealthSummary.GOOD)), new ApiHost().hostname("host2").addHealthChecksItem(new ApiHealthCheck().name(HOST_SCM_HEALTH).summary(ApiHealthSummary.CONCERNING)).addHealthChecksItem(new ApiHealthCheck().name(HOST_AGENT_CERTIFICATE_EXPIRY).summary(ApiHealthSummary.CONCERNING).explanation("in 30 days")), new ApiHost().hostname("host3").addHealthChecksItem(new ApiHealthCheck().name(HOST_SCM_HEALTH).summary(ApiHealthSummary.BAD).explanation("explanation.")).addHealthChecksItem(new ApiHealthCheck().name(HOST_AGENT_CERTIFICATE_EXPIRY).summary(ApiHealthSummary.BAD).explanation("in 2 days")), new ApiHost().hostname("host4").addHealthChecksItem(new ApiHealthCheck().name(HOST_SCM_HEALTH).summary(ApiHealthSummary.NOT_AVAILABLE)), new ApiHost().hostname("host5").addHealthChecksItem(new ApiHealthCheck().name(HOST_SCM_HEALTH).summary(ApiHealthSummary.HISTORY_NOT_AVAILABLE)), new ApiHost().hostname("host6").addHealthChecksItem(new ApiHealthCheck().name(HOST_SCM_HEALTH).summary(ApiHealthSummary.DISABLED)), new ApiHost().hostname("host7").maintenanceMode(true).addHealthChecksItem(new ApiHealthCheck().name(HOST_SCM_HEALTH).summary(ApiHealthSummary.GOOD)).addHealthChecksItem(new ApiHealthCheck().name(HOST_AGENT_CERTIFICATE_EXPIRY).summary(ApiHealthSummary.GOOD)));
ExtendedHostStatuses extendedHostStatuses = subject.getExtendedHostStatuses(Optional.of("7.2.12"));
assertEquals("explanation. Cert health on CM: BAD", extendedHostStatuses.statusReasonForHost(hostName("host3")));
assertTrue(extendedHostStatuses.isAnyCertExpiring());
assertTrue(extendedHostStatuses.isHostHealthy(hostName("host1")));
assertTrue(extendedHostStatuses.isHostHealthy(hostName("host2")));
assertFalse(extendedHostStatuses.isHostHealthy(hostName("host3")));
assertFalse(extendedHostStatuses.isHostHealthy(hostName("host7")));
}
use of com.cloudera.api.swagger.model.ApiHost in project cloudbreak by hortonworks.
the class ClouderaManagerHostStatusCheckerTest method shouldBeTrueWhenOneInstanceIsStopped.
@Test
public void shouldBeTrueWhenOneInstanceIsStopped() throws ApiException {
InstanceMetaData instanceMetaData = validInstanceMetadata();
InstanceMetaData instanceMetaData2 = validInstanceMetadata();
instanceMetaData2.setPrivateIp("2.2.2.2");
instanceMetaData2.setInstanceStatus(InstanceStatus.STOPPED);
ApiHost apiHost = getValidApiHost(instanceMetaData);
when(hostsResourceApi.readHosts(null, null, VIEWTYPE)).thenReturn(new ApiHostList().items(List.of(apiHost)));
boolean result = underTest.doStatusCheck(getPollerObject(instanceMetaData, instanceMetaData2));
assertTrue(result);
}
use of com.cloudera.api.swagger.model.ApiHost in project cloudbreak by hortonworks.
the class ClouderaManagerHostStatusCheckerTest method shouldBeFalseWhenHostsReturnedHasDifferentIp.
@Test
public void shouldBeFalseWhenHostsReturnedHasDifferentIp() throws ApiException {
InstanceMetaData instanceMetaData = validInstanceMetadata();
ApiHost apiHost = new ApiHost().ipAddress("2.2.2.2").lastHeartbeat(Instant.now().plus(5, ChronoUnit.MINUTES).toString());
when(hostsResourceApi.readHosts(null, null, VIEWTYPE)).thenReturn(new ApiHostList().items(List.of(apiHost)));
boolean result = underTest.doStatusCheck(getPollerObject(instanceMetaData));
assertFalse(result);
}
use of com.cloudera.api.swagger.model.ApiHost in project cloudbreak by hortonworks.
the class ClouderaManagerHostStatusCheckerTest method shouldBeTrueWhenOneInstanceIsDeletedOnProvider.
@Test
public void shouldBeTrueWhenOneInstanceIsDeletedOnProvider() throws ApiException {
InstanceMetaData instanceMetaData = validInstanceMetadata();
InstanceMetaData instanceMetaData2 = validInstanceMetadata();
instanceMetaData2.setPrivateIp("2.2.2.2");
instanceMetaData2.setInstanceStatus(InstanceStatus.DELETED_ON_PROVIDER_SIDE);
ApiHost apiHost = getValidApiHost(instanceMetaData);
when(hostsResourceApi.readHosts(null, null, VIEWTYPE)).thenReturn(new ApiHostList().items(List.of(apiHost)));
boolean result = underTest.doStatusCheck(getPollerObject(instanceMetaData, instanceMetaData2));
assertTrue(result);
}
Aggregations