Search in sources :

Example 26 with ApiHost

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

the class BaseClouderaManagerCommDecommTest method createApiHostRef.

protected ApiHost createApiHostRef(String instanceFqd, ApiHealthSummary healthSummary) {
    ApiHost instanceHostRef = new ApiHost();
    instanceHostRef.setHostname(instanceFqd);
    instanceHostRef.setHostId(instanceFqd);
    instanceHostRef.setHealthSummary(healthSummary);
    return instanceHostRef;
}
Also used : ApiHost(com.cloudera.api.swagger.model.ApiHost)

Example 27 with ApiHost

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

the class BaseClouderaManagerCommDecommTest method createGoodHealthApiHostList.

protected ApiHostList createGoodHealthApiHostList(Set<String> hostnames) {
    List<ApiHost> apiHosts = hostnames.stream().map(h -> createGoodHealthApiHostRef(h)).collect(Collectors.toList());
    ApiHostList apiHostList = new ApiHostList();
    apiHostList.setItems(apiHosts);
    return apiHostList;
}
Also used : ApiCommand(com.cloudera.api.swagger.model.ApiCommand) HostsResourceApi(com.cloudera.api.swagger.HostsResourceApi) ApiClient(com.cloudera.api.swagger.client.ApiClient) ApiHostList(com.cloudera.api.swagger.model.ApiHostList) InstanceStatus(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.base.InstanceStatus) Set(java.util.Set) Mockito.when(org.mockito.Mockito.when) Collectors(java.util.stream.Collectors) ApiException(com.cloudera.api.swagger.client.ApiException) BigDecimal(java.math.BigDecimal) List(java.util.List) ApiHealthSummary(com.cloudera.api.swagger.model.ApiHealthSummary) InstanceMetaData(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData) ApiHost(com.cloudera.api.swagger.model.ApiHost) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup) ClouderaManagerApiFactory(com.sequenceiq.cloudbreak.cm.client.retry.ClouderaManagerApiFactory) ApiHostList(com.cloudera.api.swagger.model.ApiHostList) ApiHost(com.cloudera.api.swagger.model.ApiHost)

Example 28 with ApiHost

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

the class ClouderaManagerClusterStatusServiceTest method getDecommissionedHostsFromCM.

@Test
public void getDecommissionedHostsFromCM() throws ApiException {
    hostsAre(new ApiHost().hostname("host1").maintenanceMode(true), new ApiHost().hostname("host2").maintenanceMode(false));
    List<String> hosts = subject.getDecommissionedHostsFromCM();
    assertEquals(1, hosts.size());
    assertEquals("host1", hosts.get(0));
}
Also used : ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) ApiHost(com.cloudera.api.swagger.model.ApiHost) Test(org.junit.Test)

Example 29 with ApiHost

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

the class ClouderaManagerClusterStatusServiceTest method testServiceBadHealth.

@Test
public void testServiceBadHealth() throws ApiException {
    hostsAre(new ApiHost().hostname("host1").addHealthChecksItem(new ApiHealthCheck().name(HOST_SCM_HEALTH).summary(ApiHealthSummary.BAD).explanation("explanation")).addHealthChecksItem(new ApiHealthCheck().name(HOST_AGENT_CERTIFICATE_EXPIRY).summary(ApiHealthSummary.GOOD)).addRoleRefsItem(roleRef("badservice", ApiHealthSummary.BAD)), 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")).addRoleRefsItem(roleRef("badservice2", ApiHealthSummary.BAD)).addRoleRefsItem(roleRef("badservice3", ApiHealthSummary.BAD)));
    ExtendedHostStatuses extendedHostStatuses = subject.getExtendedHostStatuses(Optional.of("7.2.12"));
    assertFalse(extendedHostStatuses.isAnyCertExpiring());
    assertFalse(extendedHostStatuses.isHostHealthy(hostName("host1")));
    assertFalse(extendedHostStatuses.isHostHealthy(hostName("host2")));
    assertEquals("explanation. The following services are in bad health: badservice.", extendedHostStatuses.statusReasonForHost(hostName("host1")));
    assertEquals("The following services are in bad health: badservice2, badservice3.", extendedHostStatuses.statusReasonForHost(hostName("host2")));
    extendedHostStatuses = subject.getExtendedHostStatuses(Optional.of("7.2.11"));
    assertFalse(extendedHostStatuses.isAnyCertExpiring());
    assertFalse(extendedHostStatuses.isHostHealthy(hostName("host1")));
    assertTrue(extendedHostStatuses.isHostHealthy(hostName("host2")));
    assertEquals("explanation.", extendedHostStatuses.statusReasonForHost(hostName("host1")));
}
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 30 with ApiHost

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

the class ClouderaManagerClusterStatusServiceTest method collectsHostHealthIfAvailable.

@Test
public void collectsHostHealthIfAvailable() throws ApiException {
    hostsAre(new ApiHost().hostname("host1").addHealthChecksItem(new ApiHealthCheck().name(HOST_SCM_HEALTH).summary(ApiHealthSummary.GOOD)), new ApiHost().hostname("host2").addHealthChecksItem(new ApiHealthCheck().name(HOST_SCM_HEALTH).summary(ApiHealthSummary.CONCERNING)), new ApiHost().hostname("host3").addHealthChecksItem(new ApiHealthCheck().name(HOST_SCM_HEALTH).summary(ApiHealthSummary.BAD)), 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)));
    ExtendedHostStatuses extendedHostStatuses = subject.getExtendedHostStatuses(Optional.of("7.2.12"));
    assertFalse(extendedHostStatuses.isHostHealthy(hostName("host3")));
    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)

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