Skip to content

Commit

Permalink
contrib/Shopify/sarama: use sarama.MinVersion in tests. (#761)
Browse files Browse the repository at this point in the history
Starting in github.com/Shopify/sarama@v1.27.1, the default kafka version
that the client uses is 1.0.0 (sarama.V1_0_0_0) rather that the previous
0.8.2 (sarama.V0_8_2_0) Unfortunately, the Sarama client for Kafka 1.0.0
does not work with the mock broker, so this change breaks our tests. To
repair the situation, we specify that the client should use version 0.8.2.
If Sarama fixes their mock client in the future, we can use the default
version instead.
  • Loading branch information
knusbaum authored Oct 15, 2020
1 parent 54b73b3 commit 6514d0b
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions contrib/Shopify/sarama/sarama_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ func TestConsumer(t *testing.T) {
SetMessage("test-topic", 0, 0, sarama.StringEncoder("hello")).
SetMessage("test-topic", 0, 1, sarama.StringEncoder("world")),
})

client, err := sarama.NewClient([]string{broker.Addr()}, sarama.NewConfig())
cfg := sarama.NewConfig()
cfg.Version = sarama.MinVersion
client, err := sarama.NewClient([]string{broker.Addr()}, cfg)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -113,6 +114,7 @@ func TestSyncProducer(t *testing.T) {
leader.Returns(prodSuccess)

cfg := sarama.NewConfig()
cfg.Version = sarama.MinVersion
cfg.Producer.Return.Successes = true

producer, err := sarama.NewSyncProducer([]string{seedBroker.Addr()}, cfg)
Expand Down Expand Up @@ -160,6 +162,7 @@ func TestSyncProducerSendMessages(t *testing.T) {
leader.Returns(prodSuccess)

cfg := sarama.NewConfig()
cfg.Version = sarama.MinVersion
cfg.Producer.Return.Successes = true
cfg.Producer.Flush.Messages = 2

Expand Down Expand Up @@ -200,7 +203,9 @@ func TestAsyncProducer(t *testing.T) {

broker := newMockBroker(t)

producer, err := sarama.NewAsyncProducer([]string{broker.Addr()}, nil)
cfg := sarama.NewConfig()
cfg.Version = sarama.MinVersion
producer, err := sarama.NewAsyncProducer([]string{broker.Addr()}, cfg)
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -234,6 +239,7 @@ func TestAsyncProducer(t *testing.T) {
broker := newMockBroker(t)

cfg := sarama.NewConfig()
cfg.Version = sarama.MinVersion
cfg.Producer.Return.Successes = true

producer, err := sarama.NewAsyncProducer([]string{broker.Addr()}, cfg)
Expand Down

0 comments on commit 6514d0b

Please sign in to comment.