Skip to content
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

[WCF] add wait strategy to reduce random test failures #2915

Merged
merged 2 commits into from
Sep 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions test/IntegrationTests/WcfIISTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ private async Task<IContainer> StartContainerAsync(int netTcpPort, int httpPort)
.WithNetwork(networkName)
.WithPortBinding(netTcpPort, 808)
.WithPortBinding(httpPort, 80)
.WithWaitStrategy(Wait.ForWindowsContainer().UntilHttpRequestIsSucceeded(rq
=> rq.ForPort(80).ForPath("/StatusService.svc")))
.WithBindMount(logPath, "c:/inetpub/wwwroot/logs");

foreach (var env in _environmentVariables)
Expand All @@ -103,14 +105,15 @@ private async Task<IContainer> StartContainerAsync(int netTcpPort, int httpPort)
}

var container = builder.Build();
var cts = new CancellationTokenSource(TimeSpan.FromMinutes(5));
try
{
var wasStarted = container.StartAsync().Wait(TimeSpan.FromMinutes(5));
wasStarted.Should().BeTrue($"Container based on {imageName} has to be operational for the test.");
await container.StartAsync(cts.Token);
Output.WriteLine("Container was started successfully.");
}
catch
{
Output.WriteLine("Container failed to start in a required time frame.");
await container.DisposeAsync();
throw;
}
Expand Down
Loading