Skip to content

Commit 994038c

Browse files
authored
fix(EventHubs): Workaround health API timeout (#1624)
1 parent f776ff9 commit 994038c

2 files changed

Lines changed: 20 additions & 2 deletions

File tree

src/Testcontainers.EventHubs/EventHubsBuilder.cs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,10 @@ protected override EventHubsBuilder Init()
168168
return base.Init()
169169
.WithPortBinding(EventHubsPort, true)
170170
.WithPortBinding(EventHubsHttpPort, true)
171-
.WithWaitStrategy(Wait.ForUnixContainer().UntilHttpRequestIsSucceeded(request =>
172-
request.ForPort(EventHubsHttpPort).ForPath("/health")));
171+
.WithWaitStrategy(Wait.ForUnixContainer()
172+
.AddCustomWaitStrategy(new WorkaroundGhIssue69())
173+
.UntilHttpRequestIsSucceeded(request =>
174+
request.ForPort(EventHubsHttpPort).ForPath("/health")));
173175
}
174176

175177
/// <inheritdoc />
@@ -189,4 +191,19 @@ protected override EventHubsBuilder Merge(EventHubsConfiguration oldValue, Event
189191
{
190192
return new EventHubsBuilder(new EventHubsConfiguration(oldValue, newValue));
191193
}
194+
195+
/// <summary>
196+
/// See GH issue: https://github.com/Azure/azure-event-hubs-emulator-installer/issues/69#issuecomment-3762895979.
197+
/// </summary>
198+
private sealed class WorkaroundGhIssue69 : IWaitUntil
199+
{
200+
/// <inheritdoc />
201+
public async Task<bool> UntilAsync(IContainer container)
202+
{
203+
await Task.Delay(TimeSpan.FromSeconds(5))
204+
.ConfigureAwait(false);
205+
206+
return true;
207+
}
208+
}
192209
}

src/Testcontainers.EventHubs/Usings.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
global using System.Linq;
66
global using System.Text;
77
global using System.Text.Json;
8+
global using System.Threading.Tasks;
89
global using Docker.DotNet.Models;
910
global using DotNet.Testcontainers;
1011
global using DotNet.Testcontainers.Builders;

0 commit comments

Comments
 (0)