Search in sources :

Example 1 with SaltCommandTracker

use of com.sequenceiq.cloudbreak.orchestrator.salt.poller.SaltCommandTracker 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 SaltCommandTracker

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

the class SaltOrchestrator method runSaltCommand.

private void runSaltCommand(SaltConnector sc, BaseSaltJobRunner baseSaltJobRunner, ExitCriteriaModel exitCriteriaModel) throws ExecutionException, InterruptedException {
    OrchestratorBootstrap saltCommandTracker = new SaltCommandTracker(sc, baseSaltJobRunner);
    Callable<Boolean> saltCommandRunBootstrapRunner = runner(saltCommandTracker, exitCriteria, exitCriteriaModel);
    Future<Boolean> saltCommandRunBootstrapFuture = parallelOrchestratorComponentRunner.submit(saltCommandRunBootstrapRunner);
    saltCommandRunBootstrapFuture.get();
}
Also used : OrchestratorBootstrap(com.sequenceiq.cloudbreak.orchestrator.OrchestratorBootstrap) SaltCommandTracker(com.sequenceiq.cloudbreak.orchestrator.salt.poller.SaltCommandTracker)

Aggregations

SaltCommandTracker (com.sequenceiq.cloudbreak.orchestrator.salt.poller.SaltCommandTracker)2 OrchestratorBootstrap (com.sequenceiq.cloudbreak.orchestrator.OrchestratorBootstrap)1 OrchestratorBootstrapRunner (com.sequenceiq.cloudbreak.orchestrator.OrchestratorBootstrapRunner)1 Node (com.sequenceiq.cloudbreak.orchestrator.model.Node)1 SaltConfig (com.sequenceiq.cloudbreak.orchestrator.model.SaltConfig)1 PillarSave (com.sequenceiq.cloudbreak.orchestrator.salt.poller.PillarSave)1 SaltBootstrap (com.sequenceiq.cloudbreak.orchestrator.salt.poller.SaltBootstrap)1 SaltJobIdTracker (com.sequenceiq.cloudbreak.orchestrator.salt.poller.SaltJobIdTracker)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 Test (org.junit.Test)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1