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()
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) next = get_next(client.iter_messages()) for i in range(10): watcher, pid, stat = next() self.assertTrue(watcher in ('test', 'circusd-stats', 'circus'), watcher) yield self.stop_arbiter()
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) # waiting for data to appear in the file stream empty = True while empty: with open(log) as f: empty = f.read() == "" yield tornado_sleep(0.1) # checking that our system is live and running client = AsyncCircusClient() 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() next = get_next(client.iter_messages()) for i in range(10): watcher, pid, stat = next() self.assertTrue(watcher in ("test", "circusd-stats", "circus"), watcher) yield self.stop_arbiter()