For 66 members, 213 partitions, each member should get 213/66 = 3.22 partitions. This means that in practice, each member should get either 3 or 4 partitions assigned to it. Any other number is a failure.
(t *testing.T)
| 196 | // This means that in practice, each member should get either 3 or 4 partitions |
| 197 | // assigned to it. Any other number is a failure. |
| 198 | func TestRangeAssignGroupsUnbalanced(t *testing.T) { |
| 199 | members := []GroupMember{} |
| 200 | for i := 0; i < 66; i++ { |
| 201 | members = append(members, GroupMember{ |
| 202 | ID: strconv.Itoa(i), |
| 203 | Topics: []string{"topic-1"}, |
| 204 | }) |
| 205 | } |
| 206 | partitions := []Partition{} |
| 207 | for i := 0; i < 213; i++ { |
| 208 | partitions = append(partitions, Partition{ |
| 209 | ID: i, |
| 210 | Topic: "topic-1", |
| 211 | }) |
| 212 | } |
| 213 | |
| 214 | assignments := RangeGroupBalancer{}.AssignGroups(members, partitions) |
| 215 | if len(assignments) != len(members) { |
| 216 | t.Fatalf("Assignment count mismatch: %d != %d", len(assignments), len(members)) |
| 217 | } |
| 218 | |
| 219 | for _, m := range assignments { |
| 220 | if len(m["topic-1"]) < 3 || len(m["topic-1"]) > 4 { |
| 221 | t.Fatalf("Expected assignment of 3 or 4 partitions, got %d", len(m["topic-1"])) |
| 222 | } |
| 223 | } |
| 224 | } |
| 225 | |
| 226 | func TestRoundRobinAssignGroups(t *testing.T) { |
| 227 | newPartitions := func(partitionCount int, topics ...string) []Partition { |
nothing calls this directly
no test coverage detected