summaryrefslogtreecommitdiff
path: root/test/test_producer.py
diff options
context:
space:
mode:
authorDana Powers <dana.powers@gmail.com>2016-03-13 13:40:41 -0700
committerDana Powers <dana.powers@gmail.com>2016-03-13 15:05:49 -0700
commita03c7ace89c4c39bdd8b1f4285a95155299da758 (patch)
tree4c5d0c5258323acefc6f8de495fae824c817b79d /test/test_producer.py
parentbd5bd62b09425140cf53a7fb61c56b88ce19ab96 (diff)
downloadkafka-python-a03c7ace89c4c39bdd8b1f4285a95155299da758.tar.gz
Add SimpleBufferPool test to verify reallocated buffers are empty
Diffstat (limited to 'test/test_producer.py')
-rw-r--r--test/test_producer.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/test/test_producer.py b/test/test_producer.py
index 829c6f2..8ef49b3 100644
--- a/test/test_producer.py
+++ b/test/test_producer.py
@@ -3,10 +3,23 @@ import sys
import pytest
from kafka import KafkaConsumer, KafkaProducer
+from kafka.producer.buffer import SimpleBufferPool
from test.conftest import version
from test.testutil import random_string
+def test_buffer_pool():
+ pool = SimpleBufferPool(1000, 1000)
+
+ buf1 = pool.allocate(1000, 1000)
+ message = ''.join(map(str, range(100)))
+ buf1.write(message.encode('utf-8'))
+ pool.deallocate(buf1)
+
+ buf2 = pool.allocate(1000, 1000)
+ assert buf2.read() == b''
+
+
@pytest.mark.skipif(not version(), reason="No KAFKA_VERSION set")
@pytest.mark.parametrize("compression", [None, 'gzip', 'snappy', 'lz4'])
def test_end_to_end(kafka_broker, compression):