use of com.sequenceiq.cloudbreak.orchestrator.OrchestratorBootstrapRunner 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));
}
Aggregations