Skip to content

Commit

Permalink
KAFKA-18763: changed the assertion statement for acknowledgements to …
Browse files Browse the repository at this point in the history
…include only successful acks (apache#18846)

Reviewers: Andrew Schofield <aschofield@confluent.io>
  • Loading branch information
chirag-wadhwa5 authored Feb 10, 2025
1 parent be89ce5 commit 7fef5b8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions tests/kafkatest/services/verifiable_share_consumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def __init__(self, node, idx, state=ShareConsumerState.Dead):
self.node = node
self.idx = idx
self.total_consumed = 0
self.total_acknowledged = 0
self.total_acknowledged_successfully = 0
self.total_acknowledged_failed = 0
self.consumed_per_partition = {}
self.acknowledged_per_partition = {}
Expand All @@ -52,7 +52,7 @@ def handle_startup_complete(self, node, logger):

def handle_offsets_acknowledged(self, event, node, logger):
if event["success"]:
self.total_acknowledged += event["count"]
self.total_acknowledged_successfully += event["count"]
for share_partition_data in event["partitions"]:
topic_partition = TopicPartition(share_partition_data["topic"], share_partition_data["partition"])
self.acknowledged_per_partition[topic_partition] = self.acknowledged_per_partition.get(topic_partition, 0) + share_partition_data["count"]
Expand Down Expand Up @@ -291,7 +291,7 @@ def total_acknowledged(self):
with self.lock:
return self.total_records_acknowledged + self.total_records_acknowledged_failed

def total_successful_acknowledged(self):
def total_acknowledged_successfully(self):
with self.lock:
return self.total_records_acknowledged

Expand All @@ -305,11 +305,11 @@ def total_consumed_for_a_share_consumer(self, node):

def total_acknowledged_for_a_share_consumer(self, node):
with self.lock:
return self.event_handlers[node].total_acknowledged + self.event_handlers[node].total_acknowledged_failed
return self.event_handlers[node].total_acknowledged_successfully + self.event_handlers[node].total_acknowledged_failed

def total_successful_acknowledged_for_a_share_consumer(self, node):
def total_acknowledged_sucessfully_for_a_share_consumer(self, node):
with self.lock:
return self.event_handlers[node].total_acknowledged
return self.event_handlers[node].total_acknowledged_successfully

def total_failed_acknowledged_for_a_share_consumer(self, node):
with self.lock:
Expand Down
8 changes: 4 additions & 4 deletions tests/kafkatest/tests/client/share_consumer_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,11 @@ def test_share_single_topic_partition(self, metadata_quorum=quorum.isolated_kraf
self.await_acknowledged_messages(consumer, min_messages=total_messages, timeout_sec=self.default_timeout_sec)

assert consumer.total_consumed() >= producer.num_acked
assert consumer.total_acknowledged() == producer.num_acked
assert consumer.total_acknowledged_successfully() == producer.num_acked

for event_handler in consumer.event_handlers.values():
assert event_handler.total_consumed > 0
assert event_handler.total_acknowledged > 0
assert event_handler.total_acknowledged_successfully > 0

producer.stop()
consumer.stop_all()
Expand All @@ -161,11 +161,11 @@ def test_share_multiple_partitions(self, metadata_quorum=quorum.isolated_kraft):
self.await_acknowledged_messages(consumer, min_messages=total_messages, timeout_sec=self.default_timeout_sec)

assert consumer.total_consumed() >= producer.num_acked
assert consumer.total_acknowledged() == producer.num_acked
assert consumer.total_acknowledged_successfully() == producer.num_acked

for event_handler in consumer.event_handlers.values():
assert event_handler.total_consumed > 0
assert event_handler.total_acknowledged > 0
assert event_handler.total_acknowledged_successfully > 0
for topic_partition in self.get_topic_partitions(self.TOPIC2):
assert topic_partition in event_handler.consumed_per_partition
assert event_handler.consumed_per_partition[topic_partition] > 0
Expand Down

0 comments on commit 7fef5b8

Please sign in to comment.