Skip to content

Commit 8b07400

Browse files
RabbitMQ vs Kafka: start apache/kafka 4.3.1 under Testcontainers 4.15.0
Testcontainers.Kafka 4.15.0 writes KAFKA_ADVERTISED_LISTENERS with a trailing comma, and apache/kafka:4.3.1 exits with "Configuration 'advertised.listeners' values must not be empty". The upstream fix (testcontainers-dotnet PR 1772) is not released yet, so the Kafka test's start command drops the comma from the generated startup script.
1 parent 9e60aa6 commit 8b07400

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

  • dotnet-client-libraries/RabbitMqVsKafka/RabbitMqVsKafka.Tests

‎dotnet-client-libraries/RabbitMqVsKafka/RabbitMqVsKafka.Tests/BrokerTests.cs‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ public async Task RabbitQueue_AcksGoodOrders_DeadLettersPoisonOrder_LeavesNothin
2828
[Fact]
2929
public async Task Kafka_CommitsGoodOrders_DeadLettersPoisonOrder_SecondGroupAndReplayReadAllFive()
3030
{
31-
await using var kafka = new KafkaBuilder("apache/kafka:4.3.1").Build();
31+
await using var kafka = new KafkaBuilder("apache/kafka:4.3.1")
32+
.WithCommand(StartKafkaWithoutTrailingComma)
33+
.Build();
3234
await kafka.StartAsync(TestContext.Current.CancellationToken);
3335

3436
var result = await new KafkaDemo(kafka.GetBootstrapAddress()).RunAsync();
@@ -50,4 +52,14 @@ public async Task RabbitStream_TwoReadersFromFirstOffset_BothReadAllFive()
5052
Assert.Equal(AllOrders, first);
5153
Assert.Equal(AllOrders, second);
5254
}
55+
56+
// Testcontainers.Kafka 4.15.0 writes KAFKA_ADVERTISED_LISTENERS with a trailing comma, and
57+
// apache/kafka:4.3.1 refuses to start with it ("values must not be empty"). The fix
58+
// (testcontainers-dotnet PR 1772) is not released yet, so this start command drops the
59+
// comma from the generated startup script before it starts the broker.
60+
private static readonly DotNet.Testcontainers.Configurations.OverwriteEnumerable<string> StartKafkaWithoutTrailingComma = new(
61+
[
62+
"while [ ! -f /testcontainers.sh ]; do sleep 0.1; done; " +
63+
"sed 's/,$//' /testcontainers.sh > /tmp/testcontainers.sh && exec bash /tmp/testcontainers.sh"
64+
]);
5365
}

0 commit comments

Comments
 (0)