예제 #1
0
파일: ProxyTest.py 프로젝트: thiell/shine
    def test_start_ok(self):
        """send a start and done message"""
        msgs = []
        msgs.append(
            shine_msg_pack(evtype='comp', info=self.info, status='start'))
        self.tgt.state = MOUNTED
        msgs.append(
            shine_msg_pack(evtype='comp', info=self.info, status='done'))

        self.act.fakecmd = 'echo "%s"' % '\n'.join(msgs)
        self.act.launch()
        self.fs._run_actions()
        self.fs._check_errors([MOUNTED], self.fs.components)

        self.assertEqual(len(self.fs.proxy_errors), 0)
        self.assertEqual(self.tgt.state, MOUNTED)
        self.assertEqual(self.act.status(), ACT_OK)
예제 #2
0
    def test_start_ok(self):
        """send a start and done message"""
        msgs = []
        msgs.append(shine_msg_pack(evtype='comp', info=self.info,
                                   status='start'))
        self.tgt.state = MOUNTED
        msgs.append(shine_msg_pack(evtype='comp', info=self.info,
                                   status='done'))

        self.act.fakecmd = 'echo "%s"' % '\n'.join(msgs)
        self.act.launch()
        self.fs._run_actions()
        self.fs._check_errors([MOUNTED], self.fs.components)

        self.assertEqual(len(self.fs.proxy_errors), 0)
        self.assertEqual(self.tgt.state, MOUNTED)
        self.assertEqual(self.act.status(), ACT_OK)
예제 #3
0
    def test_compat_compname(self):
        """message with compname value is backward compatible"""
        msgs = []
        msgs.append(shine_msg_pack(compname=self.tgt.TYPE, action='start',
                                   status='start', comp=self.tgt))
        self.tgt.state = MOUNTED
        msgs.append(shine_msg_pack(compname=self.tgt.TYPE, action='start',
                                   status='done', comp=self.tgt))

        self.act.fakecmd = 'echo "%s"' % '\n'.join(msgs)
        self.act.launch()
        self.fs._run_actions()
        self.fs._check_errors([MOUNTED], self.fs.components)

        self.assertEqual(len(self.fs.proxy_errors), 0)
        self.assertEqual(self.tgt.state, MOUNTED)
        self.assertEqual(self.act.status(), ACT_OK)
 def event_callback(self, evtype, **kwargs):
     """Convert each event it receives into an encoded line on stdout."""
     # For distant message, we do not need to send the node. It will
     # be extract from the incoming server name.
     if 'node' in kwargs:
         del kwargs['node']
     msg = shine_msg_pack(evtype=evtype, **kwargs)
     sys.stdout.write(msg)
     sys.stdout.flush()
 def event_callback(self, evtype, **kwargs):
     """Convert each event it receives into an encoded line on stdout."""
     # For distant message, we do not need to send the node. It will
     # be extract from the incoming server name.
     if 'node' in kwargs:
         del kwargs['node']
     msg = shine_msg_pack(evtype=evtype, **kwargs)
     sys.stdout.write(msg)
     sys.stdout.flush()
예제 #6
0
    def test_crash_after_start_ok(self):
        """send a start and done message and then crashes"""
        msgs = []
        msgs.append(shine_msg_pack(evtype='comp', info=self.info,
                                   status='start'))
        self.tgt.state = MOUNTED
        msgs.append(shine_msg_pack(evtype='comp', info=self.info,
                                   status='done'))

        self.act.fakecmd = 'echo "%s"; echo Oops; exit 1' % '\n'.join(msgs)
        self.act.launch()
        self.fs._run_actions()
        self.fs._check_errors([MOUNTED], self.fs.components)

        self.assertEqual(len(self.fs.proxy_errors), 1)
        self.assertEqual(list(self.fs.proxy_errors.messages())[0],
                         "Remote action start failed: \n\nOops\n")
        self.assertEqual(self.tgt.state, MOUNTED)
        self.assertEqual(self.act.status(), ACT_ERROR)
예제 #7
0
파일: ProxyTest.py 프로젝트: thiell/shine
    def test_crash_after_start_ok(self):
        """send a start and done message and then crashes"""
        msgs = []
        msgs.append(
            shine_msg_pack(evtype='comp', info=self.info, status='start'))
        self.tgt.state = MOUNTED
        msgs.append(
            shine_msg_pack(evtype='comp', info=self.info, status='done'))

        self.act.fakecmd = 'echo "%s"; echo Oops; exit 1' % '\n'.join(msgs)
        self.act.launch()
        self.fs._run_actions()
        self.fs._check_errors([MOUNTED], self.fs.components)

        self.assertEqual(len(self.fs.proxy_errors), 1)
        self.assertEqual(
            list(self.fs.proxy_errors.messages())[0],
            "Remote action start failed: \n\nOops\n")
        self.assertEqual(self.tgt.state, MOUNTED)
        self.assertEqual(self.act.status(), ACT_ERROR)
예제 #8
0
파일: ProxyTest.py 프로젝트: thiell/shine
    def test_compat_compname(self):
        """message with compname value is backward compatible"""
        msgs = []
        msgs.append(
            shine_msg_pack(compname=self.tgt.TYPE,
                           action='start',
                           status='start',
                           comp=self.tgt))
        self.tgt.state = MOUNTED
        msgs.append(
            shine_msg_pack(compname=self.tgt.TYPE,
                           action='start',
                           status='done',
                           comp=self.tgt))

        self.act.fakecmd = 'echo "%s"' % '\n'.join(msgs)
        self.act.launch()
        self.fs._run_actions()
        self.fs._check_errors([MOUNTED], self.fs.components)

        self.assertEqual(len(self.fs.proxy_errors), 0)
        self.assertEqual(self.tgt.state, MOUNTED)
        self.assertEqual(self.act.status(), ACT_OK)
예제 #9
0
    def test_start_crash(self):
        """send a start message then crashes"""
        msg = shine_msg_pack(evtype='comp', info=self.info, status='start')

        self.act.fakecmd = 'echo "%s"; echo BAD; exit 1' % msg
        self.act.launch()
        self.fs._run_actions()
        self.fs._check_errors([MOUNTED], self.fs.components)

        self.assertEqual(len(self.fs.proxy_errors), 1)
        self.assertEqual(list(self.fs.proxy_errors.messages())[0],
                         "Remote action start failed: \nBAD\n")
        self.assertEqual(self.tgt.state, RUNTIME_ERROR)
        self.assertEqual(self.act.status(), ACT_ERROR)
예제 #10
0
파일: ProxyTest.py 프로젝트: thiell/shine
    def test_start_crash(self):
        """send a start message then crashes"""
        msg = shine_msg_pack(evtype='comp', info=self.info, status='start')

        self.act.fakecmd = 'echo "%s"; echo BAD; exit 1' % msg
        self.act.launch()
        self.fs._run_actions()
        self.fs._check_errors([MOUNTED], self.fs.components)

        self.assertEqual(len(self.fs.proxy_errors), 1)
        self.assertEqual(
            list(self.fs.proxy_errors.messages())[0],
            "Remote action start failed: \nBAD\n")
        self.assertEqual(self.tgt.state, RUNTIME_ERROR)
        self.assertEqual(self.act.status(), ACT_ERROR)
예제 #11
0
    def test_bad_object(self):
        """send a done message which fails update due to bad property"""
        msg = shine_msg_pack(evtype='comp', info=self.info, status='done')
        def buggy_update(self, other):
            self.wrong_property = other.wrong_property
        self.tgt.update = types.MethodType(buggy_update, self.tgt)

        self.act.fakecmd = 'echo "%s"' % msg
        self.act.launch()
        self.fs._run_actions()
        self.fs._check_errors([OFFLINE], self.fs.components)

        self.assertEqual(len(self.fs.proxy_errors), 1)
        self.assertEqual(str(list(self.fs.proxy_errors.messages())[0]),
                         "Cannot read message (check Shine and ClusterShell "
                         "version): 'MGT' object has no attribute "
                         "'wrong_property'")
        self.assertEqual(self.tgt.state, RUNTIME_ERROR)
        self.assertEqual(self.act.status(), ACT_OK)
예제 #12
0
파일: ProxyTest.py 프로젝트: thiell/shine
    def test_bad_object(self):
        """send a done message which fails update due to bad property"""
        msg = shine_msg_pack(evtype='comp', info=self.info, status='done')

        def buggy_update(self, other):
            self.wrong_property = other.wrong_property

        self.tgt.update = types.MethodType(buggy_update, self.tgt)

        self.act.fakecmd = 'echo "%s"' % msg
        self.act.launch()
        self.fs._run_actions()
        self.fs._check_errors([OFFLINE], self.fs.components)

        self.assertEqual(len(self.fs.proxy_errors), 1)
        self.assertEqual(
            str(list(self.fs.proxy_errors.messages())[0]),
            "Cannot read message (check Shine and ClusterShell "
            "version): 'MGT' object has no attribute "
            "'wrong_property'")
        self.assertEqual(self.tgt.state, RUNTIME_ERROR)
        self.assertEqual(self.act.status(), ACT_OK)