Package com.dtolabs.rundeck.core.utils

Examples of com.dtolabs.rundeck.core.utils.NodeSet


        {
            ExecTool main = newExecTool();
            main.parseArgs(new String[]{"-p", TEST_EXEC_TOOL_PROJECT, "-v", "-X", "homestar", "-I", "os-name=Testux"});
            Map exmap = main.parseExcludeArgs(nodeKeys);
            Map incmap = main.parseIncludeArgs(nodeKeys);
            NodeSet nodeset = main.createNodeSet(incmap, exmap);
            assertTrue(nodeset.getExclude().isDominant());
            assertFalse(nodeset.getInclude().isDominant());
            final Collection c = main.filterNodes().getNodes();
            final TestFormatter formatter = new TestFormatter();
            main.setNodeFormatter(formatter);
            main.listAction();
            assertNotNull(formatter.nodes);
View Full Code Here


    public void testCreateNodeSet() throws Exception {
        {
            final ExecTool main = newExecTool();
            main.parseArgs(new String[]{"-p", TEST_EXEC_TOOL_PROJECT});
            final NodeSet set = main.createFilterNodeSelector();
            assertNotNull(set);
            assertNotNull(set.getInclude());
            assertTrue(set.getInclude().isBlank() );
            assertNotNull(set.getExclude());
            assertTrue(set.getExclude().isBlank());
            assertEquals(1,set.getThreadCount());
            assertEquals(false,set.isKeepgoing());
        }
        {
            final ExecTool main = newExecTool();
            main.parseArgs(new String[]{"-p", TEST_EXEC_TOOL_PROJECT,"-K"});
            final NodeSet set = main.createFilterNodeSelector();
            assertNotNull(set);
            assertNotNull(set.getInclude());
            assertTrue(set.getInclude().isBlank() );
            assertNotNull(set.getExclude());
            assertTrue(set.getExclude().isBlank());
            assertEquals(1,set.getThreadCount());
            assertEquals(true,set.isKeepgoing());
        }
        {
            final ExecTool main = newExecTool();
            main.parseArgs(new String[]{"-p", TEST_EXEC_TOOL_PROJECT,"-C","2"});
            final NodeSet set = main.createFilterNodeSelector();
            assertNotNull(set);
            assertNotNull(set.getInclude());
            assertTrue(set.getInclude().isBlank() );
            assertNotNull(set.getExclude());
            assertTrue(set.getExclude().isBlank());
            assertEquals(2,set.getThreadCount());
            assertEquals(false,set.isKeepgoing());
        }
        {
            final ExecTool main = newExecTool();
            main.parseArgs(new String[]{"-p", TEST_EXEC_TOOL_PROJECT,"-C","2","-I","ahostname","-X","tags=blaoen","-I","os-family=test","-X","os-version=3"});
            final NodeSet set = main.createFilterNodeSelector();
            assertNotNull(set);
            assertNotNull(set.getInclude());
            assertFalse(set.getInclude().isBlank() );
            assertEquals("ahostname",set.getInclude().getHostname() );
            assertEquals("test",set.getInclude().getOsfamily() );
            assertNotNull(set.getExclude());
            assertFalse(set.getExclude().isBlank());
            assertEquals("blaoen",set.getExclude().getTags());
            assertEquals("3",set.getExclude().getOsversion());
            assertEquals(2,set.getThreadCount());
            assertEquals(false,set.isKeepgoing());
        }
        {
            //test precedence setting, Include dominant in first position
            final ExecTool main = newExecTool();
            main.parseArgs(new String[]{"-p", TEST_EXEC_TOOL_PROJECT,"-C","2","-I","ahostname","-X","tags=blaoen"});
            final NodeSet set = main.createFilterNodeSelector();
            assertNotNull(set);
            assertNotNull(set.getInclude());
            assertFalse(set.getInclude().isBlank() );
            assertTrue(set.getInclude().isDominant() );
            assertNotNull(set.getExclude());
            assertFalse(set.getExclude().isBlank());
            assertFalse(set.getExclude().isDominant());
        }
        {
            //test precedence setting, Exclude dominant in first position
            final ExecTool main = newExecTool();
            main.parseArgs(new String[]{"-p", TEST_EXEC_TOOL_PROJECT,"-C","2","-X","ahostname","-I","tags=blaoen"});
            final NodeSet set = main.createFilterNodeSelector();
            assertNotNull(set);
            assertNotNull(set.getInclude());
            assertFalse(set.getInclude().isBlank() );
            assertFalse(set.getInclude().isDominant() );
            assertNotNull(set.getExclude());
            assertFalse(set.getExclude().isBlank());
            assertTrue(set.getExclude().isDominant());
        }
        {
            //test precedence setting, Include dominant explicitly
            final ExecTool main = newExecTool();
            main.parseArgs(new String[]{"-p", TEST_EXEC_TOOL_PROJECT,"--filter-exclude-precedence","false","-C","2","-X","ahostname","-I","tags=blaoen"});
            final NodeSet set = main.createFilterNodeSelector();
            assertNotNull(set);
            assertNotNull(set.getInclude());
            assertFalse(set.getInclude().isBlank() );
            assertTrue(set.getInclude().isDominant() );
            assertNotNull(set.getExclude());
            assertFalse(set.getExclude().isBlank());
            assertFalse(set.getExclude().isDominant());
        }
        {
            //test precedence setting, Exclude dominant explicitly
            final ExecTool main = newExecTool();
            main.parseArgs(new String[]{"-p", TEST_EXEC_TOOL_PROJECT,"--filter-exclude-precedence","true","-C","2","-I","ahostname","-X","tags=blaoen"});
            final NodeSet set = main.createFilterNodeSelector();
            assertNotNull(set);
            assertNotNull(set.getInclude());
            assertFalse(set.getInclude().isBlank() );
            assertFalse(set.getInclude().isDominant() );
            assertNotNull(set.getExclude());
            assertFalse(set.getExclude().isBlank());
            assertTrue(set.getExclude().isDominant());
        }
    }
View Full Code Here

        }

        {
            //test empty workflow
            final NodeSet nodeset = new NodeSet();
            final WorkflowImpl workflow = new WorkflowImpl(new ArrayList<StepExecutionItem>(), 1, false,
                WorkflowStrategy.STEP_FIRST);
            final WorkflowExecutionItemImpl executionItem = new WorkflowExecutionItemImpl(workflow);
            final StepFirstWorkflowStrategy strategy = new StepFirstWorkflowStrategy(testFramework);
            final StepExecutionContext context =
                new ExecutionContextImpl.Builder()
                    .frameworkProject(TEST_PROJECT)
                    .user("user1")
                    .nodeSelector(nodeset)
                    .executionListener(new testListener())
                    .framework(testFramework)
                    .nodes(testFramework.filterNodeSet(nodeset, TEST_PROJECT, null))
                    .build();

            //setup testInterpreter for all command types
            final NodeStepExecutionService interpreterService = NodeStepExecutionService.getInstanceForFramework(
                testFramework);
            testInterpreter interpreterMock = new testInterpreter();
            interpreterService.registerInstance("exec", interpreterMock);
            interpreterService.registerInstance("script", interpreterMock);
            interpreterService.registerInstance(WorkflowExecutionItem.COMMAND_TYPE_NODE_FIRST, interpreterMock);
            interpreterService.registerInstance(WorkflowExecutionItem.COMMAND_TYPE_STEP_FIRST, interpreterMock);
//            interpreterService.registerInstance(JobExecutionItem.COMMAND_TYPE, interpreterMock);


            final WorkflowExecutionResult result = strategy.executeWorkflow(context, executionItem);

            assertNotNull(result);
            if (!result.isSuccess() && null != result.getException()) {
                result.getException().printStackTrace(System.err);
            }
            assertNull("threw exception: " + result.getException(), result.getException());
            assertTrue(result.isSuccess());
            assertEquals(0, interpreterMock.executionItemList.size());
        }
        {
            //test undefined workflow item
            final NodeSet nodeset = new NodeSet();
            final ArrayList<StepExecutionItem> commands = new ArrayList<StepExecutionItem>();
            commands.add(new testWorkflowCmdItem());

            final WorkflowImpl workflow = new WorkflowImpl(commands, 1, false, WorkflowStrategy.STEP_FIRST);
            final WorkflowExecutionItemImpl executionItem = new WorkflowExecutionItemImpl(workflow);
            final StepFirstWorkflowStrategy strategy = new StepFirstWorkflowStrategy(testFramework);
            final StepExecutionContext context =
                new ExecutionContextImpl.Builder()
                    .frameworkProject(TEST_PROJECT)
                    .user("user1")
                    .nodeSelector(nodeset.nodeSelectorWithDefaultAll())
                    .executionListener(new testListener())
                    .framework(testFramework)
                    .nodes(testFramework.filterNodeSet(nodeset.nodeSelectorWithDefaultAll(), TEST_PROJECT, null))
                    .build();

            //setup testInterpreter for all command types
            final NodeStepExecutionService interpreterService = NodeStepExecutionService.getInstanceForFramework(
                testFramework);
View Full Code Here

    public void testMultipleNodes() throws Exception{

        {
            //test jobref item
            final NodeSet nodeset = new NodeSet();
            nodeset.createInclude().setName(".*");
            final ArrayList<StepExecutionItem> commands = new ArrayList<StepExecutionItem>();
            final testWorkflowCmdItem item = new testWorkflowCmdItem();
            item.type = "my-type";
            commands.add(item);
            final WorkflowImpl workflow = new WorkflowImpl(commands, 1, false,
View Full Code Here

    }
    public void testMultipleItemsAndNodes() throws Exception{

        {
            //test jobref item
            final NodeSet nodeset = new NodeSet();
            nodeset.createInclude().setName(".*");
            final ArrayList<StepExecutionItem> commands = new ArrayList<StepExecutionItem>();
            final testWorkflowCmdItem item = new testWorkflowCmdItem();
            item.flag=0;
            item.type = "my-type";
            commands.add(item);
View Full Code Here

    public void testGetNodeDispatcher() throws Exception {
        final Framework frameworkInstance = getFrameworkInstance();
        final NodeDispatcherService service = NodeDispatcherService.getInstanceForFramework(
            frameworkInstance);
        {
            final NodeSet nodeSet = new NodeSet();
            nodeSet.createInclude().setName(".*");
            nodeSet.setThreadCount(2);
            //get node dispatcher for a context.  nodeset>1 and threadcount>1 returns parallel provider
            final ExecutionContext context = ExecutionContextImpl.builder()
                .frameworkProject(PROJ_NAME)
                .framework(frameworkInstance)
                .user("blah")
                .nodeSelector(nodeSet)
                .nodes(frameworkInstance.filterNodeSet(nodeSet,PROJ_NAME,null))
                .threadCount(nodeSet.getThreadCount())
                .keepgoing(nodeSet.isKeepgoing())
                .build();


            final NodeDispatcher nodeDispatcher = service.getNodeDispatcher(context);
            assertNotNull(nodeDispatcher);
            assertTrue(nodeDispatcher instanceof ParallelNodeDispatcher);

        }

        {   //get node dispatcher for a context.  nodeset>1 and threadcount<2 returns sequential provider

            final NodeSet nodeSet = new NodeSet();
            nodeSet.createInclude().setName(".*");
            nodeSet.setThreadCount(1);
            final ExecutionContext context = ExecutionContextImpl.builder()
                .frameworkProject(PROJ_NAME)
                .framework(frameworkInstance)
                .user("blah")
                .nodeSelector(nodeSet)
                .threadCount(nodeSet.getThreadCount())
                .keepgoing(nodeSet.isKeepgoing())
                .build();


            final NodeDispatcher nodeDispatcher = service.getNodeDispatcher(context);
            assertNotNull(nodeDispatcher);
            assertTrue(nodeDispatcher instanceof SequentialNodeDispatcher);

        }

        {   //get node dispatcher for a context.  nodeset<2 and threadcount<2 returns sequential provider

            final NodeSet nodeSet = new NodeSet();
            nodeSet.setSingleNodeName("test1");
            nodeSet.setThreadCount(1);
            final ExecutionContext context = ExecutionContextImpl.builder()
                .frameworkProject(PROJ_NAME)
                .framework(frameworkInstance)
                .user("blah")
                .nodeSelector(nodeSet)
                .threadCount(nodeSet.getThreadCount())
                .keepgoing(nodeSet.isKeepgoing())
                .build();


            final NodeDispatcher nodeDispatcher = service.getNodeDispatcher(context);
            assertNotNull(nodeDispatcher);
            assertTrue(nodeDispatcher instanceof SequentialNodeDispatcher);

        }

        {   //get node dispatcher for a context.  nodeset<2 and threadcount>1 returns sequential provider

            final NodeSet nodeSet = new NodeSet();
            nodeSet.setSingleNodeName("test1");
            nodeSet.setThreadCount(2);
            final ExecutionContext context = ExecutionContextImpl.builder()
                .frameworkProject(PROJ_NAME)
                .framework(frameworkInstance)
                .user("blah")
                .nodeSelector(nodeSet)
                .nodes(frameworkInstance.filterNodeSet(nodeSet,PROJ_NAME,null))
                .threadCount(nodeSet.getThreadCount())
                .keepgoing(nodeSet.isKeepgoing())
                .build();


            final NodeDispatcher nodeDispatcher = service.getNodeDispatcher(context);
            assertNotNull(nodeDispatcher);
View Full Code Here

    public void testExtResources() throws Exception {
        final Framework frameworkInstance = getFrameworkInstance();
        final NodeDispatcherService service = NodeDispatcherService.getInstanceForFramework(
            frameworkInstance);
        {   //use test-1 file
            final NodeSet nodeSet = new NodeSet();
            nodeSet.createInclude().setTags("priority1"); //matches single nodes in test1 file
            nodeSet.setThreadCount(2);
            //get node dispatcher for a context.  nodeset<2 and threadcount>1 returns sequential provider
            final ExecutionContext context = ExecutionContextImpl.builder()
                .frameworkProject(PROJ_NAME)
                .framework(frameworkInstance)
                .user("blah")
                .nodeSelector(nodeSet)
                .threadCount(nodeSet.getThreadCount())
                .keepgoing(nodeSet.isKeepgoing())
                .nodesFile(resourcesfile)
                .nodes(frameworkInstance.filterNodeSet(nodeSet, PROJ_NAME, resourcesfile))
                .build();


            final NodeDispatcher nodeDispatcher = service.getNodeDispatcher(context);
            assertNotNull(nodeDispatcher);
            assertTrue(nodeDispatcher instanceof SequentialNodeDispatcher);
        }
        {
            final NodeSet nodeSet = new NodeSet();
            nodeSet.createInclude().setTags("priority1"); //matches two nodes in external file
            nodeSet.setThreadCount(2);
            //get node dispatcher for a context.  nodeset>1 and threadcount>1 returns parallel provider
            final ExecutionContext context = ExecutionContextImpl.builder()
                .frameworkProject(PROJ_NAME)
                .framework(frameworkInstance)
                .user("blah")
                .nodeSelector(nodeSet)
                .threadCount(nodeSet.getThreadCount())
                .keepgoing(nodeSet.isKeepgoing())
                .nodesFile(extResourcesfile)
                .nodes(frameworkInstance.filterNodeSet(nodeSet, PROJ_NAME, extResourcesfile))
                .build();
            assertEquals(2,context.getNodes().getNodeNames().size());
View Full Code Here

     * Create and return a NodeSet representing the input arguments, may be empty.
     *
     * @return nodeset
     */
    public NodeSet getNodeSet() {
        final NodeSet nodeset = new NodeSet();
        final NodeSet.Include include = nodeset.createInclude(includeMap);
        include.setDominant(!isArgExcludePrecedence());
        final NodeSet.Exclude exclude = nodeset.createExclude(excludeMap);
        exclude.setDominant(isArgExcludePrecedence());
        nodeset.setKeepgoing(isArgKeepgoing());
        nodeset.setThreadCount(getArgThreadCount());

        return nodeset;
    }
View Full Code Here

TOP

Related Classes of com.dtolabs.rundeck.core.utils.NodeSet

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.