def test_module_tippingbucket_time(): # Bucket spills in 1 second actor_config = ActorConfig('tippingbucket', 100, 1, {}, "") bucket = TippingBucket(actor_config, bucket_age=1) bucket.pool.queue.inbox.disableFallThrough() bucket.pool.queue.outbox.disableFallThrough() bucket.start() bucket.pool.queue.inbox.put(Event("hello")) sleep(1) b = getter(bucket.pool.queue.outbox) assert b.size() == 1 bucket.stop()
def test_module_tippingbucket_size(): # Wraps 10 events into a bulk event. actor_config = ActorConfig('tippingbucket', 100, 1, {}, "") bucket = TippingBucket(actor_config, bucket_size=10) bucket.pool.queue.inbox.disableFallThrough() bucket.pool.queue.outbox.disableFallThrough() bucket.start() for c in range(0, 11): bucket.pool.queue.inbox.put(Event(c)) b = getter(bucket.pool.queue.outbox) assert isinstance(b, Bulk) assert b.size() == 10 bucket.stop()