Example #1
0
 def test_screen(self):
     try:
         # Launch some screens
         screen_kill('my_1st_screen', fail=False)
         screen_kill('my_2nd_screen', fail=False)
         self.equal(len(screen_launch('my_1st_screen', 'top', fail=False)['stderr']), 0)
         self.equal(len(screen_launch('my_2nd_screen', 'top', fail=False)['stderr']), 0)
         self.equal(len(screen_launch('my_2nd_screen', 'top', fail=False)['stderr']), 0)
         # List the launched screen sessions
         screens = screen_list(name='my_1st_screen')
         self.greater_equal(len(screens), 1)
         self.true(screens[0].endswith('my_1st_screen'))
         screens = screen_list(name='my_2nd_screen')
         self.greater_equal(len(screens), 1)
         self.true(screens[0].endswith('my_2nd_screen'))
     finally:
         # Cleanup
         log = mock.Mock()
         screen_kill(name='my_1st_screen', log=log)
         screen_kill(name='my_2nd_screen', log=log)
         if log.call_args_list:
             validate_list(log.call_args_list, [
                 r"call\(u*'Execute screen -ls my_1st_screen'\)",
                 r"call\(u*'Attempt 1 out of 1: Failed'\)",
                 r"call\(u*'Execute screen -S \d+\.my_1st_screen -X quit'\)",
                 r"call\(u*'Execute screen -ls my_2nd_screen'\)",
                 r"call\(u*'Attempt 1 out of 1: Failed'\)",
                 r"call\(u*'Execute screen -S \d+\.my_2nd_screen -X quit'\)",
                 r"call\(u*'Execute screen -S \d+\.my_2nd_screen -X quit'\)"
             ])
Example #2
0
 def test_screen(self):
     try:
         # Launch some screens
         screen_kill('my_1st_screen', fail=False)
         screen_kill('my_2nd_screen', fail=False)
         self.assertEqual(len(screen_launch('my_1st_screen', 'top', fail=False)['stderr']), 0)
         self.assertEqual(len(screen_launch('my_2nd_screen', 'top', fail=False)['stderr']), 0)
         self.assertEqual(len(screen_launch('my_2nd_screen', 'top', fail=False)['stderr']), 0)
         # List the launched screen sessions
         screens = screen_list(name='my_1st_screen')
         self.assertGreaterEqual(len(screens), 1)
         self.assertTrue(screens[0].endswith('my_1st_screen'))
         screens = screen_list(name='my_2nd_screen')
         self.assertGreaterEqual(len(screens), 1)
         self.assertTrue(screens[0].endswith('my_2nd_screen'))
     finally:
         # Cleanup
         log = Mock()
         screen_kill(name='my_1st_screen', log=log)
         screen_kill(name='my_2nd_screen', log=log)
         if log.call_args_list:
             validate_list(log.call_args_list, [
                 r"call\(u*'Execute screen -ls my_1st_screen'\)",
                 r"call\(u*'Attempt 1 out of 1: Failed'\)",
                 r"call\(u*'Execute screen -S \d+\.my_1st_screen -X quit'\)",
                 r"call\(u*'Execute screen -ls my_2nd_screen'\)",
                 r"call\(u*'Attempt 1 out of 1: Failed'\)",
                 r"call\(u*'Execute screen -S \d+\.my_2nd_screen -X quit'\)",
                 r"call\(u*'Execute screen -S \d+\.my_2nd_screen -X quit'\)"
             ])
def test_screen():
    try:
        # Launch some screens
        subprocess.screen_kill('my_1st_screen', fail=False)
        subprocess.screen_kill('my_2nd_screen', fail=False)
        assert subprocess.screen_launch('my_1st_screen', 'top',
                                        fail=False)['stderr'] == b''
        assert subprocess.screen_launch('my_2nd_screen', 'top',
                                        fail=False)['stderr'] == b''
        assert subprocess.screen_launch('my_2nd_screen', 'top',
                                        fail=False)['stderr'] == b''

        # List the launched screen sessions
        assert subprocess.screen_list(name='my_1st_screen') == [
            regex.Match(r'\d+\.my_1st_screen')
        ]
        assert subprocess.screen_list(name='my_2nd_screen') == [
            regex.Match(r'\d+\.my_2nd_screen'),
            regex.Match(r'\d+\.my_2nd_screen')
        ]
    finally:
        # Cleanup
        log = mock.Mock()
        subprocess.screen_kill(name='my_1st_screen', log=log)
        subprocess.screen_kill(name='my_2nd_screen', log=log)
        if log.call_args_list:
            validate_list(log.call_args_list, [
                r"call\('Execute screen -ls my_1st_screen'\)",
                r"call\('Execute screen -S \d+\.my_1st_screen -X quit'\)",
                r"call\('Execute screen -ls my_2nd_screen'\)",
                r"call\('Execute screen -S \d+\.my_2nd_screen -X quit'\)",
                r"call\('Execute screen -S \d+\.my_2nd_screen -X quit'\)"
            ])
Example #4
0
 def start_paya(self, retry_count=15, retry_delay=1):
     if self.paya_config_string:
         config_list = shlex.split(to_bytes(self.paya_config_string))
         if screen_list(u'paya', log=self.debug) == []:
             screen_launch(u'paya', [u'paya-monitor'] + config_list)
         for start_delay in xrange(retry_count):
             time.sleep(retry_delay)
             if screen_list(u'paya', log=self.debug) != []:
                 start_time = start_delay * retry_delay
                 self.remark(u'{0} successfully started in {1} seconds'.format(u'paya', start_time))
                 return
         raise RuntimeError(u'Monitor damon is not ready')
     else:
         self.remark(u'paya config string is not configured')
Example #5
0
 def test_screen(self):
     try:
         # Launch some screens
         assert_equal(len(screen_launch(u'my_1st_screen', u'top', fail=False)[u'stderr']), 0)
         assert_equal(len(screen_launch(u'my_2nd_screen', u'top', fail=False)[u'stderr']), 0)
         assert_equal(len(screen_launch(u'my_2nd_screen', u'top', fail=False)[u'stderr']), 0)
         # List the launched screen sessions
         screens = screen_list(name=u'my_1st_screen')
         assert(len(screens) >= 1 and screens[0].endswith(u'my_1st_screen'))
         screens = screen_list(name=u'my_2nd_screen')
         assert(len(screens) >= 1 and screens[0].endswith(u'my_2nd_screen'))
     finally:
         # Cleanup
         kill_log = mock_cmd()
         screen_kill(name=u'my_1st_screen', log=kill_log)
         screen_kill(name=u'my_2nd_screen', log=kill_log)
         #raise NotImplementedError(kill_log.call_args_list)
         validate_list(kill_log.call_args_list, [
             r"call\(u*\"Execute \[u*'screen', u*'-ls', u*'my_1st_screen'\]\"\)",
             r"call\(u*\"Execute \[u*'screen', u*'-S', u*'\d+\.my_1st_screen', u*'-X', u*'quit'\]\"\)",
             r"call\(u*\"Execute \[u*'screen', u*'-ls', u*'my_2nd_screen'\]\"\)",
             r"call\(u*\"Execute \[u*'screen', u*'-S', u*'\d+\.my_2nd_screen', u*'-X', u*'quit'\]\"\)",
             r"call\(u*\"Execute \[u*'screen', u*'-S', u*'\d+\.my_2nd_screen', u*'-X', u*'quit'\]\"\)"])