HOTFIX: fix validity check in sticky assignor tests (#8815)

Reviewers: Guozhang Wang <wangguoz@gmail.com>
This commit is contained in:
A. Sophie Blee-Goldman 2020-06-08 16:08:27 -07:00 committed by GitHub
parent 5bcd7cca22
commit 0fa95935db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 25 deletions

View File

@ -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));
}
}
}