public BlockUntilInitScriptStatusIsZeroThenReturnOutput future() { ExecResponse returnVal = super.doCall(); if (returnVal.getExitStatus() != 0) { IllegalStateException e = new IllegalStateException(String.format( "instance: %s on node: %s had non-zero exit status: %s", init.getInstanceName(), getNode().getId(), returnVal)); eventBus.post(new StatementOnNodeFailure(init, node, e)); throw e; } return statusFactory.create(this).init(); }
@Override public BlockUntilInitScriptStatusIsZeroThenReturnOutput submit(NodeMetadata node, Statement script, RunScriptOptions options) { checkNotNull(node, "node"); checkNotNull(script, "script"); checkNotNull(options, "options"); options.shouldWrapInInitScript(); return factory.backgroundAndBlockOnComplete(node, script, options).init().future(); } }
replay(sshClient); RunScriptOnNodeAsInitScriptUsingSshAndBlockUntilComplete testMe = new RunScriptOnNodeAsInitScriptUsingSshAndBlockUntilComplete( statusFactory, timeouts, Functions.forMap(ImmutableMap.of(node, sshClient)), eventBus, InitScriptConfigurationForTasks.create().appendIncrementingNumberToAnonymousTaskNames(), node, command, new RunScriptOptions()); assertEquals(testMe.getInitFile(), "/tmp/init-jclouds-script-0"); assertEquals(testMe.getNode(), node); assertEquals(testMe.getStatement(), init); testMe.init(); assertEquals(testMe.call(), new ExecResponse("out", "err", 0));
@Override public ExecResponse doCall() { try { return future().get(timeouts.scriptComplete, TimeUnit.MILLISECONDS); } catch (Throwable e) { eventBus.post(new StatementOnNodeFailure(init, node, e)); throw Throwables.propagate(e); } }
@Test(expectedExceptions = IllegalStateException.class) public void testWithoutInitThrowsIllegalStateException() { Statement command = exec("doFoo"); NodeMetadata node = new NodeMetadataBuilder().ids("id").status(Status.RUNNING).credentials( LoginCredentials.builder().user("tester").password("testpassword!").build()).build(); SshClient sshClient = createMock(SshClient.class); replay(sshClient); RunScriptOnNodeAsInitScriptUsingSshAndBlockUntilComplete testMe = new RunScriptOnNodeAsInitScriptUsingSshAndBlockUntilComplete( statusFactory, timeouts, Functions.forMap(ImmutableMap.of(node, sshClient)), eventBus, InitScriptConfigurationForTasks.create().appendIncrementingNumberToAnonymousTaskNames(), node, command, new RunScriptOptions()); testMe.call(); }
replay(sshClient); RunScriptOnNodeAsInitScriptUsingSshAndBlockUntilComplete testMe = new RunScriptOnNodeAsInitScriptUsingSshAndBlockUntilComplete( statusFactory, timeouts, Functions.forMap(ImmutableMap.of(node, sshClient)), eventBus, InitScriptConfigurationForTasks.create().appendIncrementingNumberToAnonymousTaskNames(), node, command, new RunScriptOptions().runAsRoot(false)); assertEquals(testMe.getInitFile(), "/tmp/init-jclouds-script-0"); assertEquals(testMe.getNode(), node); assertEquals(testMe.getStatement(), init); testMe.init(); assertEquals(testMe.call(), new ExecResponse("out", "err", 1));
@Override public ExecResponse doCall() { try { return future().get(timeouts.scriptComplete, TimeUnit.MILLISECONDS); } catch (Throwable e) { eventBus.post(new StatementOnNodeFailure(init, node, e)); throw Throwables.propagate(e); } }
@Test(expectedExceptions = IllegalStateException.class) public void testWithoutInitThrowsIllegalStateException() { Statement command = exec("doFoo"); NodeMetadata node = new NodeMetadataBuilder().ids("id").status(Status.RUNNING).credentials( LoginCredentials.builder().user("tester").password("testpassword!").build()).build(); SshClient sshClient = createMock(SshClient.class); replay(sshClient); RunScriptOnNodeAsInitScriptUsingSshAndBlockUntilComplete testMe = new RunScriptOnNodeAsInitScriptUsingSshAndBlockUntilComplete( statusFactory, timeouts, Functions.forMap(ImmutableMap.of(node, sshClient)), eventBus, InitScriptConfigurationForTasks.create().appendIncrementingNumberToAnonymousTaskNames(), node, command, new RunScriptOptions()); testMe.call(); }
replay(sshClient); RunScriptOnNodeAsInitScriptUsingSshAndBlockUntilComplete testMe = new RunScriptOnNodeAsInitScriptUsingSshAndBlockUntilComplete( statusFactory, timeouts, Functions.forMap(ImmutableMap.of(node, sshClient)), eventBus, InitScriptConfigurationForTasks.create().appendIncrementingNumberToAnonymousTaskNames(), node, command, new RunScriptOptions().runAsRoot(false)); assertEquals(testMe.getInitFile(), "/tmp/init-jclouds-script-0"); assertEquals(testMe.getNode(), node); assertEquals(testMe.getStatement(), init); testMe.init(); assertEquals(testMe.call(), new ExecResponse("out", "err", 0));
@Override public BlockUntilInitScriptStatusIsZeroThenReturnOutput submit(NodeMetadata node, Statement script, RunScriptOptions options) { checkNotNull(node, "node"); checkNotNull(script, "script"); checkNotNull(options, "options"); options.shouldWrapInInitScript(); return factory.backgroundAndBlockOnComplete(node, script, options).init().future(); } }
public BlockUntilInitScriptStatusIsZeroThenReturnOutput future() { ExecResponse returnVal = super.doCall(); if (returnVal.getExitStatus() != 0) { IllegalStateException e = new IllegalStateException(String.format( "instance: %s on node: %s had non-zero exit status: %s", init.getInstanceName(), getNode().getId(), returnVal)); eventBus.post(new StatementOnNodeFailure(init, node, e)); throw e; } return statusFactory.create(this).init(); }
@Override public ExecResponse doCall() { try { return future().get(timeouts.scriptComplete, TimeUnit.MILLISECONDS); } catch (Throwable e) { eventBus.post(new StatementOnNodeFailure(init, node, e)); throw Throwables.propagate(e); } }
replay(sshClient); RunScriptOnNodeAsInitScriptUsingSshAndBlockUntilComplete testMe = new RunScriptOnNodeAsInitScriptUsingSshAndBlockUntilComplete( statusFactory, timeouts, Functions.forMap(ImmutableMap.of(node, sshClient)), eventBus, InitScriptConfigurationForTasks.create().appendIncrementingNumberToAnonymousTaskNames(), node, command, new RunScriptOptions()); assertEquals(testMe.getInitFile(), "/tmp/init-jclouds-script-0"); assertEquals(testMe.getNode(), node); assertEquals(testMe.getStatement(), init); testMe.init(); assertEquals(testMe.call(), new ExecResponse("out", "err", 0));
@Override public BlockUntilInitScriptStatusIsZeroThenReturnOutput submit(NodeMetadata node, Statement script, RunScriptOptions options) { checkNotNull(node, "node"); checkNotNull(script, "script"); checkNotNull(options, "options"); options.shouldWrapInInitScript(); return factory.backgroundAndBlockOnComplete(node, script, options).init().future(); } }
public BlockUntilInitScriptStatusIsZeroThenReturnOutput future() { ExecResponse returnVal = super.doCall(); if (returnVal.getExitStatus() != 0) { IllegalStateException e = new IllegalStateException(String.format( "instance: %s on node: %s had non-zero exit status: %s", init.getInstanceName(), getNode().getId(), returnVal)); eventBus.post(new StatementOnNodeFailure(init, node, e)); throw e; } return statusFactory.create(this).init(); }
@Override public ExecResponse doCall() { try { return future().get(timeouts.scriptComplete, TimeUnit.MILLISECONDS); } catch (Throwable e) { eventBus.post(new StatementOnNodeFailure(init, node, e)); throw Throwables.propagate(e); } }
replay(sshClient); RunScriptOnNodeAsInitScriptUsingSshAndBlockUntilComplete testMe = new RunScriptOnNodeAsInitScriptUsingSshAndBlockUntilComplete( statusFactory, timeouts, Functions.forMap(ImmutableMap.of(node, sshClient)), eventBus, InitScriptConfigurationForTasks.create().appendIncrementingNumberToAnonymousTaskNames(), node, command, new RunScriptOptions()); assertEquals(testMe.getInitFile(), "/tmp/init-jclouds-script-0"); assertEquals(testMe.getNode(), node); assertEquals(testMe.getStatement(), init); testMe.init(); assertEquals(testMe.call(), new ExecResponse("out", "err", 0));
@Override public BlockUntilInitScriptStatusIsZeroThenReturnOutput submit(NodeMetadata node, Statement script, RunScriptOptions options) { checkNotNull(node, "node"); checkNotNull(script, "script"); checkNotNull(options, "options"); options.shouldWrapInInitScript(); return factory.backgroundAndBlockOnComplete(node, script, options).init().future(); } }
public BlockUntilInitScriptStatusIsZeroThenReturnOutput future() { ExecResponse returnVal = super.doCall(); if (returnVal.getExitStatus() != 0) { IllegalStateException e = new IllegalStateException(String.format( "instance: %s on node: %s had non-zero exit status: %s", init.getInstanceName(), getNode().getId(), returnVal)); eventBus.post(new StatementOnNodeFailure(init, node, e)); throw e; } return statusFactory.create(this).init(); }
replay(sshClient); RunScriptOnNodeAsInitScriptUsingSshAndBlockUntilComplete testMe = new RunScriptOnNodeAsInitScriptUsingSshAndBlockUntilComplete( statusFactory, timeouts, Functions.forMap(ImmutableMap.of(node, sshClient)), eventBus, InitScriptConfigurationForTasks.create().appendIncrementingNumberToAnonymousTaskNames(), node, command, new RunScriptOptions().runAsRoot(false)); assertEquals(testMe.getInitFile(), "/tmp/init-jclouds-script-0"); assertEquals(testMe.getNode(), node); assertEquals(testMe.getStatement(), init); testMe.init(); assertEquals(testMe.call(), new ExecResponse("out", "err", 1));