MCPcopy
hub / github.com/IBM/sarama / TestClusterAdminListPartitionReassignments

Function TestClusterAdminListPartitionReassignments

admin_test.go:601–646  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

599}
600
601func TestClusterAdminListPartitionReassignments(t *testing.T) {
602 seedBroker := NewMockBroker(t, 1)
603 defer seedBroker.Close()
604
605 secondBroker := NewMockBroker(t, 2)
606 defer secondBroker.Close()
607
608 seedBroker.SetHandlerByMap(map[string]MockResponse{
609 "ApiVersionsRequest": NewMockApiVersionsResponse(t),
610 "MetadataRequest": NewMockMetadataResponse(t).
611 SetController(secondBroker.BrokerID()).
612 SetBroker(seedBroker.Addr(), seedBroker.BrokerID()).
613 SetBroker(secondBroker.Addr(), secondBroker.BrokerID()),
614 })
615
616 secondBroker.SetHandlerByMap(map[string]MockResponse{
617 "ApiVersionsRequest": NewMockApiVersionsResponse(t),
618 "ListPartitionReassignmentsRequest": NewMockListPartitionReassignmentsResponse(t),
619 })
620
621 config := NewTestConfig()
622 config.Version = V2_4_0_0
623 admin, err := NewClusterAdmin([]string{seedBroker.Addr()}, config)
624 if err != nil {
625 t.Fatal(err)
626 }
627
628 response, err := admin.ListPartitionReassignments("my_topic", []int32{0, 1})
629 if err != nil {
630 t.Fatal(err)
631 }
632
633 partitionStatus, ok := response["my_topic"]
634 if !ok {
635 t.Fatalf("topic missing in response")
636 }
637
638 if len(partitionStatus) != 2 {
639 t.Fatalf("partition missing in response")
640 }
641
642 err = admin.Close()
643 if err != nil {
644 t.Fatal(err)
645 }
646}
647
648func TestClusterAdminListPartitionReassignmentsWithDiffVersion(t *testing.T) {
649 seedBroker := NewMockBroker(t, 1)

Callers

nothing calls this directly

Calls 15

CloseMethod · 0.95
SetHandlerByMapMethod · 0.95
BrokerIDMethod · 0.95
AddrMethod · 0.95
CloseMethod · 0.95
NewMockBrokerFunction · 0.85
NewMockMetadataResponseFunction · 0.85
NewClusterAdminFunction · 0.85
SetBrokerMethod · 0.80

Tested by

no test coverage detected