Skip to content

Commit

Permalink
Merge pull request #1930 from Shopify/dnwe/fix-balance-strategy-test
Browse files Browse the repository at this point in the history
fix(test): use correct param and equivalence check
  • Loading branch information
dnwe authored May 5, 2021
2 parents 16dacfe + 784e249 commit bbf1d62
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions balance_strategy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1765,7 +1765,7 @@ func Test_stickyBalanceStrategy_Plan_ReassignmentWithRandomSubscriptionsAndChang
}
}
plan2, err := s.Plan(membersPlan2, partitionsPerTopic)
verifyPlanIsBalancedAndSticky(t, s, members, plan2, err)
verifyPlanIsBalancedAndSticky(t, s, membersPlan2, plan2, err)
}
}

Expand Down Expand Up @@ -2121,6 +2121,7 @@ func BenchmarkStickAssignmentWithLargeNumberOfConsumersAndTopicsAndExistingAssig
}

func verifyPlanIsBalancedAndSticky(t *testing.T, s *stickyBalanceStrategy, members map[string]ConsumerGroupMemberMetadata, plan BalanceStrategyPlan, err error) {
t.Helper()
if err != nil {
t.Errorf("stickyBalanceStrategy.Plan() error = %v", err)
return
Expand All @@ -2133,6 +2134,7 @@ func verifyPlanIsBalancedAndSticky(t *testing.T, s *stickyBalanceStrategy, membe
}

func verifyValidityAndBalance(t *testing.T, consumers map[string]ConsumerGroupMemberMetadata, plan BalanceStrategyPlan) {
t.Helper()
size := len(consumers)
if size != len(plan) {
t.Errorf("Subscription size (%d) not equal to plan size (%d)", size, len(plan))
Expand All @@ -2151,13 +2153,13 @@ func verifyValidityAndBalance(t *testing.T, consumers map[string]ConsumerGroupMe
for assignedTopic := range plan[memberID] {
found := false
for _, assignableTopic := range consumers[memberID].Topics {
if assignableTopic == assignableTopic {
if assignableTopic == assignedTopic {
found = true
break
}
}
if !found {
t.Errorf("Consumer %s had assigned topic %s that wasn't in the list of assignable topics", memberID, assignedTopic)
t.Errorf("Consumer %s had assigned topic %q that wasn't in the list of assignable topics %v", memberID, assignedTopic, consumers[memberID].Topics)
t.FailNow()
}
}
Expand Down

0 comments on commit bbf1d62

Please sign in to comment.