@Test public void callHasTargetNodesTest() throws Exception { SaltConnector saltConnector = Mockito.mock(SaltConnector.class); SaltJobRunner saltJobRunner = Mockito.mock(SaltJobRunner.class); Set<String> targets = new HashSet<>(); targets.add("10.0.0.1"); targets.add("10.0.0.2"); targets.add("10.0.0.3"); when(saltJobRunner.getTargetHostnames()).thenReturn(targets); SaltCommandTracker saltCommandTracker = new SaltCommandTracker(saltConnector, saltJobRunner); try { saltCommandTracker.call(); fail("shoud throw exception"); } catch (CloudbreakOrchestratorFailedException e) { for (String target : targets) { assertTrue(e.getMessage().contains(target)); } } }
@Override public Boolean call() throws Exception { saltJobRunner.submit(saltConnector); if (!saltJobRunner.getTargetHostnames().isEmpty()) { throw new CloudbreakOrchestratorFailedException("There are missing nodes from job result: " + saltJobRunner.getTargetHostnames()); } return true; }
SaltCommandTracker implements OrchestratorBootstrap { @Override public Boolean call() throws Exception { saltJobRunner.submit(saltConnector); if (!saltJobRunner.getTargetHostnames().isEmpty()) { throw new CloudbreakOrchestratorFailedException("There are missing nodes from job result: " + saltJobRunner.getTargetHostnames()); } return true; } }
SaltCommandTracker implements OrchestratorBootstrap { @Override public Boolean call() throws Exception { saltJobRunner.submit(saltConnector); if (!saltJobRunner.getTargetHostnames().isEmpty()) { throw new CloudbreakOrchestratorFailedException("There are missing nodes from job result: " + saltJobRunner.getTargetHostnames()); } return true; } SaltCommandTracker(SaltConnector saltConnector, SaltJobRunner saltJobRunner); }
SaltCommandTracker implements OrchestratorBootstrap { @Override public Boolean call() throws Exception { saltJobRunner.submit(saltConnector); if (!saltJobRunner.getTargetHostnames().isEmpty()) { throw new CloudbreakOrchestratorFailedException("There are missing nodes from job result: " + saltJobRunner.getTargetHostnames()); } return true; } SaltCommandTracker(SaltConnector saltConnector, SaltJobRunner saltJobRunner); @Override Boolean call(); @Override String toString(); }
SaltCommandTracker implements OrchestratorBootstrap { @Override public Boolean call() throws Exception { saltJobRunner.submit(saltConnector); if (!saltJobRunner.getTargetHostnames().isEmpty()) { throw new CloudbreakOrchestratorFailedException("There are missing nodes from job result: " + saltJobRunner.getTargetHostnames()); } return true; } SaltCommandTracker(SaltConnector saltConnector, SaltJobRunner saltJobRunner); @Override Boolean call(); @Override String toString();  }