Repository: kafka
Updated Branches:
  refs/heads/trunk 79987590e -> bf5aebadb


MINOR: Add offset information to consumer_test error messages

Author: Jason Gustafson <[email protected]>

Reviewers: Ismael Juma <[email protected]>

Closes #2426 from hachikuji/improve-consumer-test-error-messages


Project: http://git-wip-us.apache.org/repos/asf/kafka/repo
Commit: http://git-wip-us.apache.org/repos/asf/kafka/commit/bf5aebad
Tree: http://git-wip-us.apache.org/repos/asf/kafka/tree/bf5aebad
Diff: http://git-wip-us.apache.org/repos/asf/kafka/diff/bf5aebad

Branch: refs/heads/trunk
Commit: bf5aebadb54dd67d27e85cda0109bfc40f7e2883
Parents: 7998759
Author: Jason Gustafson <[email protected]>
Authored: Mon Jan 23 16:42:50 2017 -0800
Committer: Jason Gustafson <[email protected]>
Committed: Mon Jan 23 16:42:50 2017 -0800

----------------------------------------------------------------------
 tests/kafkatest/tests/client/consumer_test.py | 25 ++++++++++++++--------
 1 file changed, 16 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kafka/blob/bf5aebad/tests/kafkatest/tests/client/consumer_test.py
----------------------------------------------------------------------
diff --git a/tests/kafkatest/tests/client/consumer_test.py 
b/tests/kafkatest/tests/client/consumer_test.py
index a68e23e..ffaabbb 100644
--- a/tests/kafkatest/tests/client/consumer_test.py
+++ b/tests/kafkatest/tests/client/consumer_test.py
@@ -113,7 +113,8 @@ class OffsetValidationTest(VerifiableConsumerTest):
         consumer.stop_all()
 
         assert consumer.current_position(partition) == 
consumer.total_consumed(), \
-            "Total consumed records did not match consumed position"
+            "Total consumed records %d did not match consumed position %d" % \
+            (consumer.total_consumed(), consumer.current_position(partition))
 
     @cluster(num_nodes=7)
     @matrix(clean_shutdown=[True, False], bounce_mode=["all", "rolling"])
@@ -188,16 +189,19 @@ class OffsetValidationTest(VerifiableConsumerTest):
             # if the total records consumed matches the current position, we 
haven't seen any duplicates
             # this can only be guaranteed with a clean shutdown
             assert consumer.current_position(partition) == 
consumer.total_consumed(), \
-                "Total consumed records did not match consumed position"
+                "Total consumed records %d did not match consumed position %d" 
% \
+                (consumer.total_consumed(), 
consumer.current_position(partition))
         else:
             # we may have duplicates in a hard failure
             assert consumer.current_position(partition) <= 
consumer.total_consumed(), \
-                "Current position greater than the total number of consumed 
records"
+                "Current position %d greater than the total number of consumed 
records %d" % \
+                (consumer.current_position(partition), 
consumer.total_consumed())
 
         # if autocommit is not turned on, we can also verify the last 
committed offset
         if not enable_autocommit:
             assert consumer.last_commit(partition) == 
consumer.current_position(partition), \
-                "Last committed offset did not match last consumed position"
+                "Last committed offset %d did not match last consumed position 
%d" % \
+                (consumer.last_commit(partition), 
consumer.current_position(partition))
 
     @cluster(num_nodes=7)
     @matrix(clean_shutdown=[True, False], enable_autocommit=[True, False])
@@ -227,12 +231,14 @@ class OffsetValidationTest(VerifiableConsumerTest):
 
         # if the total records consumed matches the current position, we 
haven't seen any duplicates
         assert consumer.current_position(partition) == 
consumer.total_consumed(), \
-            "Total consumed records did not match consumed position"
+            "Total consumed records %d did not match consumed position %d" % \
+            (consumer.total_consumed(), consumer.current_position(partition))
 
         # if autocommit is not turned on, we can also verify the last 
committed offset
         if not enable_autocommit:
             assert consumer.last_commit(partition) == 
consumer.current_position(partition), \
-                "Last committed offset did not match last consumed position"
+                "Last committed offset %d did not match last consumed position 
%d" % \
+                (consumer.last_commit(partition), 
consumer.current_position(partition))
 
     @cluster(num_nodes=7)
     def test_group_consumption(self):
@@ -267,11 +273,12 @@ class OffsetValidationTest(VerifiableConsumerTest):
                 self.await_consumed_messages(consumer)
 
         assert consumer.current_position(partition) == 
consumer.total_consumed(), \
-            "Total consumed records did not match consumed position"
+            "Total consumed records %d did not match consumed position %d" % \
+            (consumer.total_consumed(), consumer.current_position(partition))
 
         assert consumer.last_commit(partition) == 
consumer.current_position(partition), \
-            "Last committed offset did not match last consumed position"
-
+            "Last committed offset %d did not match last consumed position %d" 
% \
+            (consumer.last_commit(partition), 
consumer.current_position(partition))
 
 class AssignmentValidationTest(VerifiableConsumerTest):
     TOPIC = "test_topic"

Reply via email to