def testSuccessCallback(self):
        self.callback_called = 0

        def callback(start_time, eapsed, proc):
            self.callback_called += 1

        run_cmd_periodic_poll(['bash', '-c', 'sleep 5 && true'],
                              warning_interval=2, warning_callback=callback),
        self.assertEqual(self.callback_called, 2)
    def testSuccessCallback(self):
        self.callback_called = 0

        def callback(start_time, eapsed, proc):
            self.callback_called += 1

        run_cmd_periodic_poll(['bash', '-c', 'sleep 5 && true'],
                              warning_interval=2,
                              warning_callback=callback),
        self.assertEqual(self.callback_called, 2)
Beispiel #3
0
 def fabric_cmd(self, actions, **cmdKwargs):
     cmd = ['python', FABRIC_SCRIPT, '-f', self.masters_json_file,
            '-j', str(self.concurrency)]
     for role in self.roles:
         cmd += ['-R', role]
     if self.username:
         cmd += ['--username', self.username]
     if self.ssh_key:
         cmd += ['--ssh-key', self.ssh_key]
     cmd += actions
     # don't buffer output
     env = {'PYTHONUNBUFFERED': '1'}
     if self.subprocess:
         run_cmd_periodic_poll(cmd, warning_interval=self.warning_interval,
                               warning_callback=self.callback, env=env,
                               **cmdKwargs)
     else:
         run_cmd(cmd, env=env)
 def testSuccess3secsWith2secsPoll(self):
     self.assertEquals(
         run_cmd_periodic_poll(['bash', '-c', 'sleep 3 && true'],
                               warning_interval=2), 0)
 def testSuccess2secs(self):
     self.assertEquals(
         run_cmd_periodic_poll(['bash', '-c', 'sleep 2 && true']), 0)
 def testSimple(self):
     self.assertEquals(run_cmd_periodic_poll(['true']), 0)
 def testSuccess3secsWith2secsPoll(self):
     self.assertEquals(
         run_cmd_periodic_poll(['bash', '-c', 'sleep 3 && true'],
                               warning_interval=2),
         0)
 def testSuccess2secs(self):
     self.assertEquals(
         run_cmd_periodic_poll(['bash', '-c', 'sleep 2 && true']),
         0)
 def testSimple(self):
     self.assertEquals(run_cmd_periodic_poll(['true']), 0)