Skip to content

Commit

Permalink
improve test and add changelog note
Browse files Browse the repository at this point in the history
  • Loading branch information
d1egoaz committed Jan 16, 2020
1 parent 11f91ad commit 7728893
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog


#### Unreleased

Improvements:
- Enabled producing with zstd compression
([1574](https://github.com/Shopify/sarama/pull/1574))

Known Issues:
- Consuming zstd topics doesn't work right now

#### Version 1.25.0 (2020-01-13)

New Features:
Expand Down
28 changes: 25 additions & 3 deletions zstd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,40 @@ func TestSaramaZSTD(t *testing.T) {
cfg.Producer.Retry.Max = 0
cfg.Producer.Compression = CompressionZSTD
cfg.Version = V2_1_0_0
kafkaHome := []string{"localhost:9092"}
topic := "my-zstd-topic"

producer, err := NewSyncProducer([]string{"localhost:9092"}, cfg)
admin, err := NewClusterAdmin(kafkaHome, cfg)
if err != nil {
t.Fatal(err)
}
_ = admin.DeleteTopic(topic)
err = admin.CreateTopic(topic, &TopicDetail{NumPartitions: 1, ReplicationFactor: 1}, false)
if err.Error() != "kafka server: Topic with this name already exists. - Topic 'my-zstd-topic' already exists." {
t.Fatal(err)
}
defer func() {
if err := admin.Close(); err != nil {
t.Error(err)
}
}()

// producer
producer, err := NewSyncProducer(kafkaHome, cfg)
defer func() {
if err := producer.Close(); err != nil {
t.Error(err)
}
}()
if err != nil {
t.Fatalf("NewSyncProducer failed: %v", err)
}
_, _, err = producer.SendMessage(
&ProducerMessage{
Topic: "my-topic",
Topic: topic,
Value: StringEncoder("hello world!"),
})
if err != nil {
t.Errorf("TEST: sending message failed: %v\n", err)
}
_ = producer.Close()
}

0 comments on commit 7728893

Please sign in to comment.