Search in sources :

Example 11 with ApiHost

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")));
}
Also used : ApiHealthCheck(com.cloudera.api.swagger.model.ApiHealthCheck) ApiHost(com.cloudera.api.swagger.model.ApiHost) Test(org.junit.Test)

Example 12 with ApiHost

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")));
}
Also used : ExtendedHostStatuses(com.sequenceiq.cloudbreak.cluster.status.ExtendedHostStatuses) ApiHealthCheck(com.cloudera.api.swagger.model.ApiHealthCheck) ApiHost(com.cloudera.api.swagger.model.ApiHost) Test(org.junit.Test)

Example 13 with ApiHost

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);
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) ApiHostList(com.cloudera.api.swagger.model.ApiHostList) ApiHost(com.cloudera.api.swagger.model.ApiHost) Test(org.junit.Test)

Example 14 with ApiHost

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);
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) ApiHostList(com.cloudera.api.swagger.model.ApiHostList) ApiHost(com.cloudera.api.swagger.model.ApiHost) Test(org.junit.Test)

Example 15 with ApiHost

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);
}
Also used : InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) ApiHostList(com.cloudera.api.swagger.model.ApiHostList) ApiHost(com.cloudera.api.swagger.model.ApiHost) Test(org.junit.Test)

Aggregations

ApiHost (com.cloudera.api.swagger.model.ApiHost)49 ApiHostList (com.cloudera.api.swagger.model.ApiHostList)30 InstanceMetaData (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData)26 Test (org.junit.Test)23 HostsResourceApi (com.cloudera.api.swagger.HostsResourceApi)16 ApiException (com.cloudera.api.swagger.client.ApiException)16 List (java.util.List)14 ApiClient (com.cloudera.api.swagger.client.ApiClient)13 Set (java.util.Set)13 Collectors (java.util.stream.Collectors)13 ClouderaManagerApiFactory (com.sequenceiq.cloudbreak.cm.client.retry.ClouderaManagerApiFactory)12 ApiCommand (com.cloudera.api.swagger.model.ApiCommand)11 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)11 HostGroup (com.sequenceiq.cloudbreak.domain.stack.cluster.host.HostGroup)11 ApiHealthSummary (com.cloudera.api.swagger.model.ApiHealthSummary)10 ApiRoleRef (com.cloudera.api.swagger.model.ApiRoleRef)10 ClouderaManagerPollingServiceProvider (com.sequenceiq.cloudbreak.cm.polling.ClouderaManagerPollingServiceProvider)10 Logger (org.slf4j.Logger)10 LoggerFactory (org.slf4j.LoggerFactory)10 ClouderaManagerResourceApi (com.cloudera.api.swagger.ClouderaManagerResourceApi)9