Package com.dtolabs.rundeck.core.execution.workflow.steps.node

Examples of com.dtolabs.rundeck.core.execution.workflow.steps.node.NodeStepResult


            {
                //first step result
                final StepExecutionResult interpreterResult = test1.get(resultIndex);
                final DispatcherResult dr = NodeDispatchStepExecutor.extractDispatcherResult(interpreterResult);
                assertEquals(1, dr.getResults().size());
                final NodeStepResult nrs = dr.getResults().values().iterator().next();
                assertTrue("unexpected class: " + nrs.getClass(),
                           nrs instanceof testResult);
                testResult val = (testResult) nrs;
                assertEquals(0, val.flag);
                assertFalse(val.isSuccess());


                final StepExecutionItem executionItem1 = interpreterMock.executionItemList.get(stepNum);
                assertTrue("wrong class: " + executionItem1.getClass().getName(),
                    executionItem1 instanceof ExecCommandExecutionItem);
                ExecCommandExecutionItem execItem = (ExecCommandExecutionItem) executionItem1;
                assertNotNull(execItem.getCommand());
                assertEquals(3, execItem.getCommand().length);
                assertEquals("a", execItem.getCommand()[0]);
                assertEquals("2", execItem.getCommand()[1]);
                assertEquals("command", execItem.getCommand()[2]);


                final ExecutionContext executionContext = interpreterMock.executionContextList.get(stepNum);
                assertEquals(TEST_PROJECT, executionContext.getFrameworkProject());

                assertNotNull(executionContext.getDataContext());
                assertNotNull(executionContext.getDataContext().get("node"));
                assertEquals(0, executionContext.getLoglevel());
                assertEquals("user1", executionContext.getUser());
                assertEquals(nodeset, executionContext.getNodeSelector());
            }

            resultIndex=1;
//
//            {
//                //failure handler result
//                final StepExecutionResult interpreterResult = test1.get(resultIndex);
//                final DispatcherResult dr = NodeDispatchStepExecutor.extractDispatcherResult(interpreterResult);
//                assertEquals(1, dr.getResults().size());
//                final NodeStepResult nrs = dr.getResults().values().iterator().next();
//                assertTrue("unexpected class: " + nrs.getClass(),
//                           nrs instanceof testResult);
//                testResult val = (testResult) nrs;
//                assertEquals(0, val.flag);
//                assertFalse(val.isSuccess());
//
//                final StepExecutionItem executionItemX = handlerInterpreterMock.executionItemList.get(stepNum);
//                assertTrue("wrong class: " + executionItemX.getClass().getName(),
//                    executionItemX instanceof ScriptFileCommandExecutionItem);
//                ScriptFileCommandExecutionItem execItemX = (ScriptFileCommandExecutionItem) executionItemX;
//                assertNotNull(execItemX.getScript());
//                assertNotNull(execItemX.getArgs());
//                assertEquals("failure handler script", execItemX.getScript());
//                assertEquals(3, execItemX.getArgs().length);
//                assertEquals("failure", execItemX.getArgs()[0]);
//                assertEquals("script", execItemX.getArgs()[1]);
//                assertEquals("args", execItemX.getArgs()[2]);
//
//
//                final ExecutionContext executionContextX = handlerInterpreterMock.executionContextList.get(stepNum);
//                assertEquals(TEST_PROJECT, executionContextX.getFrameworkProject());
//                assertNull(executionContextX.getDataContext());
//                assertEquals(0, executionContextX.getLoglevel());
//                assertEquals("user1", executionContextX.getUser());
//                assertEquals(nodeset, executionContextX.getNodeSelector());
//                assertNull(executionContextX.getArgs());
//            }

//            resultIndex=2;
            stepNum = 1;
            {
                //second step result
                final StepExecutionResult interpreterResult = test1.get(resultIndex);
                final DispatcherResult dr = NodeDispatchStepExecutor.extractDispatcherResult(interpreterResult);
                assertEquals(1, dr.getResults().size());
                final NodeStepResult nrs = dr.getResults().values().iterator().next();
                assertTrue("unexpected class: " + nrs.getClass(),
                           nrs instanceof testResult);
                testResult val = (testResult) nrs;
                assertEquals(1, val.flag);
                assertTrue(val.isSuccess());
View Full Code Here


            {
                //failure handler result
                final StepExecutionResult interpreterResult = test1.get(resultIndex);
                final DispatcherResult dr = NodeDispatchStepExecutor.extractDispatcherResult(interpreterResult);
                assertEquals(1, dr.getResults().size());
                final NodeStepResult nrs = dr.getResults().values().iterator().next();
                assertTrue("unexpected class: " + nrs.getClass(),
                           nrs instanceof testResult);
                testResult val = (testResult) nrs;
                assertEquals(0, val.flag);
                assertTrue(val.isSuccess());

                final StepExecutionItem executionItemX = handlerInterpreterMock.executionItemList.get(stepNum);
                assertTrue("wrong class: " + executionItemX.getClass().getName(),
                    executionItemX instanceof ScriptFileCommandExecutionItem);
                ScriptFileCommandExecutionItem execItemX = (ScriptFileCommandExecutionItem) executionItemX;
                assertNotNull(execItemX.getScript());
                assertNotNull(execItemX.getArgs());
                assertEquals("failure handler script", execItemX.getScript());
                assertEquals(3, execItemX.getArgs().length);
                assertEquals("failure", execItemX.getArgs()[0]);
                assertEquals("script", execItemX.getArgs()[1]);
                assertEquals("args", execItemX.getArgs()[2]);


                final ExecutionContext executionContextX = handlerInterpreterMock.executionContextList.get(stepNum);
                assertEquals(TEST_PROJECT, executionContextX.getFrameworkProject());

                assertNotNull(executionContextX.getDataContext());
                assertNotNull(executionContextX.getDataContext().get("node"));
                assertEquals(0, executionContextX.getLoglevel());
                assertEquals("user1", executionContextX.getUser());
                assertEquals(nodeset, executionContextX.getNodeSelector());
            }

            resultIndex=1;
            stepNum = 1;
            {
                //second step result
                final StepExecutionResult interpreterResult = test1.get(resultIndex);
                final DispatcherResult dr = NodeDispatchStepExecutor.extractDispatcherResult(interpreterResult);
                assertEquals(1, dr.getResults().size());
                final NodeStepResult nrs = dr.getResults().values().iterator().next();
                assertTrue("unexpected class: " + nrs.getClass(),
                           nrs instanceof testResult);
                testResult val = (testResult) nrs;
                assertEquals(1, val.flag);
                assertTrue(val.isSuccess());
View Full Code Here

            return "Dispatch successful (" + results.size() + " nodes)";
        }else{
            int i=0;
            ArrayList<String> names = new ArrayList<String>();
            for (final String s : results.keySet()) {
                NodeStepResult stepResult = results.get(s);
                if(!stepResult.isSuccess()){
                    i++;
                    names.add(s+": "+stepResult.toString());
                }
            }
            return "Dispatch failed on " + i + " nodes: " + names;
        }
    }
View Full Code Here

                if (thread.isInterrupted()
                    || thread instanceof ServiceThreadBase && ((ServiceThreadBase) thread).isAborted()) {
                    interrupted = true;
                    break;
                }
                final NodeStepResult result;

                //execute the step or dispatchable
                if (null != item) {
                    result = framework.getExecutionService().executeNodeStep(context, item, node);
                } else {
                    result = toDispatch.dispatch(context, node);

                }
                resultMap.put(node.getNodename(), result);
                if (!result.isSuccess()) {
                    success = false;
//                    context.getExecutionListener().log(Constants.ERR_LEVEL,
//                        "Failed execution for node " + node.getNodename() + ": " + result);
                    failures.put(node.getNodename(), result);
                    if (!keepgoing) {
View Full Code Here

    private Callable dispatchableCallable(final ExecutionContext context, final Dispatchable toDispatch,
                                          final HashMap<String, NodeStepResult> resultMap, final INodeEntry node,
                                          final Map<String, NodeStepResult> failureMap) {
        return new Callable() {
            public Object call() throws Exception {
                final NodeStepResult dispatch = toDispatch.dispatch(context, node);
                resultMap.put(node.getNodename(), dispatch);
                if (!dispatch.isSuccess()) {
                    failureMap.put(node.getNodename(), dispatch);
                    throw new DispatchFailure(node.getNodename());
                }
                return dispatch;
            }
View Full Code Here

        }

        @Override
        public NodeStepResult call() {
            try {
                final NodeStepResult interpreterResult = framework.getExecutionService().executeNodeStep(
                    context, item, node);
                if (!interpreterResult.isSuccess()) {
                    failureMap.put(node.getNodename(), interpreterResult);
                }
                resultMap.put(node.getNodename(), interpreterResult);
                return interpreterResult;
            } catch (NodeStepException e) {
View Full Code Here

                                                            Reason.NodeDispatchFailure,
                                                            "Node dispatch failed");
            //extract failed nodes
            ArrayList<String> nodeNames = new ArrayList<String>();
            for (String nodeName : dispatcherResult.getResults().keySet()) {
                NodeStepResult nodeStepResult = dispatcherResult.getResults().get(nodeName);
                if(!nodeStepResult.isSuccess()) {
                    nodeNames.add(nodeName);
                }
            }
            if(!nodeNames.isEmpty()){
                result.getFailureData().put(FAILURE_DATA_FAILED_NODES, StringUtils.join(nodeNames, ","));
View Full Code Here

            HashMap<String, NodeStepResult> stringNodeStepResultHashMap = new HashMap<String,
                    NodeStepResult>();
            resultMap = stringNodeStepResultHashMap;
            NodeStepException nodeStepException = exception.getNodeStepException();
            if (null != nodeStepException && null != exception.getNode()) {
                NodeStepResult nodeExecutorResult = nodeStepResultFromNodeStepException(
                        exception.getNode(),
                        nodeStepException
                );
                stringNodeStepResultHashMap.put(
                        nodeStepException.getNodeName(),
                        nodeExecutorResult
                );
            }
        } else {
            return handlerExecContext;
        }
        ExecutionContextImpl.Builder builder = ExecutionContextImpl.builder(handlerExecContext);
        if(null!= resultMap){
            for (final Map.Entry<String, ? extends NodeStepResult> dentry : resultMap.entrySet()) {
                String nodename = dentry.getKey();
                NodeStepResult stepResult = dentry.getValue();
                HashMap<String, String> resultData = new HashMap<String, String>();
                if (null != stepResult.getFailureData()) {
                    //convert values to string
                    for (final Map.Entry<String, Object> entry : stepResult.getFailureData().entrySet()) {
                        resultData.put(entry.getKey(), entry.getValue().toString());
                    }
                }
                FailureReason reason = stepResult.getFailureReason();
                if (null == reason) {
                    reason = StepFailureReason.Unknown;
                }
                resultData.put("reason", reason.toString());
                String message = stepResult.getFailureMessage();
                if (null == message) {
                    message = "No message";
                }
                resultData.put("message", message);
                //add to data context
View Full Code Here

            if (NodeDispatchStepExecutor.isWrappedDispatcherResult(o)) {
                //indicates dispatcher returned node results
                final DispatcherResult dispatcherResult = NodeDispatchStepExecutor.extractDispatcherResult(o);

                for (final String s : dispatcherResult.getResults().keySet()) {
                    final NodeStepResult interpreterResult = dispatcherResult.getResults().get(s);
                    if (!failures.containsKey(s)) {
                        failures.put(s, new ArrayList<StepExecutionResult>());
                    }
                    failures.get(s).add(interpreterResult);
                }
View Full Code Here

        //unroll each workflow result, append the result of each step into map of node results
        //merge each step result with the mergedStepResults

        //DispatcherResult contains map {nodename: NodeStepResult}
        for (final String nodeName : dispatcherResult.getResults().keySet()) {
            final NodeStepResult stepResult = dispatcherResult.getResults().get(nodeName);

            //This NodeStepResult is produced by the DispatchedWorkflow wrapper
            WorkflowExecutionResult result = DispatchedWorkflow.extractWorkflowResult(stepResult);

            if (null == failures.get(nodeName)) {
                failures.put(nodeName, new ArrayList<StepExecutionResult>());
            }

            //extract failures for this node
            final Collection<StepExecutionResult> thisNodeFailures = result.getNodeFailures().get(nodeName);
            if (null != thisNodeFailures && thisNodeFailures.size() > 0) {
                failures.get(nodeName).addAll(thisNodeFailures);
            }

            //extract failures by step (for this node)
            Map<Integer, NodeStepResult> perStepFailures = DispatchedWorkflow.extractStepFailures(result,
                                                                                                  stepResult.getNode());
            for (final Map.Entry<Integer, NodeStepResult> entry : perStepFailures.entrySet()) {
                Integer stepNum = entry.getKey();
                NodeStepResult value = entry.getValue();
                if (null == mergedStepFailures.get(stepNum)) {
                    mergedStepFailures.put(stepNum, new HashMap<String, NodeStepResult>());
                }
                mergedStepFailures.get(stepNum).put(nodeName, value);
            }
View Full Code Here

TOP

Related Classes of com.dtolabs.rundeck.core.execution.workflow.steps.node.NodeStepResult

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.