コード例 #1
0
ファイル: ActionTest.py プロジェクト: cea-hpc/milkcheck
 def test_action_with_variables(self):
     """Test variables in action command"""
     cmd = 'echo %([ "%VAR1" != "" ] && echo "-x %VAR1")'
     action = Action('start', command=cmd)
     service = Service('TEST')
     service.add_actions(action)
     service.add_var('VAR1', 'foo')
     service.resolve_all()
     action.run()
     self.assertEqual(action.worker.command, 'echo -x foo')
コード例 #2
0
ファイル: ActionTest.py プロジェクト: fihuer/milkcheck
 def test_action_with_variables(self):
     """Test variables in action command"""
     cmd = 'echo %([ "%VAR1" != "" ] && echo "-x %VAR1")'
     action = Action('start', command=cmd)
     service = Service('TEST')
     service.add_actions(action)
     service.add_var('VAR1', 'foo')
     service.resolve_all()
     action.run()
     self.assertEqual(action.worker.command, 'echo -x foo')
コード例 #3
0
ファイル: ActionTest.py プロジェクト: cea-hpc/milkcheck
    def test_exec_mode(self):
        """Test exec mode"""
        action = Action(name='start', command='echo %%h %%rank',
                        target='%s,localhost' % HOSTNAME)
        action.mode = 'exec'
        svc = Service('test')
        svc.add_action(action)
        svc.resolve_all()
        svc.run('start')

        # Need 2 checks because we do not know which target will be used first
        outputs = [action.worker.node_buffer(HOSTNAME),
                   action.worker.node_buffer('localhost')]
        self.assertTrue(outputs == ["%s 0" % HOSTNAME, "localhost 1"] or
                        outputs == ["%s 1" % HOSTNAME, "localhost 0"])
コード例 #4
0
 def test_resolve_all(self):
     """Test variable resolution in resolve_all()"""
     srv = Service('svc1')
     srv.add_var('label', "I am a service")
     srv.fromdict({
         'desc': "%label",
         'actions': {
             'start': {
                 'cmd': 'service foo %ACTION'
             },
         }
     })
     srv.resolve_all()
     self.assertEqual(srv.desc, "I am a service")
     self.assertEqual(srv._actions['start'].command, "service foo start")
コード例 #5
0
ファイル: ServiceTest.py プロジェクト: cea-hpc/milkcheck
 def test_resolve_all(self):
     """Test variable resolution in resolve_all()"""
     srv = Service('svc1')
     srv.add_var('label', "I am a service")
     srv.fromdict({
                   'desc': "%label",
                   'actions': {
                        'start': {
                            'cmd': 'service foo %ACTION'
                        },
                   }
                 })
     srv.resolve_all()
     self.assertEqual(srv.desc, "I am a service")
     self.assertEqual(srv._actions['start'].command, "service foo start")
コード例 #6
0
ファイル: ActionTest.py プロジェクト: fihuer/milkcheck
    def test_exec_mode(self):
        """Test exec mode"""
        action = Action(name='start',
                        command='echo %%h %%rank',
                        target='%s,localhost' % HOSTNAME)
        action.mode = 'exec'
        svc = Service('test')
        svc.add_action(action)
        svc.resolve_all()
        svc.run('start')

        # Need 2 checks because we do not know which target will be used first
        outputs = [
            action.worker.node_buffer(HOSTNAME).decode(),
            action.worker.node_buffer('localhost').decode()
        ]
        self.assertTrue(outputs == ["%s 0" % HOSTNAME, "localhost 1"]
                        or outputs == ["%s 1" % HOSTNAME, "localhost 0"])