handle single broker case

This commit is contained in:
chrislu
2024-03-01 05:59:40 -08:00
parent 50c5dd7313
commit fe03b1b522
2 changed files with 37 additions and 2 deletions

View File

@@ -83,6 +83,8 @@ func TestEnsureAssignmentsToActiveBrokersX(t *testing.T) {
lowActiveBrokers := cmap.New[*BrokerStats]()
lowActiveBrokers.SetIfAbsent("localhost:1", &BrokerStats{})
lowActiveBrokers.SetIfAbsent("localhost:2", &BrokerStats{})
singleActiveBroker := cmap.New[*BrokerStats]()
singleActiveBroker.SetIfAbsent("localhost:1", &BrokerStats{})
tests := []struct {
name string
args args
@@ -207,6 +209,23 @@ func TestEnsureAssignmentsToActiveBrokersX(t *testing.T) {
},
hasChanges: false,
},
{
name: "test single active broker",
args: args{
activeBrokers: singleActiveBroker,
followerCount: 3,
assignments: []*mq_pb.BrokerPartitionAssignment{
{
LeaderBroker: "localhost:1",
Partition: &mq_pb.Partition{},
FollowerBrokers: []string{
"localhost:2",
},
},
},
},
hasChanges: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {