use of com.sequenceiq.cloudbreak.orchestrator.host.TelemetryOrchestrator in project cloudbreak by hortonworks.
the class CloudStorageValidationServiceTest method testValidationWithFailingIdbrokerAndRandomHost.
@Test
void testValidationWithFailingIdbrokerAndRandomHost() throws CloudbreakOrchestratorException {
Stack stack = getStack();
when(stackService.getByIdWithClusterInTransaction(STACK_ID)).thenReturn(stack);
when(entitlementService.cloudStorageValidationOnVmEnabled(anyString())).thenReturn(true);
DetailedEnvironmentResponse environment = getEnvironment();
when(environmentClientService.getByCrn(ENV_CRN)).thenReturn(environment);
List<GatewayConfig> gatewayConfigs = getGatewayConfigs();
when(gatewayConfigService.getAllGatewayConfigs(stack)).thenReturn(gatewayConfigs);
Set<Node> nodes = getNodes();
when(stackUtil.collectNodes(stack)).thenReturn(nodes);
when(diagnosticCloudStorageConverter.loggingResponseToCloudStorageDiagnosticsParameters(environment.getTelemetry().getLogging(), REGION)).thenReturn(new AwsDiagnosticParameters());
doThrow(new CloudbreakOrchestratorFailedException("failed")).when(telemetryOrchestrator).validateCloudStorage(anyList(), anySet(), any(), anyMap(), any());
assertThrows(CloudbreakOrchestratorFailedException.class, () -> underTest.validateCloudStorage(STACK_ID), "If provisioning was done using the UI, then verify the log's instance profile and logs location base when provisioning");
ArgumentCaptor<Set<String>> targetHostnamesCaptor = ArgumentCaptor.forClass(Set.class);
verify(telemetryOrchestrator, times(2)).validateCloudStorage(anyList(), anySet(), targetHostnamesCaptor.capture(), anyMap(), any());
verify(eventService, times(1)).fireCloudbreakEvent(anyLong(), anyString(), any());
List<Set<String>> capturedTargetHostnames = targetHostnamesCaptor.getAllValues();
List<String> idbrokerTargets = capturedTargetHostnames.stream().flatMap(Collection::stream).filter(s -> s.equals(IDBROKER_HOSTNAME)).collect(Collectors.toList());
List<String> nonIdbrokerTargets = capturedTargetHostnames.stream().flatMap(Collection::stream).filter(s -> !s.equals(IDBROKER_HOSTNAME)).collect(Collectors.toList());
assertEquals(1, idbrokerTargets.size());
assertEquals(1, nonIdbrokerTargets.size());
}
use of com.sequenceiq.cloudbreak.orchestrator.host.TelemetryOrchestrator in project cloudbreak by hortonworks.
the class CloudStorageValidationServiceTest method testValidationWithIdbrokerAndRandomHost.
@Test
void testValidationWithIdbrokerAndRandomHost() throws CloudbreakOrchestratorException {
Stack stack = getStack();
when(stackService.getByIdWithClusterInTransaction(STACK_ID)).thenReturn(stack);
when(entitlementService.cloudStorageValidationOnVmEnabled(anyString())).thenReturn(true);
DetailedEnvironmentResponse environment = getEnvironment();
when(environmentClientService.getByCrn(ENV_CRN)).thenReturn(environment);
List<GatewayConfig> gatewayConfigs = getGatewayConfigs();
when(gatewayConfigService.getAllGatewayConfigs(stack)).thenReturn(gatewayConfigs);
Set<Node> nodes = getNodes();
when(stackUtil.collectNodes(stack)).thenReturn(nodes);
when(diagnosticCloudStorageConverter.loggingResponseToCloudStorageDiagnosticsParameters(environment.getTelemetry().getLogging(), REGION)).thenReturn(new AwsDiagnosticParameters());
underTest.validateCloudStorage(STACK_ID);
ArgumentCaptor<Set<String>> targetHostnamesCaptor = ArgumentCaptor.forClass(Set.class);
verify(telemetryOrchestrator, times(2)).validateCloudStorage(anyList(), anySet(), targetHostnamesCaptor.capture(), anyMap(), any());
List<Set<String>> capturedTargetHostnames = targetHostnamesCaptor.getAllValues();
List<String> idbrokerTargets = capturedTargetHostnames.stream().flatMap(Collection::stream).filter(s -> s.equals(IDBROKER_HOSTNAME)).collect(Collectors.toList());
List<String> nonIdbrokerTargets = capturedTargetHostnames.stream().flatMap(Collection::stream).filter(s -> !s.equals(IDBROKER_HOSTNAME)).collect(Collectors.toList());
assertEquals(1, idbrokerTargets.size());
assertEquals(1, nonIdbrokerTargets.size());
}
Aggregations