Search in sources :

Example 31 with ApiHost

use of com.cloudera.api.swagger.model.ApiHost in project cloudbreak by hortonworks.

the class ClouderaManagerClusterStatusServiceTest method testEverythingGood.

@Test
public void testEverythingGood() 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.GOOD)).addHealthChecksItem(new ApiHealthCheck().name(HOST_AGENT_CERTIFICATE_EXPIRY).summary(ApiHealthSummary.GOOD).explanation("in 30 days")));
    ExtendedHostStatuses extendedHostStatuses = subject.getExtendedHostStatuses(Optional.of("7.2.12"));
    assertFalse(extendedHostStatuses.isAnyCertExpiring());
    assertTrue(extendedHostStatuses.isHostHealthy(hostName("host1")));
    assertTrue(extendedHostStatuses.isHostHealthy(hostName("host2")));
}
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 32 with ApiHost

use of com.cloudera.api.swagger.model.ApiHost in project cloudbreak by hortonworks.

the class ClouderaManagerClusterStatusServiceTest method hostWithoutAppropriateHealthCheckIsIgnored.

@Test
public void hostWithoutAppropriateHealthCheckIsIgnored() throws ApiException {
    hostsAre(new ApiHost().hostname("hostY").addHealthChecksItem(new ApiHealthCheck().name("fake_check").summary(ApiHealthSummary.BAD)));
    assertFalse(subject.getExtendedHostStatuses(Optional.of("7.2.12")).getHostsHealth().containsKey(hostName("hostY")));
}
Also used : ApiHealthCheck(com.cloudera.api.swagger.model.ApiHealthCheck) ApiHost(com.cloudera.api.swagger.model.ApiHost) Test(org.junit.Test)

Example 33 with ApiHost

use of com.cloudera.api.swagger.model.ApiHost in project cloudbreak by hortonworks.

the class ClouderaManagerClusterStatusServiceTest method testCertExpiringEverythingElseGood.

@Test
public void testCertExpiringEverythingElseGood() 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.GOOD)).addHealthChecksItem(new ApiHealthCheck().name(HOST_AGENT_CERTIFICATE_EXPIRY).summary(ApiHealthSummary.CONCERNING).explanation("in 30 days")));
    ExtendedHostStatuses extendedHostStatuses = subject.getExtendedHostStatuses(Optional.of("7.2.12"));
    assertTrue(extendedHostStatuses.isHostHealthy(hostName("host1")));
    assertTrue(extendedHostStatuses.isHostHealthy(hostName("host2")));
    assertTrue(extendedHostStatuses.isAnyCertExpiring());
}
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 34 with ApiHost

use of com.cloudera.api.swagger.model.ApiHost in project cloudbreak by hortonworks.

the class ClouderaManagerHostStatusCheckerTest method shouldBeFalseWhenHostsReturnedHasOldHeartbeat.

@Test
public void shouldBeFalseWhenHostsReturnedHasOldHeartbeat() throws ApiException {
    InstanceMetaData instanceMetaData = validInstanceMetadata();
    ApiHost apiHost = new ApiHost().ipAddress(instanceMetaData.getPrivateIp()).lastHeartbeat(Instant.now().minus(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 35 with ApiHost

use of com.cloudera.api.swagger.model.ApiHost in project cloudbreak by hortonworks.

the class ClouderaManagerHostStatusCheckerTest method shouldBeTrueWhenMultipleValidHosts.

@Test
public void shouldBeTrueWhenMultipleValidHosts() throws ApiException {
    InstanceMetaData instanceMetaData = validInstanceMetadata();
    InstanceMetaData instanceMetaData2 = validInstanceMetadata();
    instanceMetaData2.setPrivateIp("2.2.2.2");
    ApiHost apiHost = getValidApiHost(instanceMetaData);
    ApiHost apiHost2 = getValidApiHost(instanceMetaData2);
    when(hostsResourceApi.readHosts(null, null, VIEWTYPE)).thenReturn(new ApiHostList().items(List.of(apiHost, apiHost2)));
    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