3
3
import functools
4
4
import operator
5
5
import os
6
- import socket
7
6
import time
8
7
import uuid
9
8
10
9
import pytest
11
10
from . import unittest
12
11
13
- from kafka import SimpleClient , create_message
12
+ from kafka import SimpleClient
14
13
from kafka .errors import (
15
14
LeaderNotAvailableError , KafkaTimeoutError , InvalidTopicError ,
16
15
NotLeaderForPartitionError , UnknownTopicOrPartitionError ,
17
16
FailedPayloadsError
18
17
)
19
- from kafka .structs import OffsetRequestPayload , ProduceRequestPayload
18
+ from kafka .structs import OffsetRequestPayload
20
19
from test .fixtures import random_string , version_str_to_list , version as kafka_version #pylint: disable=wrong-import-order
21
20
22
21
@@ -67,26 +66,6 @@ def wrapper(func, *args, **kwargs):
67
66
return real_kafka_versions
68
67
69
68
70
- _MESSAGES = {}
71
- def msg (message ):
72
- """Format, encode and deduplicate a message
73
- """
74
- global _MESSAGES #pylint: disable=global-statement
75
- if message not in _MESSAGES :
76
- _MESSAGES [message ] = '%s-%s' % (message , str (uuid .uuid4 ()))
77
-
78
- return _MESSAGES [message ].encode ('utf-8' )
79
-
80
- def send_messages (client , topic , partition , messages ):
81
- """Send messages to a topic's partition
82
- """
83
- messages = [create_message (msg (str (m ))) for m in messages ]
84
- produce = ProduceRequestPayload (topic , partition , messages = messages )
85
- resp , = client .send_produce_request ([produce ])
86
- assert resp .error == 0
87
-
88
- return [x .value for x in messages ]
89
-
90
69
def current_offset (client , topic , partition , kafka_broker = None ):
91
70
"""Get the current offset of a topic's partition
92
71
"""
@@ -101,6 +80,7 @@ def current_offset(client, topic, partition, kafka_broker=None):
101
80
else :
102
81
return offsets .offsets [0 ]
103
82
83
+
104
84
class KafkaIntegrationTestCase (unittest .TestCase ):
105
85
create_client = True
106
86
topic = None
0 commit comments