use of com.sequenceiq.cloudbreak.structuredevent.event.CloudbreakEventService in project cloudbreak by hortonworks.
the class InstanceMetadataUpdaterTest method updatePackageVersionsOnAllInstancesInstancePkgQueryFailed.
@Test
public void updatePackageVersionsOnAllInstancesInstancePkgQueryFailed() throws Exception {
Stack stack = createStack();
Map<String, Map<String, String>> hostPackageMap = Maps.newHashMap();
hostPackageMap.put("instanceId", packageMap());
hostPackageMap.put("hostByCmd", falsePackageMap());
when(hostOrchestrator.getPackageVersionsFromAllHosts(any(GatewayConfig.class), any())).thenReturn(hostPackageMap);
when(stackService.getByIdWithListsInTransaction(anyLong())).thenReturn(stack);
underTest.updatePackageVersionsOnAllInstances(1L);
verify(cloudbreakEventService, times(1)).fireCloudbreakEvent(anyLong(), anyString(), eq(ResourceEvent.CLUSTER_PACKAGE_VERSION_CANNOT_BE_QUERIED), anyCollection());
verify(cloudbreakEventService, times(2)).fireCloudbreakEvent(anyLong(), anyString(), any(ResourceEvent.class), anyCollection());
assertEquals(SERVICES_UNHEALTHY, stack.getInstanceGroups().stream().filter(instanceGroup -> instanceGroup.getInstanceMetaDataSet().stream().filter(instanceMetaData -> StringUtils.equals(instanceMetaData.getDiscoveryFQDN(), "hostByCmd")).findFirst().isPresent()).findFirst().get().getInstanceMetaDataSet().iterator().next().getInstanceStatus());
}
Aggregations