Пример #1
0
    def setUp(self):
        '''
        Set up the graph of services within the service manager

        Graph
                                _ start
                   -- service1 /
                 -'             _ start
                  '-- service2 /
        '''

        CLICommon.setUp(self)

        # Service
        service1 = Service('service1')
        service1.desc = 'I am the service 1'
        service2 = Service('service2')
        service2.desc = 'I am the service 2'
        # Actions
        action = Action('start', command='/bin/true')
        action.inherits_from(service1)
        service1.add_action(action)

        service2.add_dep(target=service1)

        action = Action('start', command='/bin/true')
        action.inherits_from(service2)
        service2.add_action(action)

        # Register services within the manager
        self.manager.register_services(service1, service2)
Пример #2
0
    def setUp(self):
        '''
        Set up the graph of services within the service manager

        Graph
                              _ start
           group --> service /
                             `- stop
        '''
        CLICommon.setUp(self)

        # ServiceGroup
        group = ServiceGroup('ServiceGroup')
        # Service
        self.service = service = Service('service')
        service.desc = 'I am the service'
        # Actions
        start_action = Action('start', command='/bin/true')
        stop_action = Action('stop', command='/bin/false')
        self.timeout_action = Action('timeout', command='sleep 1', timeout=0.1)
        start_action.inherits_from(service)
        stop_action.inherits_from(service)
        service.add_action(start_action)
        service.add_action(stop_action)
        service.add_action(self.timeout_action)

        # Build graph
        group.add_inter_dep(target=service)

        # Register services within the manager
        self.manager.register_services(group, service)
Пример #3
0
    def test_command_output_warning(self):
        '''Test command line output with warning'''
        svc_warn = Service('service_failled')
        svc_warn.desc = 'I am the failled service'
        svc_ok = Service('service_ok')
        svc_ok.desc = 'I am the ok service'
        # Actions
        action = Action('warning', command='/bin/false')
        action.inherits_from(svc_warn)
        svc_warn.add_action(action)
        action = Action('warning', command='/bin/true')
        action.inherits_from(svc_ok)
        svc_ok.add_action(action)

        # Register services within the manager
        svc_ok.add_dep(target=svc_warn, sgth=REQUIRE_WEAK)
        self.manager.add_service(svc_warn)
        self.manager.add_service(svc_ok)

        self._output_check(['service_ok', 'warning'], RC_OK,
"""warning service_failled ran in 0.00 s
 > localhost exited with 1
service_failled - I am the failled service                        [  ERROR  ]
service_ok - I am the ok service                                  [    OK   ]
""")
Пример #4
0
    def test_desc(self):
        """Test action inherits 'desc'"""
        # No service description, no action description
        action1 = Action('status', command='/bin/true')
        service = Service('TEST')
        service.add_actions(action1)
        self.assertEqual(action1.desc, None)

        # Service description, actions inherits the description
        action2 = Action('status', command='/bin/true')
        service2 = Service('TEST2')
        service2.desc = "Service TEST"
        service2.add_actions(action2)
        action2.inherits_from(service2)
        self.assertEqual(action2.desc, "Service TEST")
Пример #5
0
    def test_command_output_interactive_delayed(self):
        '''Test command line output in interactive mode with delayed actions'''
        action = Action('start', command='/bin/sleep 0.1', delay=0.3)
        srv = Service('service')
        srv.desc = 'I am the service'
        action.inherits_from(srv)
        srv.add_action(action)
        self.manager.register_services(srv)
        self._output_check(['service', 'start'], RC_OK,
'''
Actions in progress
 > service.start (delayed for 0.3s) on localhost

service - I am the service                                        [    OK   ]
''')
Пример #6
0
    def test_desc(self):
        """Test action inherits 'desc'"""
        # No service description, no action description
        action1 = Action('status', command='/bin/true')
        service = Service('TEST')
        service.add_actions(action1)
        self.assertEqual(action1.desc, None)

        # Service description, actions inherits the description
        action2 = Action('status', command='/bin/true')
        service2 = Service('TEST2')
        service2.desc = "Service TEST"
        service2.add_actions(action2)
        action2.inherits_from(service2)
        self.assertEqual(action2.desc, "Service TEST")
Пример #7
0
    def test_run_skipped_with_error_deps(self):
        """Test run with ERROR dependencies for a SKIPPED service"""

        # Distant service with empty target: should be skipped
        svc = Service('test_service', target="tempnode[1-2]")
        action = Action('start', command='/bin/true')
        action.inherits_from(svc)
        svc.add_action(action)
        svc.update_target("tempnode[1-2]", 'DIF')

        # A simple dep
        dep = Service('DEP_A')
        dep.add_action(Action('start', command='/bin/false'))

        svc.add_dep(dep)
        svc.run('start')

        self.assertEqual(svc.eval_deps_status(), DEP_ERROR)
        self.assertEqual(dep.status, ERROR)
        self.assertEqual(svc.status, SKIPPED)
Пример #8
0
    def test_run_skipped_with_error_deps(self):
        """Test run with ERROR dependencies for a SKIPPED service"""

        # Distant service with empty target: should be skipped
        svc = Service('test_service', target="tempnode[1-2]")
        action = Action('start', command='/bin/true')
        action.inherits_from(svc)
        svc.add_action(action)
        svc.update_target("tempnode[1-2]", 'DIF')

        # A simple dep
        dep = Service('DEP_A')
        dep.add_action(Action('start', command='/bin/false'))

        svc.add_dep(dep)
        svc.run('start')

        self.assertEqual(svc.eval_deps_status(), DEP_ERROR)
        self.assertEqual(dep.status, ERROR)
        self.assertEqual(svc.status, SKIPPED)
Пример #9
0
    def setUp(self):
        '''
        Set up the graph of services within the service manager

        Graph
                                _ start
                   -- service1 /
                 -'             _ start
                  '-- service2 /
        '''

        self.backup_terminal = MilkCheck.UI.Cli.Terminal
        self.backup_interactivethr = MilkCheck.UI.Cli.InteractiveThread
        self.backup_confirm_actions = \
            ConfigParser.DEFAULT_FIELDS['confirm_actions']['value']
        MilkCheck.UI.Cli.Terminal = MockInterTerminal
        MilkCheck.UI.Cli.InteractiveThread = MockInteractiveThread
        MockInterTerminal.called = False
        CLICommon.setUp(self)

        # Service
        service1 = Service('service1')
        service1.desc = 'I am the service 1'
        self.service1 = service1
        service2 = Service('service2')
        service2.desc = 'I am the service 2'
        self.service2 = service2
        # Actions
        action = Action('start', command='/bin/sleep 0.1')
        action.inherits_from(service1)
        service1.add_action(action)

        service2.add_dep(target=service1)

        action = Action('start', command='/bin/sleep 0.8')
        action.inherits_from(service2)
        service2.add_action(action)

        # Register services within the manager
        self.manager.add_service(service1)
        self.manager.add_service(service2)
Пример #10
0
    def fromdict(self, svcdict):
        """Populate service attributes from dict."""
        BaseEntity.fromdict(self, svcdict)

        if 'actions' in svcdict:
            dependencies = {}
            for names, props in svcdict['actions'].items():
                for name in NodeSet(names):
                    action = Action(name)
                    self.add_action(action)
                    action.fromdict(props)

                    dependencies[name] = props.get('check', [])

            for action in self._actions.values():
                for dep in dependencies[action.name]:
                    action.add_dep(self._actions[dep])

        # Inherits properies between service and actions
        for action in self.iter_actions():
            action.inherits_from(self)
Пример #11
0
    def fromdict(self, svcdict):
        """Populate service attributes from dict."""
        BaseEntity.fromdict(self, svcdict)

        if "actions" in svcdict:
            dependencies = {}
            actions = {}
            for names, props in svcdict["actions"].items():
                for name in NodeSet(names):
                    action = Action(name)
                    action.fromdict(props)

                    actions[name] = action
                    dependencies[name] = props.get("check", [])

            for action in actions.values():
                for dep in dependencies[action.name]:
                    action.add_dep(actions[dep])
                self.add_action(action)

        # Inherits properies between service and actions
        for action in self.iter_actions():
            action.inherits_from(self)
Пример #12
0
    def setUp(self):
        '''
        Set up the graph of services within the service manager

        Graph
                                _ start
                   -- service1 /
                 -'             _ start
                  '-- service2 /
        '''

        self.backup_terminal = MilkCheck.UI.Cli.Terminal
        self.backup_interactivethr = MilkCheck.UI.Cli.InteractiveThread
        MilkCheck.UI.Cli.Terminal = MockInterTerminal
        MilkCheck.UI.Cli.InteractiveThread = MockInteractiveThread
        MockInterTerminal.called = False
        CLICommon.setUp(self)

        # Service
        service1 = Service('service1')
        service1.desc = 'I am the service 1'
        service2 = Service('service2')
        service2.desc = 'I am the service 2'
        # Actions
        action = Action('start', command='/bin/sleep 0.1')
        action.inherits_from(service1)
        service1.add_action(action)

        service2.add_dep(target=service1)

        action = Action('start', command='/bin/sleep 0.8')
        action.inherits_from(service2)
        service2.add_action(action)

        # Register services within the manager
        self.manager.register_services(service1, service2)
Пример #13
0
    def test_command_output_warning(self):
        '''Test command line output with warning'''
        svc_warn = Service('service_failled')
        svc_warn.desc = 'I am the failled service'
        svc_ok = Service('service_ok')
        svc_ok.desc = 'I am the ok service'
        # Actions
        action = Action('warning', command='/bin/false')
        action.inherits_from(svc_warn)
        svc_warn.add_action(action)
        action = Action('warning', command='/bin/true')
        action.inherits_from(svc_ok)
        svc_ok.add_action(action)

        # Register services within the manager
        svc_ok.add_dep(target=svc_warn, sgth=REQUIRE_WEAK)
        self.manager.register_services(svc_warn, svc_ok)

        self._output_check(['service_ok', 'warning'], RC_OK,
"""warning service_failled ran in 0.00 s
 > localhost exited with 1
service_failled - I am the failled service                        [  ERROR  ]
service_ok - I am the ok service                                  [    OK   ]
""")
Пример #14
0
    def test_command_output_dist_report_full_error_and_ok(self):
        """
        Test command line output with full report, FAILED actions and OK
        actions on distant nodes.
        """
        # Service
        svc = Service('service_ok')
        svc.desc = 'I am the ok service'
        svc2 = Service('service_fail')
        svc2.desc = 'I am the fail service'
        svc.add_dep(svc2, sgth=REQUIRE_WEAK)
        # Actions
        false_action = Action('stop', command='/bin/false', target=NodeSet(HOSTNAME))
        false_action.inherits_from(svc)
        svc.add_action(false_action)

        true_action = Action('stop', command='/bin/true', target=NodeSet(HOSTNAME))
        true_action.inherits_from(svc2)
        svc2.add_action(true_action)

        # Register services within the manager
        self.manager.add_service(svc)
        self.manager.add_service(svc2)

        # FIXME: must return RC_OK
        self._output_check(['service_fail', 'stop', '--report=full'], RC_OK,
"""stop service_ok ran in 0.00 s
 > HOSTNAME exited with 1
service_ok - I am the ok service                                  [  ERROR  ]
service_fail - I am the fail service                              [    OK   ]

 SUMMARY - 2 actions (1 failed)
 + service_ok.stop - I am the ok service
    Target: HOSTNAME
    Command: /bin/false
""")
Пример #15
0
class CommandLineOutputTests(CLICommon):
    '''Tests cases of the command line output'''

    def setUp(self):
        '''
        Set up the graph of services within the service manager

        Graph
                              _ start
           group --> service /
                             `- stop
        '''
        CLICommon.setUp(self)

        # ServiceGroup
        group = ServiceGroup('ServiceGroup')
        # Service
        self.service = service = Service('service')
        service.desc = 'I am the service'
        # Actions
        self.start_action = Action('start', command='/bin/true')
        self.stop_action = Action('stop', command='/bin/false')
        self.timeout_action = Action('timeout', command='sleep 1', timeout=0.1)
        self.start_action.inherits_from(service)
        self.stop_action.inherits_from(service)
        service.add_action(self.start_action)
        service.add_action(self.stop_action)
        service.add_action(self.timeout_action)

        # Build graph
        group.add_inter_dep(target=service)

        # Register services within the manager
        self.manager.add_service(group)

    def test_command_output_help(self):
        '''Test command line help output'''
        self._output_check([], RC_OK,
"""Usage: nosetests [options] [SERVICE...] ACTION

Options:
  --version             show program's version number and exit
  -h, --help            show this help message and exit
  -v, --verbose         Increase or decrease verbosity
  -d, --debug           Set debug mode and maximum verbosity
  -g, --graph           Output dependencies graph
  -s, --summary         --summary is an alias for --report=default
  -r REPORT, --report=REPORT
                        Display a report of executed actions
  -c CONFIG_DIR, --config-dir=CONFIG_DIR
                        Change configuration files directory
  -q, --quiet           Enable quiet mode
  -y, --assumeyes       Answer yes to any requested confirmation

  Engine parameters:
    Those options allow you to configure the behaviour of the engine

    -n ONLY_NODES, --only-nodes=ONLY_NODES
                        Use only the specified nodes
    -x EXCLUDED_NODES, --exclude-nodes=EXCLUDED_NODES
                        Exclude the cluster's nodes specified
    -X EXCLUDED_SVC, --exclude-service=EXCLUDED_SVC
                        Skip the specified services
    --dry-run           Only simulate command execution
    -D DEFINES, --define=DEFINES, --var=DEFINES
                        Define custom variables
    --nodeps            Do not run dependencies
    -t TAGS, --tags=TAGS
                        Run services matching these tags
""")

    def test_command_output_checkconfig(self):
        '''Test command line output checking config'''
        self._output_check(['-c', '../conf/samples'], RC_OK,
"""No actions specified, checking configuration...
../conf/samples seems good                     
""" )

    def test_command_line_variables(self):
        '''Test automatic variables from command line.'''
        self._output_check(['ServiceGroup', 'start', '-n', 'fo1', '-x', 'fo2'],
                           RC_OK,
"""ServiceGroup.service - I am the service                           [    OK   ]
ServiceGroup                                                      [    OK   ]
""", "[service]\r")
        self.assertEqual(self.manager.variables['SELECTED_NODES'], 'fo1')
        self.assertEqual(self.manager.variables['EXCLUDED_NODES'], 'fo2')

    def test_command_line_default_variables(self):
        '''Test default values of automatic variables from command line.'''
        self._output_check(['ServiceGroup', 'start'], RC_OK,
"""ServiceGroup.service - I am the service                           [    OK   ]
ServiceGroup                                                      [    OK   ]
""", "[service]\r")
        self.assertEqual(self.manager.variables['SELECTED_NODES'], '')
        self.assertEqual(self.manager.variables['EXCLUDED_NODES'], '')

    def test_command_output_ok(self):
        '''Test command line output with all actions OK'''
        self._output_check(['ServiceGroup', 'start'], RC_OK,
"""ServiceGroup.service - I am the service                           [    OK   ]
ServiceGroup                                                      [    OK   ]
""")

    def test_command_output_ok_verbose2(self):
        '''Test command line output with local action OK in verbose x2'''
        self._output_check(['ServiceGroup', 'start', '-vv'], RC_OK,
"""start ServiceGroup.service on localhost
 > /bin/true
start ServiceGroup.service ran in 0.00 s
 > localhost exited with 0
ServiceGroup.service - I am the service                           [    OK   ]
ServiceGroup                                                      [    OK   ]
""")

    def test_command_output_summary_ok(self):
        '''Test command line output with summary and all actions OK'''
        self._output_check(['ServiceGroup', 'start', '-s'], RC_OK,
"""ServiceGroup.service - I am the service                           [    OK   ]
ServiceGroup                                                      [    OK   ]

 SUMMARY - 1 action (0 failed)
""")

    def test_command_output_full_report_ok(self):
        """Test command line output with full report and all actions OK"""
        self._output_check(['ServiceGroup', 'start', '--report=full'], RC_OK,
"""ServiceGroup.service - I am the service                           [    OK   ]
ServiceGroup                                                      [    OK   ]

 SUMMARY - 1 action (0 failed)
""")

    def test_command_output_error(self):
        '''Test command line output with all actions FAILED'''
        self._output_check(['ServiceGroup', 'stop'], RC_ERROR,
"""stop ServiceGroup.service ran in 0.00 s
 > localhost exited with 1
ServiceGroup.service - I am the service                           [  ERROR  ]
ServiceGroup                                                      [DEP_ERROR]
""")

    def test_command_output_summary_error(self):
        '''Test command line output with summary and all actions FAILED'''
        self._output_check(['ServiceGroup', 'stop', '-s'], RC_ERROR,
"""stop ServiceGroup.service ran in 0.00 s
 > localhost exited with 1
ServiceGroup.service - I am the service                           [  ERROR  ]
ServiceGroup                                                      [DEP_ERROR]

 SUMMARY - 1 action (1 failed)
 + ServiceGroup.service.stop - I am the service
""")

    def test_command_output_dist_summary_error(self):
        """
        Test command line output with summary and all actions FAILED
        on distant nodes.
        """
        self.stop_action._target_backup = "localhost,%s" % HOSTNAME
        nodestring = re.sub(HOSTNAME, 'HOSTNAME', "%s" %
                            NodeSet(self.stop_action._target_backup))
        self._output_check(['ServiceGroup', 'stop', '-s'], RC_ERROR,
"""stop ServiceGroup.service ran in 0.00 s
 > %s exited with 1
ServiceGroup.service - I am the service                           [  ERROR  ]
ServiceGroup                                                      [DEP_ERROR]

 SUMMARY - 1 action (1 failed)
 + ServiceGroup.service.stop - I am the service
""" % nodestring)

    def test_command_output_dist_report_full_error(self):
        """
        Test command line output with full report and all actions FAILED
        on distant nodes.
        """
        self.stop_action._target_backup = "localhost,%s" % HOSTNAME
        nodestring = re.sub(HOSTNAME, 'HOSTNAME', "%s" %
                            NodeSet(self.stop_action._target_backup))
        self._output_check(['ServiceGroup', 'stop', '--report=full'], RC_ERROR,
"""stop ServiceGroup.service ran in 0.00 s
 > %s exited with 1
ServiceGroup.service - I am the service                           [  ERROR  ]
ServiceGroup                                                      [DEP_ERROR]

 SUMMARY - 1 action (1 failed)
 + ServiceGroup.service.stop - I am the service
    Target: %s
    Command: /bin/false
""" % (nodestring, nodestring))

    def test_command_output_dist_report_full_ok(self):
        """
        Test command line output with full report and all actions OK
        on distant nodes.
        """
        self.start_action._target_backup = "localhost,%s" % HOSTNAME
        nodestring = re.sub(HOSTNAME, 'HOSTNAME', "%s" %
                            NodeSet(self.start_action._target_backup))
        self._output_check(['ServiceGroup', 'start', '--report=full'], RC_OK,
"""ServiceGroup.service - I am the service                           [    OK   ]
ServiceGroup                                                      [    OK   ]

 SUMMARY - 1 action (0 failed)
 + Success on all services
    %s
""" % nodestring)

    def test_command_output_dist_report_full_error_and_ok(self):
        """
        Test command line output with full report, FAILED actions and OK
        actions on distant nodes.
        """
        # Service
        svc = Service('service_ok')
        svc.desc = 'I am the ok service'
        svc2 = Service('service_fail')
        svc2.desc = 'I am the fail service'
        svc.add_dep(svc2, sgth=REQUIRE_WEAK)
        # Actions
        false_action = Action('stop', command='/bin/false', target=NodeSet(HOSTNAME))
        false_action.inherits_from(svc)
        svc.add_action(false_action)

        true_action = Action('stop', command='/bin/true', target=NodeSet(HOSTNAME))
        true_action.inherits_from(svc2)
        svc2.add_action(true_action)

        # Register services within the manager
        self.manager.add_service(svc)
        self.manager.add_service(svc2)

        # FIXME: must return RC_OK
        self._output_check(['service_fail', 'stop', '--report=full'], RC_OK,
"""stop service_ok ran in 0.00 s
 > HOSTNAME exited with 1
service_ok - I am the ok service                                  [  ERROR  ]
service_fail - I am the fail service                              [    OK   ]

 SUMMARY - 2 actions (1 failed)
 + service_ok.stop - I am the ok service
    Target: HOSTNAME
    Command: /bin/false
""")

    def test_command_output_timeout(self):
        '''Test command line output with local timeout'''
        self._output_check(['ServiceGroup', 'timeout'], RC_ERROR,
"""timeout ServiceGroup.service ran in 0.00 s
 > localhost has timeout
ServiceGroup.service - I am the service                           [ TIMEOUT ]
ServiceGroup                                                      [DEP_ERROR]
""")

    def test_command_output_dist_timeout(self):
        '''Test command line output with distant timeout'''
        self.timeout_action._target_backup = HOSTNAME
        self._output_check(['ServiceGroup', 'timeout'], RC_ERROR,
"""timeout ServiceGroup.service ran in 0.00 s
 > HOSTNAME has timeout
ServiceGroup.service - I am the service                           [ TIMEOUT ]
ServiceGroup                                                      [DEP_ERROR]
""")

    def test_command_output_multiple_dist_timeout(self):
        '''Test command line output with timeout and multiple distant nodes'''
        self.timeout_action._target_backup = "localhost,%s" % HOSTNAME
        nodestring = re.sub(HOSTNAME, 'HOSTNAME', "%s" %
                            NodeSet(self.timeout_action._target_backup))
        self._output_check(['ServiceGroup', 'timeout'], RC_ERROR,
"""timeout ServiceGroup.service ran in 0.00 s
 > %s has timeout
ServiceGroup.service - I am the service                           [ TIMEOUT ]
ServiceGroup                                                      [DEP_ERROR]
""" % nodestring)

    def test_command_output_summary_multiple_dist_timeout(self):
        """
        Test command line output with timeout, multiple distant nodes
        and summary
        """
        self.timeout_action._target_backup = "localhost,%s" % HOSTNAME
        nodestring = re.sub(HOSTNAME, 'HOSTNAME', "%s" %
                            NodeSet(self.timeout_action._target_backup))
        self._output_check(['ServiceGroup', 'timeout', '-s'], RC_ERROR,
"""timeout ServiceGroup.service ran in 0.00 s
 > %s has timeout
ServiceGroup.service - I am the service                           [ TIMEOUT ]
ServiceGroup                                                      [DEP_ERROR]

 SUMMARY - 1 action (1 failed)
 + ServiceGroup.service.timeout
""" % nodestring)

    def test_command_output_summary_multiple_dist_timeout_full_report(self):
        """
        Test command line output with timeout, multiple distant nodes
        and summary with full report.
        """
        self.timeout_action._target_backup = "localhost,%s" % HOSTNAME
        nodestring = re.sub(HOSTNAME, 'HOSTNAME', "%s" %
                            NodeSet(self.timeout_action._target_backup))
        self._output_check(['ServiceGroup', 'timeout', '--report=full'],
                           RC_ERROR,
"""timeout ServiceGroup.service ran in 0.00 s
 > %s has timeout
ServiceGroup.service - I am the service                           [ TIMEOUT ]
ServiceGroup                                                      [DEP_ERROR]

 SUMMARY - 1 action (1 failed)
 + ServiceGroup.service.timeout
    Target: %s
    Command: sleep 1
""" % (nodestring, nodestring))

    def test_command_output_warning(self):
        '''Test command line output with warning'''
        svc_warn = Service('service_failled')
        svc_warn.desc = 'I am the failled service'
        svc_ok = Service('service_ok')
        svc_ok.desc = 'I am the ok service'
        # Actions
        action = Action('warning', command='/bin/false')
        action.inherits_from(svc_warn)
        svc_warn.add_action(action)
        action = Action('warning', command='/bin/true')
        action.inherits_from(svc_ok)
        svc_ok.add_action(action)

        # Register services within the manager
        svc_ok.add_dep(target=svc_warn, sgth=REQUIRE_WEAK)
        self.manager.add_service(svc_warn)
        self.manager.add_service(svc_ok)

        self._output_check(['service_ok', 'warning'], RC_OK,
"""warning service_failled ran in 0.00 s
 > localhost exited with 1
service_failled - I am the failled service                        [  ERROR  ]
service_ok - I am the ok service                                  [    OK   ]
""")

    def test_command_output_error_quiet(self):
        '''Test command line output with all actions FAILED in quiet mode'''
        self._output_check(['ServiceGroup', 'stop', '-q'], RC_ERROR,
"""ServiceGroup.service - I am the service                           [  ERROR  ]
ServiceGroup                                                      [DEP_ERROR]
""")
    def test_command_output_ok_quiet(self):
        '''Test command line output with all actions OK in quiet mode'''
        self._output_check(['ServiceGroup', 'start', '-q'], RC_OK,
"""ServiceGroup.service - I am the service                           [    OK   ]
ServiceGroup                                                      [    OK   ]
""")

    def test_command_output_warning_status(self):
        '''Test command line output with one action WARNING'''
        svc = Service('warn')
        act = Action('go', command='/bin/false')
        act.errors = 1
        svc.add_action(act)
        self.manager.add_service(svc)
        self._output_check(['warn', 'go', '-q'], RC_WARNING,
"""warn                                                              [ WARNING ]
""")
    def test_custom_defines(self):
        '''Test command line output custom variables'''
        svc = Service('one')
        svc.add_action(Action('go', command='/bin/echo %foo'))
        self.manager.add_service(svc)
        self._output_check(['one', 'go', '-v', '--define=foo=bar'], RC_OK,
"""go one on localhost
 > /bin/echo bar
one                                                               [    OK   ]
""")