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));
}
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);
}
}
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();
}
Aggregations