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

Function TestClientRefreshBehaviour

client_test.go:551–586  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

549}
550
551func TestClientRefreshBehaviour(t *testing.T) {
552 seedBroker := NewMockBroker(t, 1)
553 leader := NewMockBroker(t, 5)
554
555 metadataResponse1 := new(MetadataResponse)
556 metadataResponse1.AddBroker(leader.Addr(), leader.BrokerID())
557 seedBroker.Returns(metadataResponse1)
558
559 metadataResponse2 := new(MetadataResponse)
560 metadataResponse2.AddBroker(leader.Addr(), leader.BrokerID())
561 metadataResponse2.AddTopicPartition("my_topic", 0xb, leader.BrokerID(), nil, nil, nil, ErrNoError)
562 leader.Returns(metadataResponse2)
563
564 client, err := NewClient([]string{seedBroker.Addr()}, NewTestConfig())
565 if err != nil {
566 t.Fatal(err)
567 }
568
569 parts, err := client.Partitions("my_topic")
570 if err != nil {
571 t.Error(err)
572 } else if len(parts) != 1 || parts[0] != 0xb {
573 t.Error("Client returned incorrect partitions for my_topic:", parts)
574 }
575
576 tst, err := client.Leader("my_topic", 0xb)
577 if err != nil {
578 t.Error(err)
579 } else if tst.ID() != 5 {
580 t.Error("Leader for my_topic had incorrect ID.")
581 }
582
583 leader.Close()
584 seedBroker.Close()
585 safeClose(t, client)
586}
587
588func TestClientRefreshBrokers(t *testing.T) {
589 initialSeed := NewMockBroker(t, 0)

Callers

nothing calls this directly

Calls 15

AddrMethod · 0.95
BrokerIDMethod · 0.95
ReturnsMethod · 0.95
PartitionsMethod · 0.95
LeaderMethod · 0.95
CloseMethod · 0.95
NewMockBrokerFunction · 0.85
AddBrokerMethod · 0.80
FatalMethod · 0.80
IDMethod · 0.80
NewClientFunction · 0.70
NewTestConfigFunction · 0.70

Tested by

no test coverage detected