def test_init_max_assignment_latency_history__default(self): assert ( Monitor( max_assignment_latency_history=33, ).max_assignment_latency_history == 33 )
async def test_service_sampler(self, *, mon): mon = Monitor() i = 0 mon.events_runtime = [] mon.sleep = AsyncMock(name='sleep') def on_cleanup(): nonlocal i mon.events_runtime.append(i + 0.34) i += 1 if i > 10: mon._stopped.set() mon._cleanup = Mock(name='_cleanup') mon._cleanup.side_effect = on_cleanup await mon._sampler(mon)
async def test_service_sampler(self, *, mon): mon = Monitor() i = 0 mon.events_runtime = [] mon.sleep = AsyncMock(name='sleep') def on_sample(prev_events, prev_messages): nonlocal i mon.events_runtime.append(i + 0.34) i += 1 if i > 10: mon._stopped.set() return prev_events, prev_messages mon._sample = Mock(name='_sample') mon._sample.side_effect = on_sample await mon._sampler(mon)
def test_init_max_send_latency_history(self): assert (Monitor().max_send_latency_history == Monitor.max_send_latency_history)
def test_init_max_commit_latency_history__default(self): assert Monitor( max_commit_latency_history=33, ).max_commit_latency_history == 33
def test_init_max_avg_history__default(self): assert Monitor(max_avg_history=33).max_avg_history == 33
def test_init_max_avg_history(self): assert Monitor().max_avg_history == Monitor.max_avg_history
def create_monitor(self, **kwargs: Any) -> Monitor: return Monitor(**kwargs)
def test_init_rebalances(self): assert Monitor(rebalances=99).rebalances == 99
def test_init_max_assignment_latency_history(self): assert (Monitor().max_assignment_latency_history == Monitor.max_assignment_latency_history)