This is an automated email from the ASF dual-hosted git repository.
guozhang pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git
The following commit(s) were added to refs/heads/trunk by this push:
new 0fa9593 HOTFIX: fix validity check in sticky assignor tests (#8815)
0fa9593 is described below
commit 0fa95935dbe9b942f44088010a8fd8b742572ab1
Author: A. Sophie Blee-Goldman <sophie@confluent.io>
AuthorDate: Mon Jun 8 16:08:27 2020 -0700
HOTFIX: fix validity check in sticky assignor tests (#8815)
Reviewers: Guozhang Wang <wangguoz@gmail.com>
---
.../internals/AbstractStickyAssignorTest.java | 38 +++++++---------------
1 file changed, 12 insertions(+), 26 deletions(-)
diff --git a/clients/src/test/java/org/apache/kafka/clients/consumer/internals/AbstractStickyAssignorTest.java
b/clients/src/test/java/org/apache/kafka/clients/consumer/internals/AbstractStickyAssignorTest.java
index b4c9b05..7ce765a 100644
--- a/clients/src/test/java/org/apache/kafka/clients/consumer/internals/AbstractStickyAssignorTest.java
+++ b/clients/src/test/java/org/apache/kafka/clients/consumer/internals/AbstractStickyAssignorTest.java
@@ -760,32 +760,18 @@ public abstract class AbstractStickyAssignorTest {
Map<String, List<Integer>> map = CollectionUtils.groupPartitionsByTopic(partitions);
Map<String, List<Integer>> otherMap = CollectionUtils.groupPartitionsByTopic(otherPartitions);
- if (len > otherLen) {
- for (String topic: map.keySet())
- if (otherMap.containsKey(topic))
- //assertTrue(true);
- assertFalse("Error: Some partitions can be moved from c" + i + "
to c" + j
- + " to achieve a better balance"
- + "\nc" + i + " has " + len + " partitions, and c" + j +
" has " + otherLen
- + " partitions."
- + "\nSubscriptions: " + subscriptions.toString() + "\nAssignments:
" + assignments
- .toString(),
- otherMap.containsKey(topic));
-
-
-
- }
-
- if (otherLen > len) {
- for (String topic: otherMap.keySet())
- if (otherMap.containsKey(topic))
- //assertTrue(true);
- assertFalse("Error: Some partitions can be moved from c" + j + "
to c" + i + " to achieve a better balance"
- + "\nc" + i + " has " + len + " partitions, and c" + j +
" has " + otherLen + " partitions."
- + "\nSubscriptions: " + subscriptions.toString() + "\nAssignments:
" + assignments.toString(),
- map.containsKey(topic));
-
-
+ int moreLoaded = len > otherLen ? i : j;
+ int lessLoaded = len > otherLen ? j : i;
+
+ // If there's any overlap in the subscribed topics, we should have been able
to balance partitions
+ for (String topic: map.keySet()) {
+ assertFalse("Error: Some partitions can be moved from c" + moreLoaded
+ " to c" + lessLoaded
+ + " to achieve a better balance"
+ + "\nc" + i + " has " + len + " partitions, and c" + j + " has
" + otherLen
+ + " partitions."
+ + "\nSubscriptions: " + subscriptions.toString() + "\nAssignments:
" + assignments
+ .toString(),
+ otherMap.containsKey(topic));
}
}
}
|