-
-
Notifications
You must be signed in to change notification settings - Fork 508
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use new apache/kafka-native docker image for kafka module #2683
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,13 +2,11 @@ package kafka_test | |
|
||
import ( | ||
"context" | ||
"io" | ||
"strings" | ||
"testing" | ||
|
||
"github.com/IBM/sarama" | ||
|
||
"github.com/testcontainers/testcontainers-go" | ||
"github.com/testcontainers/testcontainers-go/modules/kafka" | ||
) | ||
|
||
|
@@ -17,7 +15,7 @@ func TestKafka(t *testing.T) { | |
|
||
ctx := context.Background() | ||
|
||
kafkaContainer, err := kafka.Run(ctx, "confluentinc/confluent-local:7.5.0", kafka.WithClusterID("kraftCluster")) | ||
kafkaContainer, err := kafka.Run(ctx, "apache/kafka-native:3.8.0", kafka.WithClusterID("kraftCluster")) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TODO: need some more tests on the client side to demonstrate this works + add tests for setting host port |
||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
@@ -29,8 +27,6 @@ func TestKafka(t *testing.T) { | |
} | ||
}) | ||
|
||
assertAdvertisedListeners(t, kafkaContainer) | ||
|
||
if !strings.EqualFold(kafkaContainer.ClusterID, "kraftCluster") { | ||
t.Fatalf("expected clusterID to be %s, got %s", "kraftCluster", kafkaContainer.ClusterID) | ||
} | ||
|
@@ -58,8 +54,6 @@ func TestKafka(t *testing.T) { | |
// wait for the consumer to be ready | ||
<-ready | ||
|
||
// perform assertions | ||
|
||
// set config to true because successfully delivered messages will be returned on the Successes channel | ||
config.Producer.Return.Successes = true | ||
|
||
|
@@ -87,41 +81,3 @@ func TestKafka(t *testing.T) { | |
t.Fatalf("expected value to be %s, got %s", "value", string(consumer.message.Value)) | ||
} | ||
} | ||
|
||
func TestKafka_invalidVersion(t *testing.T) { | ||
ctx := context.Background() | ||
|
||
_, err := kafka.Run(ctx, "confluentinc/confluent-local:6.3.3", kafka.WithClusterID("kraftCluster")) | ||
if err == nil { | ||
t.Fatal(err) | ||
} | ||
} | ||
|
||
// assertAdvertisedListeners checks that the advertised listeners are set correctly: | ||
// - The BROKER:// protocol is using the hostname of the Kafka container | ||
func assertAdvertisedListeners(t *testing.T, container testcontainers.Container) { | ||
inspect, err := container.Inspect(context.Background()) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
hostname := inspect.Config.Hostname | ||
|
||
code, r, err := container.Exec(context.Background(), []string{"cat", "/usr/sbin/testcontainers_start.sh"}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this script doesn't exist anymore in the kafka image - also I didn't think it was necessary to check advertisted listeners, considering if it's set incorrectly, the other tests would fail because kafka wouldn't work in the first place |
||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
if code != 0 { | ||
t.Fatalf("expected exit code to be 0, got %d", code) | ||
} | ||
|
||
bs, err := io.ReadAll(r) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
if !strings.Contains(string(bs), "BROKER://"+hostname+":9092") { | ||
t.Fatalf("expected advertised listeners to contain %s, got %s", "BROKER://"+hostname+":9092", string(bs)) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
every apache/kafka-native image supports kraft