Search in sources :

Example 1 with ConcurrentParameterizedStateRunner

use of com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.ConcurrentParameterizedStateRunner in project cloudbreak by hortonworks.

the class SaltTelemetryOrchestratorTest method testExecuteDiagnosticCollection.

@Test
void testExecuteDiagnosticCollection() throws Exception {
    Map<String, Object> parameters = getParametersMap();
    underTest.executeDiagnosticCollection(gatewayConfigs, targets, parameters, exitCriteriaModel);
    SaltJobIdTracker saltJobIdTracker = (SaltJobIdTracker) orchestratorBootstrapArgumentCaptor.getValue();
    ConcurrentParameterizedStateRunner saltJobRunner = (ConcurrentParameterizedStateRunner) saltJobIdTracker.getSaltJobRunner();
    Assertions.assertTrue(CollectionUtils.isEqualCollection(targets, saltJobRunner.getAllNode()));
    assertEquals(SaltTelemetryOrchestrator.FILECOLLECTOR_COLLECT, saltJobRunner.getState());
    verify(callable, Mockito.times(1)).call();
    verify(saltService, Mockito.times(1)).getPrimaryGatewayConfig(gatewayConfigs);
    verify(saltRunner, Mockito.times(1)).runner(any(), any(), any(), anyInt(), anyBoolean());
    verify(telemetrySaltRetryConfig, Mockito.times(1)).getDiagnosticsCollect();
}
Also used : ConcurrentParameterizedStateRunner(com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.ConcurrentParameterizedStateRunner) SaltJobIdTracker(com.sequenceiq.cloudbreak.orchestrator.salt.poller.SaltJobIdTracker) Test(org.junit.jupiter.api.Test)

Example 2 with ConcurrentParameterizedStateRunner

use of com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.ConcurrentParameterizedStateRunner in project cloudbreak by hortonworks.

the class SaltTelemetryOrchestratorTest method testUploadCollectedDiagnostics.

@Test
void testUploadCollectedDiagnostics() throws Exception {
    Map<String, Object> parameters = getParametersMap();
    underTest.uploadCollectedDiagnostics(gatewayConfigs, targets, parameters, exitCriteriaModel);
    SaltJobIdTracker saltJobIdTracker = (SaltJobIdTracker) orchestratorBootstrapArgumentCaptor.getValue();
    ConcurrentParameterizedStateRunner saltJobRunner = (ConcurrentParameterizedStateRunner) saltJobIdTracker.getSaltJobRunner();
    Assertions.assertTrue(CollectionUtils.isEqualCollection(targets, saltJobRunner.getAllNode()));
    assertEquals(SaltTelemetryOrchestrator.FILECOLLECTOR_UPLOAD, saltJobRunner.getState());
    verify(callable, Mockito.times(1)).call();
}
Also used : ConcurrentParameterizedStateRunner(com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.ConcurrentParameterizedStateRunner) SaltJobIdTracker(com.sequenceiq.cloudbreak.orchestrator.salt.poller.SaltJobIdTracker) Test(org.junit.jupiter.api.Test)

Example 3 with ConcurrentParameterizedStateRunner

use of com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.ConcurrentParameterizedStateRunner in project cloudbreak by hortonworks.

the class SaltTelemetryOrchestratorTest method testCleanupCollectedDiagnostics.

@Test
void testCleanupCollectedDiagnostics() throws Exception {
    Map<String, Object> parameters = getParametersMap();
    underTest.cleanupCollectedDiagnostics(gatewayConfigs, targets, parameters, exitCriteriaModel);
    SaltJobIdTracker saltJobIdTracker = (SaltJobIdTracker) orchestratorBootstrapArgumentCaptor.getValue();
    ConcurrentParameterizedStateRunner saltJobRunner = (ConcurrentParameterizedStateRunner) saltJobIdTracker.getSaltJobRunner();
    Assertions.assertTrue(CollectionUtils.isEqualCollection(targets, saltJobRunner.getAllNode()));
    assertEquals(SaltTelemetryOrchestrator.FILECOLLECTOR_CLEANUP, saltJobRunner.getState());
    verify(callable, Mockito.times(1)).call();
}
Also used : ConcurrentParameterizedStateRunner(com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.ConcurrentParameterizedStateRunner) SaltJobIdTracker(com.sequenceiq.cloudbreak.orchestrator.salt.poller.SaltJobIdTracker) Test(org.junit.jupiter.api.Test)

Example 4 with ConcurrentParameterizedStateRunner

use of com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.ConcurrentParameterizedStateRunner in project cloudbreak by hortonworks.

the class SaltTelemetryOrchestratorTest method testInitDiagnosticCollection.

@Test
void testInitDiagnosticCollection() throws Exception {
    Map<String, Object> parameters = getParametersMap();
    underTest.initDiagnosticCollection(gatewayConfigs, targets, parameters, exitCriteriaModel);
    SaltJobIdTracker saltJobIdTracker = (SaltJobIdTracker) orchestratorBootstrapArgumentCaptor.getValue();
    ConcurrentParameterizedStateRunner saltJobRunner = (ConcurrentParameterizedStateRunner) saltJobIdTracker.getSaltJobRunner();
    Assertions.assertTrue(CollectionUtils.isEqualCollection(targets, saltJobRunner.getAllNode()));
    assertEquals(SaltTelemetryOrchestrator.FILECOLLECTOR_INIT, saltJobRunner.getState());
    verify(callable, Mockito.times(1)).call();
}
Also used : ConcurrentParameterizedStateRunner(com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.ConcurrentParameterizedStateRunner) SaltJobIdTracker(com.sequenceiq.cloudbreak.orchestrator.salt.poller.SaltJobIdTracker) Test(org.junit.jupiter.api.Test)

Example 5 with ConcurrentParameterizedStateRunner

use of com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.ConcurrentParameterizedStateRunner in project cloudbreak by hortonworks.

the class SaltTelemetryOrchestrator method runSaltState.

// CHECKSTYLE:OFF
private void runSaltState(List<GatewayConfig> allGateways, Set<Node> nodes, Map<String, Object> parameters, ExitCriteriaModel exitModel, String saltState, String errorMessage, int retryCount, boolean retryOnFail) throws CloudbreakOrchestratorFailedException {
    // CHECKSTYLE:ON
    GatewayConfig primaryGateway = saltService.getPrimaryGatewayConfig(allGateways);
    Set<String> targetHostnames = nodes.stream().map(Node::getHostname).collect(Collectors.toSet());
    try (SaltConnector sc = saltService.createSaltConnector(primaryGateway)) {
        ConcurrentParameterizedStateRunner stateRunner = new ConcurrentParameterizedStateRunner(targetHostnames, nodes, saltState, parameters);
        OrchestratorBootstrap saltJobIdTracker = new SaltJobIdTracker(sc, stateRunner, retryOnFail);
        Callable<Boolean> saltJobRunBootstrapRunner = saltRunner.runner(saltJobIdTracker, exitCriteria, exitModel, retryCount, false);
        saltJobRunBootstrapRunner.call();
    } catch (Exception e) {
        LOGGER.debug(errorMessage, e);
        throw new CloudbreakOrchestratorFailedException(e);
    }
}
Also used : ConcurrentParameterizedStateRunner(com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.ConcurrentParameterizedStateRunner) CloudbreakOrchestratorFailedException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException) OrchestratorBootstrap(com.sequenceiq.cloudbreak.orchestrator.OrchestratorBootstrap) SaltJobIdTracker(com.sequenceiq.cloudbreak.orchestrator.salt.poller.SaltJobIdTracker) SaltConnector(com.sequenceiq.cloudbreak.orchestrator.salt.client.SaltConnector) CloudbreakOrchestratorException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorException) UncheckedIOException(java.io.UncheckedIOException) CloudbreakOrchestratorFailedException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) GatewayConfig(com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)

Aggregations

SaltJobIdTracker (com.sequenceiq.cloudbreak.orchestrator.salt.poller.SaltJobIdTracker)5 ConcurrentParameterizedStateRunner (com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.ConcurrentParameterizedStateRunner)5 Test (org.junit.jupiter.api.Test)4 OrchestratorBootstrap (com.sequenceiq.cloudbreak.orchestrator.OrchestratorBootstrap)1 CloudbreakOrchestratorException (com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorException)1 CloudbreakOrchestratorFailedException (com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException)1 GatewayConfig (com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)1 SaltConnector (com.sequenceiq.cloudbreak.orchestrator.salt.client.SaltConnector)1 IOException (java.io.IOException)1 UncheckedIOException (java.io.UncheckedIOException)1 ExecutionException (java.util.concurrent.ExecutionException)1