use of com.cloudera.api.swagger.model.ApiHost in project cloudbreak by hortonworks.
the class ClouderaManagerHostStatusCheckerTest method shouldBeTrueWhenOneInstanceIsFailed.
@Test
public void shouldBeTrueWhenOneInstanceIsFailed() throws ApiException {
InstanceMetaData instanceMetaData = validInstanceMetadata();
InstanceMetaData instanceMetaData2 = validInstanceMetadata();
instanceMetaData2.setPrivateIp("2.2.2.2");
instanceMetaData2.setInstanceStatus(InstanceStatus.FAILED);
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 shouldBeFalseWhenHostsReturnedHasNoHeartbeat.
@Test
public void shouldBeFalseWhenHostsReturnedHasNoHeartbeat() throws ApiException {
InstanceMetaData instanceMetaData = validInstanceMetadata();
ApiHost apiHost = new ApiHost().ipAddress(instanceMetaData.getPrivateIp());
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 ClouderaManagerDecomissionerTest method createApiHostRef.
private ApiHost createApiHostRef(String instanceFqd, ApiHealthSummary healthSummary) {
ApiHost instanceHostRef = new ApiHost();
instanceHostRef.setHostname(instanceFqd);
instanceHostRef.setHostId(instanceFqd);
instanceHostRef.setHealthSummary(healthSummary);
return instanceHostRef;
}
use of com.cloudera.api.swagger.model.ApiHost in project cloudbreak by hortonworks.
the class ClouderaManagerDecommisionerTest method getBusyHost.
private ApiHost getBusyHost() {
ApiHost apihost = new ApiHost();
apihost.setHostname("hg0-host-1");
ApiRoleRef apiroleref = new ApiRoleRef();
apiroleref.setRoleStatus(ApiRoleState.BUSY);
apihost.addRoleRefsItem(apiroleref);
return apihost;
}
use of com.cloudera.api.swagger.model.ApiHost in project cloudbreak by hortonworks.
the class ClouderaManagerDecommisionerTest method testCollectDownscaleCandidatesWhenEveryHostHasHostname.
@Test
public void testCollectDownscaleCandidatesWhenEveryHostHasHostname() throws ApiException {
// GIVEN
VolumeSetAttributes volumeSetAttributes = new VolumeSetAttributes("az", false, "fstab", List.of(), 50, "vt");
Stack stack = createTestStack(volumeSetAttributes);
Cluster cluster = new Cluster();
stack.setCluster(cluster);
Set<HostGroup> hostGroups = createTestHostGroups(1, 6);
cluster.setHostGroups(hostGroups);
HostGroup downscaledHostGroup = hostGroups.iterator().next();
HostsResourceApi hostsResourceApi = mock(HostsResourceApi.class);
when(clouderaManagerApiFactory.getHostsResourceApi(any(ApiClient.class))).thenReturn(hostsResourceApi);
HostTemplatesResourceApi hostTemplatesResourceApi = mock(HostTemplatesResourceApi.class);
when(clouderaManagerApiFactory.getHostTemplatesResourceApi(any(ApiClient.class))).thenReturn(hostTemplatesResourceApi);
ApiHostTemplateList hostTemplates = createEmptyHostTemplates();
when(hostTemplatesResourceApi.readHostTemplates(stack.getName())).thenReturn(hostTemplates);
ApiHostList apiHostRefList = new ApiHostList();
List<ApiHost> apiHosts = new ArrayList<>();
hostGroups.stream().flatMap(hostGroup -> hostGroup.getInstanceGroup().getAllInstanceMetaData().stream()).map(InstanceMetaData::getDiscoveryFQDN).forEach(hostName -> {
ApiHost apiHostRef = new ApiHost();
apiHostRef.setHostname(hostName);
apiHostRef.setHostId(hostName);
apiHostRef.setHealthSummary(ApiHealthSummary.GOOD);
apiHosts.add(apiHostRef);
});
apiHostRefList.setItems(apiHosts);
when(hostsResourceApi.readHosts(any(), any(), any())).thenReturn(apiHostRefList);
Set<InstanceMetaData> downscaleCandidates = underTest.collectDownscaleCandidates(mock(ApiClient.class), stack, downscaledHostGroup, -2, downscaledHostGroup.getInstanceGroup().getAllInstanceMetaData());
assertEquals(2, downscaleCandidates.size());
assertTrue("Assert if downscaleCandidates contains hg0-instanceid-4", downscaleCandidates.stream().anyMatch(instanceMetaData -> "hg0-instanceid-4".equals(instanceMetaData.getInstanceId())));
assertTrue("Assert if downscaleCandidates contains hg0-instanceid-4", downscaleCandidates.stream().anyMatch(instanceMetaData -> "hg0-instanceid-5".equals(instanceMetaData.getInstanceId())));
}
Aggregations