Skip to content

Commit 2d8afc3

Browse files
feat: Replace wait strategy with HTTP health check
1 parent 76ce3e0 commit 2d8afc3

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

src/Testcontainers.EventHubs/EventHubsBuilder.cs

+5-3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ public sealed class EventHubsBuilder : ContainerBuilder<EventHubsBuilder, EventH
1212

1313
public const ushort EventHubsPort = 5672;
1414

15+
public const ushort EventHubsHttpPort = 5300;
16+
1517
/// <summary>
1618
/// Initializes a new instance of the <see cref="EventHubsBuilder" /> class.
1719
/// </summary>
@@ -135,9 +137,9 @@ protected override EventHubsBuilder Init()
135137
return base.Init()
136138
.WithImage(EventHubsImage)
137139
.WithPortBinding(EventHubsPort, true)
138-
.WithWaitStrategy(Wait.ForUnixContainer()
139-
.UntilMessageIsLogged("Emulator Service is Successfully Up!")
140-
.AddCustomWaitStrategy(new WaitTwoSeconds()));
140+
.WithPortBinding(EventHubsHttpPort, true)
141+
.WithWaitStrategy(Wait.ForUnixContainer().UntilHttpRequestIsSucceeded(request =>
142+
request.ForPath("/health").ForPort(EventHubsHttpPort)));
141143
}
142144

143145
/// <inheritdoc />

src/Testcontainers.ServiceBus/ServiceBusBuilder.cs

+6-3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ public sealed class ServiceBusBuilder : ContainerBuilder<ServiceBusBuilder, Serv
1212

1313
public const ushort ServiceBusPort = 5672;
1414

15+
public const ushort ServiceBusHttpPort = 5300;
16+
1517
/// <summary>
1618
/// Initializes a new instance of the <see cref="ServiceBusBuilder" /> class.
1719
/// </summary>
@@ -115,9 +117,10 @@ protected override ServiceBusBuilder Init()
115117
return base.Init()
116118
.WithImage(ServiceBusImage)
117119
.WithPortBinding(ServiceBusPort, true)
118-
.WithWaitStrategy(Wait.ForUnixContainer()
119-
.UntilMessageIsLogged("Emulator Service is Successfully Up!")
120-
.AddCustomWaitStrategy(new WaitTwoSeconds()));
120+
.WithPortBinding(ServiceBusHttpPort, true)
121+
.WithEnvironment("SQL_WAIT_INTERVAL", "0")
122+
.WithWaitStrategy(Wait.ForUnixContainer().UntilHttpRequestIsSucceeded(request =>
123+
request.ForPath("/health").ForPort(ServiceBusHttpPort)));
121124
}
122125

123126
/// <inheritdoc />

0 commit comments

Comments
 (0)