Skip to content

Commit eb5b6aa

Browse files
committed
test: fix test failures on sequential starts
1 parent a0f2f18 commit eb5b6aa

File tree

2 files changed

+21
-13
lines changed

2 files changed

+21
-13
lines changed

tests/consumer.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ local function test_seek_partitions()
203203
local out = consumer:output()
204204

205205
for _ = 1, 5 do
206-
local msg = out:get(3)
206+
local msg = out:get(10)
207207
if msg == nil then
208208
error('Message is not delivered')
209209
end

tests/test_consumer.py

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -211,12 +211,15 @@ def test_consumer_should_completely_unsubscribe_from_topics():
211211
"value": "test34"
212212
}
213213

214-
write_into_kafka("test_unsubscribe", (message1, message2))
214+
t = f"test_unsubscribe_{randomword(4)}"
215+
write_into_kafka(t, (message1, message2))
215216

216217
server = get_server()
217218

218-
with create_consumer(server, KAFKA_HOST, {"group.id": "should_completely_unsubscribe_from_topics"}):
219-
server.call("consumer.subscribe", [["test_unsubscribe"]])
219+
with create_consumer(server, KAFKA_HOST, {
220+
"group.id": "should_completely_unsubscribe_from_topics",
221+
}):
222+
server.call("consumer.subscribe", [[t]])
220223

221224
response = server.call("consumer.consume", [10])[0]
222225

@@ -225,9 +228,9 @@ def test_consumer_should_completely_unsubscribe_from_topics():
225228
"test2",
226229
}
227230

228-
server.call("consumer.unsubscribe", [["test_unsubscribe"]])
231+
server.call("consumer.unsubscribe", [[t]])
229232

230-
write_into_kafka("test_unsubscribe", (message3, ))
233+
write_into_kafka(t, (message3, ))
231234

232235
response = server.call("consumer.consume", [10])
233236

@@ -257,11 +260,16 @@ def test_consumer_should_partially_unsubscribe_from_topics():
257260

258261
server = get_server()
259262

260-
with create_consumer(server, KAFKA_HOST, {"group.id": "should_partially_unsubscribe_from_topics"}):
261-
server.call("consumer.subscribe", [["test_unsub_partially_1", "test_unsub_partially_2"]])
263+
salt = randomword(4)
264+
with create_consumer(server, KAFKA_HOST, {
265+
"group.id": f"should_partially_unsubscribe_from_topics_{salt}",
266+
}):
267+
t1 = f"test_unsub_partially_{salt}_1"
268+
t2 = f"test_unsub_partially_{salt}_2"
269+
server.call("consumer.subscribe", [[t1, t2]])
262270

263-
write_into_kafka("test_unsub_partially_1", (message1, ))
264-
write_into_kafka("test_unsub_partially_2", (message2, ))
271+
write_into_kafka(t1, (message1, ))
272+
write_into_kafka(t2, (message2, ))
265273
time.sleep(5)
266274

267275
# waiting up to 30 seconds
@@ -272,10 +280,10 @@ def test_consumer_should_partially_unsubscribe_from_topics():
272280
"test2",
273281
}
274282

275-
server.call("consumer.unsubscribe", [["test_unsub_partially_1"]])
283+
server.call("consumer.unsubscribe", [[t1]])
276284

277-
write_into_kafka("test_unsub_partially_1", (message3, ))
278-
write_into_kafka("test_unsub_partially_2", (message4, ))
285+
write_into_kafka(t1, (message3, ))
286+
write_into_kafka(t2, (message4, ))
279287
time.sleep(5)
280288

281289
response = server.call("consumer.consume", [30])[0]

0 commit comments

Comments
 (0)