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

Examples of com.dtolabs.rundeck.core.execution.workflow.steps.StepExecutionResult


            assertTrue(result.isSuccess());
            assertNotNull(result.getResultSet());
            final List<StepExecutionResult> test1 = result.getResultSet();
            assertEquals(3, test1.size());
            for (final int i : new int[]{0, 1, 2}) {
                final StepExecutionResult interpreterResult = test1.get(i);
                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);
View Full Code Here


            if (null != result.getException()) {
                result.getException().printStackTrace(System.out);
            }
            assertFalse(result.isSuccess());
            assertNull("threw exception: " + result.getException(), result.getException());
            StepExecutionResult result1 = result.getResultSet().get(1);
            final DispatcherResult executionResult = NodeDispatchStepExecutor.extractDispatcherResult(result1);
            assertNotNull(executionResult.getResults());
            assertEquals(1, executionResult.getResults().size());
            assertNotNull(executionResult.getResults().get(testnode));
            final StatusResult testnode1 = executionResult.getResults().get(testnode);
            assertNotNull(testnode1);
            assertTrue(testnode1 instanceof testResult);
            testResult failResult = (testResult) testnode1;
            assertEquals(1, failResult.flag);

            assertNotNull(result.getResultSet());
            final List<StepExecutionResult> test1 = result.getResultSet();
            assertEquals(2, test1.size());
            for (final int i : new int[]{0, 1}) {
                final StepExecutionResult interpreterResult = test1.get(i);
                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);
View Full Code Here

            assertNotNull(result.getResultSet());
            final List<StepExecutionResult> test1 = result.getResultSet();
            assertEquals(3, test1.size());
            for (final int i : new int[]{0, 1, 2}) {
                final StepExecutionResult interpreterResult = test1.get(i);
                assertTrue(NodeDispatchStepExecutor.isWrappedDispatcherResult(interpreterResult));
                final DispatcherResult dr = NodeDispatchStepExecutor.extractDispatcherResult(interpreterResult);
                assertEquals(1, dr.getResults().size());
                final NodeStepResult nrs = dr.getResults().values().iterator().next();
                assertTrue("unexpected class: " + nrs.getClass(),
View Full Code Here

            if (!result.isSuccess() && null != result.getException()) {
                result.getException().printStackTrace(System.err);
            }
            assertFalse(result.isSuccess());
            assertNull("threw exception: " + result.getException(), result.getException());
            StepExecutionResult result1 = result.getResultSet().get(0);
            final DispatcherResult executionResult
                = NodeDispatchStepExecutor.extractDispatcherResult(result1);
            assertNotNull(executionResult.getResults());
            assertEquals(1, executionResult.getResults().size());
            assertNotNull(executionResult.getResults().get(testnode));
            final StatusResult testnode1 = executionResult.getResults().get(testnode);
            assertNotNull(testnode1);
            assertTrue(testnode1 instanceof testResult);
            testResult failResult = (testResult) testnode1;
            assertEquals(0, failResult.flag);

            assertEquals(1, result.getResultSet().size());
            assertNotNull(result.getResultSet());
            final List<StepExecutionResult> test1 = result.getResultSet();
            System.err.println("results: "+test1);
            assertEquals(1, test1.size());
            final int i =0;
            final StepExecutionResult interpreterResult = test1.get(i);
            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);
View Full Code Here

            int resultIndex =0;
            int stepNum=0;
            {
                //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);
View Full Code Here

            int resultIndex =0;
            int stepNum=0;
            {
                //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);
View Full Code Here

        if (null != executionContext.getExecutionListener()) {
            executionContext.getExecutionListener().log(Constants.DEBUG_LEVEL,
                                                        c + ": Workflow step executing: " + cmd);
        }
        StepExecutionResult result;
        try {
            result = framework.getExecutionService().executeStep(
                ExecutionContextImpl.builder(executionContext).stepNumber(c).build(),
                cmd);
            if (!result.isSuccess()) {
                failedMap.put(c, result);
            }
        } catch (StepException e) {
            result = StepExecutionResultImpl.wrapStepException(e);
            failedMap.put(c, result);
View Full Code Here

            StepExecutionContext stepContext = replaceFailedNodesListenerInContext(executionContext,
                stepCaptureFailedNodesListener);
            Map<String,NodeStepResult> nodeFailures;

            //execute the step item, and store the results
            StepExecutionResult stepResult=null;
            Map<Integer, StepExecutionResult> stepFailedMap = new HashMap<Integer, StepExecutionResult>();
            stepResult = executeWFItem(stepContext, stepFailedMap, c, cmd);
            stepSuccess = stepResult.isSuccess();
            nodeFailures = stepCaptureFailedNodesListener.getFailedNodes();

            if(null!=executionContext.getExecutionListener() && null!=executionContext.getExecutionListener().getFailedNodesListener()) {
                executionContext.getExecutionListener().getFailedNodesListener().matchedNodes(
                    stepCaptureFailedNodesListener.getMatchedNodes());

            }

            try {
                if(!stepSuccess && hasHandler) {
                    final HasFailureHandler handles = (HasFailureHandler) cmd;
                    final StepExecutionItem handler = handles.getFailureHandler();
                    if (null != handler) {
                        //if there is a failure, and a failureHandler item, execute the failure handler
                        //set keepgoing=false, and store the results
                        //will throw an exception on failure because keepgoing=false

                        NodeRecorder handlerCaptureFailedNodesListener = new NodeRecorder();
                        StepExecutionContext handlerExecContext = replaceFailedNodesListenerInContext(executionContext,
                            handlerCaptureFailedNodesListener);

                        //if multi-node, determine set of nodes to run handler on: (failed node list only)
                        if(stepCaptureFailedNodesListener.getMatchedNodes().size()>1) {
                            HashSet<String> failedNodeList = new HashSet<String>(
                                stepCaptureFailedNodesListener.getFailedNodes().keySet());

                            handlerExecContext = new ExecutionContextImpl.Builder(handlerExecContext).nodeSelector(
                                SelectorUtils.nodeList(failedNodeList)).build();

                        }

                        if(null!=stepResult) {
                            //add step failure data to data context
                            handlerExecContext = addStepFailureContextData(stepResult, handlerExecContext);

                            //extract node-specific failure and set as node-context data
                            handlerExecContext = addNodeStepFailureContextData(stepResult, handlerExecContext);
                        }
                        if (null != wlistener) {
                            wlistener.beginWorkflowItemErrorHandler(c, cmd);
                        }

                        Map<Integer, StepExecutionResult> handlerFailedMap = new HashMap<Integer, StepExecutionResult>();
                        StepExecutionResult handlerResult = executeWFItem(handlerExecContext,
                                                                          handlerFailedMap,
                                                                          c,
                                                                          handler);
                        boolean handlerSuccess = handlerResult.isSuccess();

                        if (null != wlistener) {
                            wlistener.finishWorkflowItemErrorHandler(c, cmd, handlerResult);
                        }
                        //handle success conditions:
View Full Code Here

        final Map<Integer, StepExecutionResult> failedMap) {

        final Map<String, Collection<StepExecutionResult>> failures
            = new HashMap<String, Collection<StepExecutionResult>>();
        for (final Map.Entry<Integer, StepExecutionResult> entry : failedMap.entrySet()) {
            final StepExecutionResult o = entry.getValue();

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

        }
        static Map<Integer,NodeStepResult> extractStepFailures(WorkflowExecutionResult result, INodeEntry node) {
            Map<Integer, NodeStepResult> results = new HashMap<Integer, NodeStepResult>();
            for (final Map.Entry<Integer, StepExecutionResult> entry : result.getStepFailures().entrySet()) {
                int num = entry.getKey();
                StepExecutionResult executionResult = entry.getValue();
                if (NodeDispatchStepExecutor.isWrappedDispatcherResult(executionResult)) {
                    DispatcherResult dispatcherResult
                        = NodeDispatchStepExecutor.extractDispatcherResult(executionResult);
                    NodeStepResult stepResult = dispatcherResult.getResults().get(node.getNodename());
                    if (null != stepResult) {
View Full Code Here

TOP

Related Classes of com.dtolabs.rundeck.core.execution.workflow.steps.StepExecutionResult

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.