示例#1
0
 def test_file_stream(self):
     yield self._start_arbiter()
     stream = FileStream(self.stdout, max_bytes='12', backup_count='3')
     self.assertTrue(isinstance(stream._max_bytes, int))
     self.assertTrue(isinstance(stream._backup_count, int))
     yield self.stop_arbiter()
     stream.close()
示例#2
0
 def test_file_stream(self):
     yield self._start_arbiter()
     stream = FileStream(self.stdout, max_bytes='12', backup_count='3')
     self.assertTrue(isinstance(stream._max_bytes, int))
     self.assertTrue(isinstance(stream._backup_count, int))
     yield self.stop_arbiter()
     stream.close()
示例#3
0
 def start_arbiter(self):
     cls = TestWatcher
     stdout = {'stream': FileStream(cls.stdout)}
     stderr = {'stream': FileStream(cls.stderr)}
     self.file, self.arbiter = cls._create_circus(cls.dummy_process,
                                                  stdout_stream=stdout,
                                                  stderr_stream=stderr,
                                                  debug=True,
                                                  async=True)
     yield self.arbiter.start()
示例#4
0
 def setUp(self):
     super(TestPapaStream, self).setUp()
     fd, self.stdout = tempfile.mkstemp()
     os.close(fd)
     fd, self.stderr = tempfile.mkstemp()
     os.close(fd)
     self.stdout_stream = FileStream(self.stdout)
     self.stderr_stream = FileStream(self.stderr)
     self.stdout_arg = {'stream': self.stdout_stream}
     self.stderr_arg = {'stream': self.stderr_stream}
示例#5
0
 def setUp(self):
     super(TestWatcher, self).setUp()
     fd, self.stdout = tempfile.mkstemp()
     os.close(fd)
     fd, self.stderr = tempfile.mkstemp()
     os.close(fd)
     self.stdout_stream = FileStream(self.stdout)
     self.stderr_stream = FileStream(self.stderr)
     self.stdout_arg = {'stream': self.stdout_stream}
     self.stderr_arg = {'stream': self.stderr_stream}
示例#6
0
    def get_stream(self, *args, **kw):
        # need a constant timestamp
        now = datetime.now()
        stream = FileStream(*args, **kw)

        # patch some details that will be used
        stream._file = StringIO()
        stream._open = lambda: stream._file
        stream.now = lambda: now

        return stream
示例#7
0
    def get_stream(self, *args, **kw):
        # need a constant timestamp
        now = datetime.now()
        stream = FileStream(*args, **kw)

        # patch some details that will be used
        stream._file = StringIO()
        stream._open = lambda: stream._file
        stream.now = lambda: now

        return stream
示例#8
0
 def setUp(self):
     super(TestWatcher, self).setUp()
     dummy_process = 'circus.tests.test_stream.run_process'
     fd, self.stdout = tempfile.mkstemp()
     os.close(fd)
     fd, self.stderr = tempfile.mkstemp()
     os.close(fd)
     self.test_file = self._run_circus(
         dummy_process,
         stdout_stream={'stream': FileStream(self.stdout)},
         stderr_stream={'stream': FileStream(self.stderr)},
         debug=True)
示例#9
0
 def setUp(self):
     super(TestPapaStream, self).setUp()
     papa.set_debug_mode(quit_when_connection_closed=True)
     papa.set_default_port(self.papa_port)
     papa.set_default_connection_timeout(120)
     fd, self.stdout = tempfile.mkstemp()
     os.close(fd)
     fd, self.stderr = tempfile.mkstemp()
     os.close(fd)
     self.stdout_stream = FileStream(self.stdout)
     self.stderr_stream = FileStream(self.stderr)
     self.stdout_arg = {'stream': self.stdout_stream}
     self.stderr_arg = {'stream': self.stderr_stream}
示例#10
0
 def setUp(self):
     super(TestPapaStream, self).setUp()
     papa.set_debug_mode(quit_when_connection_closed=True)
     papa.set_default_port(self.papa_port)
     papa.set_default_connection_timeout(120)
     fd, self.stdout = tempfile.mkstemp()
     os.close(fd)
     fd, self.stderr = tempfile.mkstemp()
     os.close(fd)
     self.stdout_stream = FileStream(self.stdout)
     self.stderr_stream = FileStream(self.stderr)
     self.stdout_arg = {'stream': self.stdout_stream}
     self.stderr_arg = {'stream': self.stderr_stream}
示例#11
0
    def setUpClass(cls):
        dummy_process = 'circus.tests.test_stream.run_process'
        fd, cls.stdout = tempfile.mkstemp()
        os.close(fd)
        fd, cls.stderr = tempfile.mkstemp()
        os.close(fd)
        stdout = {'stream': FileStream(cls.stdout)}
        stderr = {'stream': FileStream(cls.stderr)}
        cls.file, cls.arbiter = cls._create_circus(dummy_process,
                                                   stdout_stream=stdout,
                                                   stderr_stream=stderr,
                                                   debug=True)

        poll_for(cls.file, 'START')
示例#12
0
 def pid_to_slot_number_stream(self, pid):
     if pid in self._slots:
         return self._slots[pid]
     self.clean_old_pids()
     used_slot_numbers = [x[0] for x in self._slots.values()]
     for i in range(0, self._numprocesses):
         if i not in used_slot_numbers:
             fn = self._filename.replace('{SLOT}', str(i))
             stream = FileStream(filename=fn, time_format=self._time_format)
             stream.open()
             self._slots[pid] = (i, stream)
             return (i, stream)
     log.warning("can't find a slot number for pid=%i" % pid)
     return (None, None)
示例#13
0
 def start_arbiter(self):
     cls = TestWatcher
     fd, cls.stdout = tempfile.mkstemp()
     os.close(fd)
     fd, cls.stderr = tempfile.mkstemp()
     os.close(fd)
     cls.stdout_stream = FileStream(cls.stdout)
     cls.stderr_stream = FileStream(cls.stderr)
     stdout = {'stream': cls.stdout_stream}
     stderr = {'stream': cls.stderr_stream}
     self.file, self.arbiter = cls._create_circus(cls.dummy_process,
                                                  stdout_stream=stdout,
                                                  stderr_stream=stderr,
                                                  debug=True, async=True)
     yield self.arbiter.start()
示例#14
0
    def test_handler(self):
        log = self._get_file()
        stream = {'stream': FileStream(log)}

        self._run_circus('circus.tests.test_stats_client.run_process',
                         stdout_stream=stream,
                         stderr_stream=stream,
                         stats=True)
        time.sleep(.5)

        # checking that our system is live and running
        client = CircusClient()
        res = client.send_message('list')
        watchers = res['watchers']
        watchers.sort()
        self.assertEqual(['circusd-stats', 'test'], watchers)

        # making sure the stats process run
        res = client.send_message('status', name='test')
        self.assertEqual(res['status'], 'active')

        res = client.send_message('status', name='circusd-stats')
        self.assertEqual(res['status'], 'active')

        # playing around with the stats now: we should get some !
        from circus.stats.client import StatsClient
        client = StatsClient()
        next = client.iter_messages().next

        for i in range(10):
            watcher, pid, stat = next()
            self.assertTrue(watcher in ('test', 'circusd-stats', 'circus'),
                            watcher)
示例#15
0
    def test_handler(self):
        log = self._get_file()
        stream = {'stream': FileStream(log)}
        cmd = 'circus.tests.test_stats_client.run_process'
        stdout_stream = stream
        stderr_stream = stream
        yield self.start_arbiter(cmd=cmd,
                                 stdout_stream=stdout_stream,
                                 stderr_stream=stderr_stream,
                                 stats=True,
                                 debug=False)

        # waiting for data to appear in the file stream
        empty = True
        while empty:
            with open(log) as f:
                empty = f.read() == ''
            yield tornado_sleep(.1)

        # checking that our system is live and running
        client = AsyncCircusClient(endpoint=self.arbiter.endpoint)
        res = yield client.send_message('list')

        watchers = sorted(res['watchers'])
        self.assertEqual(['circusd-stats', 'test'], watchers)

        # making sure the stats process run
        res = yield client.send_message('status', name='test')
        self.assertEqual(res['status'], 'active')

        res = yield client.send_message('status', name='circusd-stats')
        self.assertEqual(res['status'], 'active')

        # playing around with the stats now: we should get some !
        from circus.stats.client import StatsClient
        client = StatsClient(endpoint=self.arbiter.stats_endpoint)

        message_iterator = client.iter_messages()

        for i in range(10):
            watcher, pid, stat = next(message_iterator)
            self.assertTrue(watcher in ('test', 'circusd-stats', 'circus'),
                            watcher)
        yield self.stop_arbiter()
示例#16
0
    def test_handler(self):
        if os.getenv('TRAVIS', False):
            return

        log = self._get_file()
        stream = {'stream': FileStream(log)}
        self._run_circus('circus.tests.test_stats_client.run_process',
                         stdout_stream=stream,
                         stderr_stream=stream,
                         stats=True)

        # waiting for data to appear in the file stream
        empty = True
        while empty:
            with open(log) as f:
                empty = f.read() == ''

            time.sleep(.1)

        # checking that our system is live and running
        client = CircusClient()
        res = client.send_message('list')
        watchers = res['watchers']
        watchers.sort()
        self.assertEqual(['circusd-stats', 'test'], watchers)

        # making sure the stats process run
        res = client.send_message('status', name='test')
        self.assertEqual(res['status'], 'active')

        res = client.send_message('status', name='circusd-stats')
        self.assertEqual(res['status'], 'active')

        # playing around with the stats now: we should get some !
        from circus.stats.client import StatsClient
        client = StatsClient()
        next = client.iter_messages().next

        for i in range(10):
            watcher, pid, stat = next()
            self.assertTrue(watcher in ('test', 'circusd-stats', 'circus'),
                            watcher)
示例#17
0
class TestWatcher(TestCircus):
    dummy_process = 'circus.tests.test_stream.run_process'

    def setUp(self):
        super(TestWatcher, self).setUp()
        fd, self.stdout = tempfile.mkstemp()
        os.close(fd)
        fd, self.stderr = tempfile.mkstemp()
        os.close(fd)
        self.stdout_stream = FileStream(self.stdout)
        self.stderr_stream = FileStream(self.stderr)
        self.stdout_arg = {'stream': self.stdout_stream}
        self.stderr_arg = {'stream': self.stderr_stream}

    def tearDown(self):
        self.stdout_stream.close()
        self.stderr_stream.close()
        if os.path.exists(self.stdout):
            os.remove(self.stdout)
        if os.path.exists(self.stderr):
            os.remove(self.stderr)

    @tornado.gen.coroutine
    def _start_arbiter(self):
        yield self.start_arbiter(cmd=self.dummy_process,
                                 stdout_stream=self.stdout_arg,
                                 stderr_stream=self.stderr_arg)

    @tornado.gen.coroutine
    def restart_arbiter(self):
        yield self.arbiter.restart()

    @tornado.gen.coroutine
    def call(self, _cmd, **props):
        msg = make_message(_cmd, **props)
        resp = yield self.cli.call(msg)
        raise tornado.gen.Return(resp)

    @skipIf(IS_WINDOWS, "Streams not supported")
    @tornado.testing.gen_test
    def test_file_stream(self):
        yield self._start_arbiter()
        stream = FileStream(self.stdout, max_bytes='12', backup_count='3')
        self.assertTrue(isinstance(stream._max_bytes, int))
        self.assertTrue(isinstance(stream._backup_count, int))
        yield self.stop_arbiter()
        stream.close()

    @skipIf(IS_WINDOWS, "Streams not supported")
    @tornado.testing.gen_test
    def test_watched_file_stream(self):
        yield self._start_arbiter()
        stream = WatchedFileStream(self.stdout,
                                   time_format='%Y-%m-%d %H:%M:%S')
        self.assertTrue(isinstance(stream._time_format, str))
        yield self.stop_arbiter()
        stream.close()

    @skipIf(IS_WINDOWS, "Streams not supported")
    @tornado.testing.gen_test
    def test_timed_rotating_file_stream(self):
        yield self._start_arbiter()
        stream = TimedRotatingFileStream(self.stdout,
                                         rotate_when='H',
                                         rotate_interval='5',
                                         backup_count='3',
                                         utc='True')
        self.assertTrue(isinstance(stream._interval, int))
        self.assertTrue(isinstance(stream._backup_count, int))
        self.assertTrue(isinstance(stream._utc, bool))
        self.assertTrue(stream._suffix is not None)
        self.assertTrue(stream._ext_match is not None)
        self.assertTrue(stream._rollover_at > 0)
        yield self.stop_arbiter()
        stream.close()

    @skipIf(IS_WINDOWS, "Streams not supported")
    @tornado.testing.gen_test
    def test_stream(self):
        yield self._start_arbiter()
        # wait for the process to be started
        res1 = yield async_poll_for(self.stdout, 'stdout')
        res2 = yield async_poll_for(self.stderr, 'stderr')
        self.assertTrue(res1)
        self.assertTrue(res2)

        # clean slate
        truncate_file(self.stdout)
        truncate_file(self.stderr)

        # restart and make sure streams are still working
        yield self.restart_arbiter()

        # wait for the process to be restarted
        res1 = yield async_poll_for(self.stdout, 'stdout')
        res2 = yield async_poll_for(self.stderr, 'stderr')
        self.assertTrue(res1)
        self.assertTrue(res2)
        yield self.stop_arbiter()

    @skipIf(IS_WINDOWS, "Streams not supported")
    @tornado.testing.gen_test
    def test_stop_and_restart(self):
        # cf https://github.com/circus-tent/circus/issues/912

        yield self._start_arbiter()
        # wait for the process to be started
        res1 = yield async_poll_for(self.stdout, 'stdout')
        res2 = yield async_poll_for(self.stderr, 'stderr')
        self.assertTrue(res1)
        self.assertTrue(res2)
        self.assertFalse(self.stdout_stream._file.closed)
        self.assertFalse(self.stderr_stream._file.closed)

        # clean slate
        truncate_file(self.stdout)
        truncate_file(self.stderr)

        # stop the watcher
        yield self.arbiter.watchers[0].stop()

        self.assertTrue(self.stdout_stream._file.closed)
        self.assertTrue(self.stderr_stream._file.closed)

        # start it again
        yield self.arbiter.watchers[0].start()

        # wait for the process to be restarted
        res1 = yield async_poll_for(self.stdout, 'stdout')
        res2 = yield async_poll_for(self.stderr, 'stderr')
        self.assertTrue(res1)
        self.assertTrue(res2)
        self.assertFalse(self.stdout_stream._file.closed)
        self.assertFalse(self.stderr_stream._file.closed)

        yield self.stop_arbiter()
示例#18
0
class TestWatcher(TestCircus):
    dummy_process = 'circus.tests.test_stream.run_process'

    def setUp(self):
        super(TestWatcher, self).setUp()
        fd, self.stdout = tempfile.mkstemp()
        os.close(fd)
        fd, self.stderr = tempfile.mkstemp()
        os.close(fd)
        self.stdout_stream = FileStream(self.stdout)
        self.stderr_stream = FileStream(self.stderr)
        self.stdout_arg = {'stream': self.stdout_stream}
        self.stderr_arg = {'stream': self.stderr_stream}

    def tearDown(self):
        self.stdout_stream.close()
        self.stderr_stream.close()
        if os.path.exists(self.stdout):
            os.remove(self.stdout)
        if os.path.exists(self.stderr):
            os.remove(self.stderr)

    @tornado.gen.coroutine
    def _start_arbiter(self):
        yield self.start_arbiter(cmd=self.dummy_process,
                                 stdout_stream=self.stdout_arg,
                                 stderr_stream=self.stderr_arg)

    @tornado.gen.coroutine
    def restart_arbiter(self):
        yield self.arbiter.restart()

    @tornado.gen.coroutine
    def call(self, _cmd, **props):
        msg = make_message(_cmd, **props)
        resp = yield self.cli.call(msg)
        raise tornado.gen.Return(resp)

    @skipIf(IS_WINDOWS, "Streams not supported")
    @tornado.testing.gen_test
    def test_file_stream(self):
        yield self._start_arbiter()
        stream = FileStream(self.stdout, max_bytes='12', backup_count='3')
        self.assertTrue(isinstance(stream._max_bytes, int))
        self.assertTrue(isinstance(stream._backup_count, int))
        yield self.stop_arbiter()
        stream.close()

    @skipIf(IS_WINDOWS, "Streams not supported")
    @tornado.testing.gen_test
    def test_watched_file_stream(self):
        yield self._start_arbiter()
        stream = WatchedFileStream(self.stdout,
                                   time_format='%Y-%m-%d %H:%M:%S')
        self.assertTrue(isinstance(stream._time_format, str))
        yield self.stop_arbiter()
        stream.close()

    @skipIf(IS_WINDOWS, "Streams not supported")
    @tornado.testing.gen_test
    def test_timed_rotating_file_stream(self):
        yield self._start_arbiter()
        stream = TimedRotatingFileStream(self.stdout,
                                         rotate_when='H',
                                         rotate_interval='5',
                                         backup_count='3',
                                         utc='True')
        self.assertTrue(isinstance(stream._interval, int))
        self.assertTrue(isinstance(stream._backup_count, int))
        self.assertTrue(isinstance(stream._utc, bool))
        self.assertTrue(stream._suffix is not None)
        self.assertTrue(stream._ext_match is not None)
        self.assertTrue(stream._rollover_at > 0)
        yield self.stop_arbiter()
        stream.close()

    @skipIf(IS_WINDOWS, "Streams not supported")
    @tornado.testing.gen_test
    def test_stream(self):
        yield self._start_arbiter()
        # wait for the process to be started
        res1 = yield async_poll_for(self.stdout, 'stdout')
        res2 = yield async_poll_for(self.stderr, 'stderr')
        self.assertTrue(res1)
        self.assertTrue(res2)

        # clean slate
        truncate_file(self.stdout)
        truncate_file(self.stderr)

        # restart and make sure streams are still working
        yield self.restart_arbiter()

        # wait for the process to be restarted
        res1 = yield async_poll_for(self.stdout, 'stdout')
        res2 = yield async_poll_for(self.stderr, 'stderr')
        self.assertTrue(res1)
        self.assertTrue(res2)
        yield self.stop_arbiter()

    @skipIf(IS_WINDOWS, "Streams not supported")
    @tornado.testing.gen_test
    def test_stop_and_restart(self):
        # cf https://github.com/circus-tent/circus/issues/912

        yield self._start_arbiter()
        # wait for the process to be started
        res1 = yield async_poll_for(self.stdout, 'stdout')
        res2 = yield async_poll_for(self.stderr, 'stderr')
        self.assertTrue(res1)
        self.assertTrue(res2)
        self.assertFalse(self.stdout_stream._file.closed)
        self.assertFalse(self.stderr_stream._file.closed)

        # clean slate
        truncate_file(self.stdout)
        truncate_file(self.stderr)

        # stop the watcher
        yield self.arbiter.watchers[0].stop()

        self.assertTrue(self.stdout_stream._file.closed)
        self.assertTrue(self.stderr_stream._file.closed)

        # start it again
        yield self.arbiter.watchers[0].start()

        # wait for the process to be restarted
        res1 = yield async_poll_for(self.stdout, 'stdout')
        res2 = yield async_poll_for(self.stderr, 'stderr')
        self.assertTrue(res1)
        self.assertTrue(res2)
        self.assertFalse(self.stdout_stream._file.closed)
        self.assertFalse(self.stderr_stream._file.closed)

        yield self.stop_arbiter()
示例#19
0
class TestPapaStream(TestCircus):
    dummy_process = 'circus.tests.test_stream.run_process'
    papa_port = random.randint(20000, 30000)

    def setUp(self):
        super(TestPapaStream, self).setUp()
        papa.set_debug_mode(quit_when_connection_closed=True)
        papa.set_default_port(self.papa_port)
        papa.set_default_connection_timeout(120)
        fd, self.stdout = tempfile.mkstemp()
        os.close(fd)
        fd, self.stderr = tempfile.mkstemp()
        os.close(fd)
        self.stdout_stream = FileStream(self.stdout)
        self.stderr_stream = FileStream(self.stderr)
        self.stdout_arg = {'stream': self.stdout_stream}
        self.stderr_arg = {'stream': self.stderr_stream}

    def tearDown(self):
        self.stdout_stream.close()
        self.stderr_stream.close()
        if os.path.exists(self.stdout):
            os.remove(self.stdout)
        if os.path.exists(self.stderr):
            os.remove(self.stderr)

    @tornado.gen.coroutine
    def _start_arbiter(self):
        yield self.start_arbiter(cmd=self.dummy_process,
                                 stdout_stream=self.stdout_arg,
                                 stderr_stream=self.stderr_arg,
                                 use_papa=True)

    @tornado.gen.coroutine
    def restart_arbiter(self):
        yield self.arbiter.restart()

    @tornado.gen.coroutine
    def call(self, _cmd, **props):
        msg = make_message(_cmd, **props)
        resp = yield self.cli.call(msg)
        raise tornado.gen.Return(resp)

    @skipIf(IS_WINDOWS, "Streams not supported")
    @tornado.testing.gen_test
    def test_file_stream(self):
        yield self._start_arbiter()
        stream = FileStream(self.stdout, max_bytes='12', backup_count='3')
        self.assertTrue(isinstance(stream._max_bytes, int))
        self.assertTrue(isinstance(stream._backup_count, int))
        yield self.stop_arbiter()
        stream.close()

    @skipIf(IS_WINDOWS, "Streams not supported")
    @tornado.testing.gen_test
    def test_watched_file_stream(self):
        yield self._start_arbiter()
        stream = WatchedFileStream(self.stdout,
                                   time_format='%Y-%m-%d %H:%M:%S')
        self.assertTrue(isinstance(stream._time_format, str))
        yield self.stop_arbiter()
        stream.close()

    @skipIf(IS_WINDOWS, "Streams not supported")
    @tornado.testing.gen_test
    def test_timed_rotating_file_stream(self):
        yield self._start_arbiter()
        stream = TimedRotatingFileStream(self.stdout,
                                         rotate_when='H',
                                         rotate_interval='5',
                                         backup_count='3',
                                         utc='True')
        self.assertTrue(isinstance(stream._interval, int))
        self.assertTrue(isinstance(stream._backup_count, int))
        self.assertTrue(isinstance(stream._utc, bool))
        self.assertTrue(stream._suffix is not None)
        self.assertTrue(stream._ext_match is not None)
        self.assertTrue(stream._rollover_at > 0)
        yield self.stop_arbiter()
        stream.close()

    @skipIf(IS_WINDOWS, "Streams not supported")
    @tornado.testing.gen_test
    def test_stream(self):
        yield self._start_arbiter()
        # wait for the process to be started
        res1 = yield async_poll_for(self.stdout, 'stdout')
        res2 = yield async_poll_for(self.stderr, 'stderr')
        self.assertTrue(res1)
        self.assertTrue(res2)

        # clean slate
        truncate_file(self.stdout)
        truncate_file(self.stderr)

        # restart and make sure streams are still working
        yield self.restart_arbiter()

        # wait for the process to be restarted
        res1 = yield async_poll_for(self.stdout, 'stdout')
        res2 = yield async_poll_for(self.stderr, 'stderr')
        self.assertTrue(res1)
        self.assertTrue(res2)
        yield self.stop_arbiter()
示例#20
0
 def test_file_stream(self):
     stream = FileStream(self.stdout, max_bytes='12', backup_count='3')
     self.assertTrue(isinstance(stream._max_bytes, int))
     self.assertTrue(isinstance(stream._backup_count, int))
示例#21
0
class TestPapaStream(TestCircus):
    dummy_process = 'circus.tests.test_stream.run_process'
    papa_port = random.randint(20000, 30000)

    def setUp(self):
        super(TestPapaStream, self).setUp()
        papa.set_debug_mode(quit_when_connection_closed=True)
        papa.set_default_port(self.papa_port)
        papa.set_default_connection_timeout(120)
        fd, self.stdout = tempfile.mkstemp()
        os.close(fd)
        fd, self.stderr = tempfile.mkstemp()
        os.close(fd)
        self.stdout_stream = FileStream(self.stdout)
        self.stderr_stream = FileStream(self.stderr)
        self.stdout_arg = {'stream': self.stdout_stream}
        self.stderr_arg = {'stream': self.stderr_stream}

    def tearDown(self):
        self.stdout_stream.close()
        self.stderr_stream.close()
        if os.path.exists(self.stdout):
            os.remove(self.stdout)
        if os.path.exists(self.stderr):
            os.remove(self.stderr)

    @tornado.gen.coroutine
    def _start_arbiter(self):
        yield self.start_arbiter(cmd=self.dummy_process,
                                 stdout_stream=self.stdout_arg,
                                 stderr_stream=self.stderr_arg,
                                 use_papa=True)

    @tornado.gen.coroutine
    def restart_arbiter(self):
        yield self.arbiter.restart()

    @tornado.gen.coroutine
    def call(self, _cmd, **props):
        msg = make_message(_cmd, **props)
        resp = yield self.cli.call(msg)
        raise tornado.gen.Return(resp)

    @skipIf(IS_WINDOWS, "Streams not supported")
    @tornado.testing.gen_test
    def test_file_stream(self):
        yield self._start_arbiter()
        stream = FileStream(self.stdout, max_bytes='12', backup_count='3')
        self.assertTrue(isinstance(stream._max_bytes, int))
        self.assertTrue(isinstance(stream._backup_count, int))
        yield self.stop_arbiter()
        stream.close()

    @skipIf(IS_WINDOWS, "Streams not supported")
    @tornado.testing.gen_test
    def test_watched_file_stream(self):
        yield self._start_arbiter()
        stream = WatchedFileStream(self.stdout,
                                   time_format='%Y-%m-%d %H:%M:%S')
        self.assertTrue(isinstance(stream._time_format, str))
        yield self.stop_arbiter()
        stream.close()

    @skipIf(IS_WINDOWS, "Streams not supported")
    @tornado.testing.gen_test
    def test_timed_rotating_file_stream(self):
        yield self._start_arbiter()
        stream = TimedRotatingFileStream(self.stdout,
                                         rotate_when='H',
                                         rotate_interval='5',
                                         backup_count='3',
                                         utc='True')
        self.assertTrue(isinstance(stream._interval, int))
        self.assertTrue(isinstance(stream._backup_count, int))
        self.assertTrue(isinstance(stream._utc, bool))
        self.assertTrue(stream._suffix is not None)
        self.assertTrue(stream._ext_match is not None)
        self.assertTrue(stream._rollover_at > 0)
        yield self.stop_arbiter()
        stream.close()

    @skipIf(IS_WINDOWS, "Streams not supported")
    @tornado.testing.gen_test
    def test_stream(self):
        yield self._start_arbiter()
        # wait for the process to be started
        res1 = yield async_poll_for(self.stdout, 'stdout')
        res2 = yield async_poll_for(self.stderr, 'stderr')
        self.assertTrue(res1)
        self.assertTrue(res2)

        # clean slate
        truncate_file(self.stdout)
        truncate_file(self.stderr)

        # restart and make sure streams are still working
        yield self.restart_arbiter()

        # wait for the process to be restarted
        res1 = yield async_poll_for(self.stdout, 'stdout')
        res2 = yield async_poll_for(self.stderr, 'stderr')
        self.assertTrue(res1)
        self.assertTrue(res2)
        yield self.stop_arbiter()