Search in sources :

Example 1 with SaltJobIdTracker

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

the class SaltOrchestratorTest method runServiceTest.

@Test
public void runServiceTest() throws Exception {
    whenNew(SaltBootstrap.class).withAnyArguments().thenReturn(mock(SaltBootstrap.class));
    whenNew(OrchestratorBootstrapRunner.class).withAnyArguments().thenReturn(mock(OrchestratorBootstrapRunner.class));
    PillarSave pillarSave = mock(PillarSave.class);
    whenNew(PillarSave.class).withAnyArguments().thenReturn(pillarSave);
    GrainAddRunner addRemoveGrainRunner = mock(GrainAddRunner.class);
    whenNew(GrainAddRunner.class).withAnyArguments().thenReturn(addRemoveGrainRunner);
    SaltCommandTracker roleCheckerSaltCommandTracker = mock(SaltCommandTracker.class);
    whenNew(SaltCommandTracker.class).withArguments(eq(saltConnector), eq(addRemoveGrainRunner)).thenReturn(roleCheckerSaltCommandTracker);
    SyncGrainsRunner syncGrainsRunner = mock(SyncGrainsRunner.class);
    whenNew(SyncGrainsRunner.class).withAnyArguments().thenReturn(syncGrainsRunner);
    SaltCommandTracker syncGrainsCheckerSaltCommandTracker = mock(SaltCommandTracker.class);
    whenNew(SaltCommandTracker.class).withArguments(eq(saltConnector), eq(syncGrainsRunner)).thenReturn(syncGrainsCheckerSaltCommandTracker);
    HighStateRunner highStateRunner = mock(HighStateRunner.class);
    whenNew(HighStateRunner.class).withAnyArguments().thenReturn(highStateRunner);
    SaltJobIdTracker saltJobIdTracker = mock(SaltJobIdTracker.class);
    whenNew(SaltJobIdTracker.class).withAnyArguments().thenReturn(saltJobIdTracker);
    saltOrchestrator.init(parallelOrchestratorComponentRunner, exitCriteria);
    SaltConfig saltConfig = new SaltConfig();
    saltOrchestrator.runService(Collections.singletonList(gatewayConfig), targets, saltConfig, exitCriteriaModel);
    // verify pillar save
    verifyNew(OrchestratorBootstrapRunner.class, times(1)).withArguments(eq(pillarSave), eq(exitCriteria), eq(exitCriteriaModel), any(), anyInt(), anyInt());
    // verify ambari server role
    verifyNew(GrainAddRunner.class, times(1)).withArguments(eq(Sets.newHashSet(gatewayConfig.getPrivateAddress())), eq(targets), eq("ambari_server_install"));
    // verify ambari server role
    verifyNew(GrainAddRunner.class, times(1)).withArguments(eq(Sets.newHashSet(gatewayConfig.getPrivateAddress())), eq(targets), eq("ambari_server"));
    // verify ambari agent role
    Set<String> allNodes = targets.stream().map(Node::getPrivateIp).collect(Collectors.toSet());
    verifyNew(GrainAddRunner.class, times(1)).withArguments(eq(allNodes), eq(targets), eq("ambari_agent_install"));
    // verify ambari agent role
    allNodes = targets.stream().map(Node::getPrivateIp).collect(Collectors.toSet());
    verifyNew(GrainAddRunner.class, times(1)).withArguments(eq(allNodes), eq(targets), eq("ambari_agent"));
    // verify two role command (amabari server, ambari agent)
    verifyNew(SaltCommandTracker.class, times(4)).withArguments(eq(saltConnector), eq(addRemoveGrainRunner));
    // verify two OrchestratorBootstrapRunner call with rolechecker command tracker
    verifyNew(OrchestratorBootstrapRunner.class, times(4)).withArguments(eq(roleCheckerSaltCommandTracker), eq(exitCriteria), eq(exitCriteriaModel), any(), anyInt(), anyInt());
    // verify syncgrains command
    verifyNew(SyncGrainsRunner.class, times(1)).withArguments(eq(allNodes), eq(targets));
    verifyNew(SaltCommandTracker.class, times(1)).withArguments(eq(saltConnector), eq(syncGrainsRunner));
    verifyNew(OrchestratorBootstrapRunner.class, times(1)).withArguments(eq(syncGrainsCheckerSaltCommandTracker), eq(exitCriteria), eq(exitCriteriaModel), any(), anyInt(), anyInt());
    // verify run new service
    verifyNew(HighStateRunner.class, atLeastOnce()).withArguments(eq(allNodes), eq(targets));
    verifyNew(SaltJobIdTracker.class, atLeastOnce()).withArguments(eq(saltConnector), eq(highStateRunner), eq(true));
}
Also used : HighStateRunner(com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.HighStateRunner) SaltJobIdTracker(com.sequenceiq.cloudbreak.orchestrator.salt.poller.SaltJobIdTracker) Node(com.sequenceiq.cloudbreak.orchestrator.model.Node) GrainAddRunner(com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.GrainAddRunner) SyncGrainsRunner(com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.SyncGrainsRunner) SaltCommandTracker(com.sequenceiq.cloudbreak.orchestrator.salt.poller.SaltCommandTracker) SaltConfig(com.sequenceiq.cloudbreak.orchestrator.model.SaltConfig) SaltBootstrap(com.sequenceiq.cloudbreak.orchestrator.salt.poller.SaltBootstrap) OrchestratorBootstrapRunner(com.sequenceiq.cloudbreak.orchestrator.OrchestratorBootstrapRunner) PillarSave(com.sequenceiq.cloudbreak.orchestrator.salt.poller.PillarSave) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 2 with SaltJobIdTracker

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

the class SaltOrchestrator method resetAmbari.

@Override
public void resetAmbari(GatewayConfig gatewayConfig, Set<String> target, Set<Node> allNodes, ExitCriteriaModel exitCriteriaModel) throws CloudbreakOrchestratorException {
    try (SaltConnector saltConnector = new SaltConnector(gatewayConfig, restDebug)) {
        BaseSaltJobRunner baseSaltJobRunner = new BaseSaltJobRunner(target, allNodes) {

            @Override
            public String submit(SaltConnector saltConnector) {
                return SaltStates.ambariReset(saltConnector, new Compound(getTarget(), CompoundType.HOST));
            }
        };
        OrchestratorBootstrap saltJobIdTracker = new SaltJobIdTracker(saltConnector, baseSaltJobRunner);
        Callable<Boolean> saltJobRunBootstrapRunner = runner(saltJobIdTracker, exitCriteria, exitCriteriaModel);
        Future<Boolean> saltJobRunBootstrapFuture = parallelOrchestratorComponentRunner.submit(saltJobRunBootstrapRunner);
        saltJobRunBootstrapFuture.get();
    } catch (Exception e) {
        LOGGER.error("Error occurred during reset", e);
        throw new CloudbreakOrchestratorFailedException(e);
    }
}
Also used : CloudbreakOrchestratorFailedException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException) OrchestratorBootstrap(com.sequenceiq.cloudbreak.orchestrator.OrchestratorBootstrap) SaltJobIdTracker(com.sequenceiq.cloudbreak.orchestrator.salt.poller.SaltJobIdTracker) BaseSaltJobRunner(com.sequenceiq.cloudbreak.orchestrator.salt.poller.BaseSaltJobRunner) Compound(com.sequenceiq.cloudbreak.orchestrator.salt.client.target.Compound) SaltConnector(com.sequenceiq.cloudbreak.orchestrator.salt.client.SaltConnector) CloudbreakOrchestratorException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorException) CloudbreakOrchestratorFailedException(com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException)

Example 3 with SaltJobIdTracker

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

the class SaltOrchestrator method runNewService.

private void runNewService(SaltConnector sc, BaseSaltJobRunner baseSaltJobRunner, ExitCriteriaModel exitCriteriaModel, int maxRetry, boolean retryOnFail) throws ExecutionException, InterruptedException {
    OrchestratorBootstrap saltJobIdTracker = new SaltJobIdTracker(sc, baseSaltJobRunner, retryOnFail);
    Callable<Boolean> saltJobRunBootstrapRunner = runner(saltJobIdTracker, exitCriteria, exitCriteriaModel, maxRetry);
    Future<Boolean> saltJobRunBootstrapFuture = parallelOrchestratorComponentRunner.submit(saltJobRunBootstrapRunner);
    saltJobRunBootstrapFuture.get();
}
Also used : OrchestratorBootstrap(com.sequenceiq.cloudbreak.orchestrator.OrchestratorBootstrap) SaltJobIdTracker(com.sequenceiq.cloudbreak.orchestrator.salt.poller.SaltJobIdTracker)

Aggregations

SaltJobIdTracker (com.sequenceiq.cloudbreak.orchestrator.salt.poller.SaltJobIdTracker)3 OrchestratorBootstrap (com.sequenceiq.cloudbreak.orchestrator.OrchestratorBootstrap)2 OrchestratorBootstrapRunner (com.sequenceiq.cloudbreak.orchestrator.OrchestratorBootstrapRunner)1 CloudbreakOrchestratorException (com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorException)1 CloudbreakOrchestratorFailedException (com.sequenceiq.cloudbreak.orchestrator.exception.CloudbreakOrchestratorFailedException)1 Node (com.sequenceiq.cloudbreak.orchestrator.model.Node)1 SaltConfig (com.sequenceiq.cloudbreak.orchestrator.model.SaltConfig)1 SaltConnector (com.sequenceiq.cloudbreak.orchestrator.salt.client.SaltConnector)1 Compound (com.sequenceiq.cloudbreak.orchestrator.salt.client.target.Compound)1 BaseSaltJobRunner (com.sequenceiq.cloudbreak.orchestrator.salt.poller.BaseSaltJobRunner)1 PillarSave (com.sequenceiq.cloudbreak.orchestrator.salt.poller.PillarSave)1 SaltBootstrap (com.sequenceiq.cloudbreak.orchestrator.salt.poller.SaltBootstrap)1 SaltCommandTracker (com.sequenceiq.cloudbreak.orchestrator.salt.poller.SaltCommandTracker)1 GrainAddRunner (com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.GrainAddRunner)1 HighStateRunner (com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.HighStateRunner)1 SyncGrainsRunner (com.sequenceiq.cloudbreak.orchestrator.salt.poller.checker.SyncGrainsRunner)1 IOException (java.io.IOException)1 ExecutionException (java.util.concurrent.ExecutionException)1 Test (org.junit.Test)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1