Skip to content

Commit 7eec4ce

Browse files
authored
chore: Remove obsolete wait strategy: UntilPortIsAvailable(int) (#1528)
1 parent ce66114 commit 7eec4ce

File tree

14 files changed

+18
-38
lines changed

14 files changed

+18
-38
lines changed

docs/api/create_docker_container.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ Starting a container or creating a resource (such as a network or a volume) can
7676

7777
```csharp title="Canceling container start after one minute"
7878
using var timeoutCts = new CancellationTokenSource(TimeSpan.FromMinutes(1));
79-
await _container.StartAsync(timeoutCts.Token);
79+
await _container.StartAsync(timeoutCts.Token)
80+
.ConfigureAwait(false);
8081
```
8182

8283
## Getting log messages
@@ -86,7 +87,8 @@ Testcontainers for .NET provides two approaches for retrieving log messages from
8687
The `GetLogsAsync` method is available through the `IContainer` interface. It allows you to fetch logs from a container for a specific time range or from the beginning until the present. This approach is useful for retrieving logs after a test has run, especially when troubleshooting issues or failures.
8788

8889
```csharp title="Getting all log messages"
89-
var (stdout, stderr) = await _container.GetLogsAsync();
90+
var (stdout, stderr) = await _container.GetLogsAsync()
91+
.ConfigureAwait(false);
9092
```
9193

9294
The `WithOutputConsumer` method is part of the `ContainerBuilder` class and is used to continuously forward container log messages to a specified output consumer. This approach provides real-time access to logs as the container runs.

examples/Flyway/Directory.Packages.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<ItemGroup>
77
<!-- Unit and integration test dependencies: -->
88
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.11.1"/>
9-
<PackageVersion Include="Testcontainers.PostgreSql" Version="4.2.0"/>
9+
<PackageVersion Include="Testcontainers.PostgreSql" Version="4.7.0"/>
1010
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.2"/>
1111
<PackageVersion Include="xunit" Version="2.9.2"/>
1212
<!-- Third-party client dependencies to connect and interact with the containers: -->

examples/Respawn/Directory.Packages.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<ItemGroup>
77
<!-- Unit and integration test dependencies: -->
88
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.11.1"/>
9-
<PackageVersion Include="Testcontainers.PostgreSql" Version="4.2.0"/>
9+
<PackageVersion Include="Testcontainers.PostgreSql" Version="4.7.0"/>
1010
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.2"/>
1111
<PackageVersion Include="xunit" Version="2.9.2"/>
1212
<!-- Third-party client dependencies to connect and interact with the containers: -->

examples/WeatherForecast/Directory.Packages.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<!-- Unit and integration test dependencies: -->
1111
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.11.1"/>
1212
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="8.0.13"/>
13-
<PackageVersion Include="Testcontainers.PostgreSql" Version="4.2.0"/>
13+
<PackageVersion Include="Testcontainers.PostgreSql" Version="4.7.0"/>
1414
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.2"/>
1515
<PackageVersion Include="xunit" Version="2.9.2"/>
1616
<!-- Third-party client dependencies to connect and interact with the containers: -->

examples/WeatherForecast/tests/WeatherForecast.Tests/WeatherForecastContainer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public WeatherForecastContainer()
4040
.WithEnvironment("ASPNETCORE_Kestrel__Certificates__Default__Path", WeatherForecastImage.CertificateFilePath)
4141
.WithEnvironment("ASPNETCORE_Kestrel__Certificates__Default__Password", WeatherForecastImage.CertificatePassword)
4242
.WithEnvironment("ConnectionStrings__PostgreSQL", postgreSqlConnectionString)
43-
.WithWaitStrategy(Wait.ForUnixContainer().UntilPortIsAvailable(WeatherForecastImage.HttpsPort))
43+
.WithWaitStrategy(Wait.ForUnixContainer().UntilInternalTcpPortIsAvailable(WeatherForecastImage.HttpsPort))
4444
.Build();
4545
}
4646

src/Testcontainers.Weaviate/WeaviateBuilder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ protected override WeaviateBuilder Init()
4242
.WithEnvironment("AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED", "true")
4343
.WithEnvironment("PERSISTENCE_DATA_PATH", "/var/lib/weaviate")
4444
.WithWaitStrategy(Wait.ForUnixContainer()
45-
.UntilPortIsAvailable(WeaviateHttpPort)
46-
.UntilPortIsAvailable(WeaviateGrpcPort)
45+
.UntilInternalTcpPortIsAvailable(WeaviateHttpPort)
46+
.UntilInternalTcpPortIsAvailable(WeaviateGrpcPort)
4747
.UntilHttpRequestIsSucceeded(request =>
4848
request.ForPath("/v1/.well-known/ready").ForPort(WeaviateHttpPort)));
4949

src/Testcontainers/Configurations/WaitStrategies/IWaitForContainerOS.cs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,6 @@ public interface IWaitForContainerOS
5858
[PublicAPI]
5959
IWaitForContainerOS UntilCommandIsCompleted(IEnumerable<string> command, Action<IWaitStrategy> waitStrategyModifier = null);
6060

61-
/// <summary>
62-
/// Waits until the port is available.
63-
/// </summary>
64-
/// <param name="port">The port to be checked.</param>
65-
/// <param name="waitStrategyModifier">The wait strategy modifier to cancel the readiness check.</param>
66-
/// <returns>A configured instance of <see cref="IWaitForContainerOS" />.</returns>
67-
[PublicAPI]
68-
[Obsolete("Use UntilInternalTcpPortIsAvailable or UntilExternalTcpPortIsAvailable instead. This method corresponds to the internal variant.")]
69-
IWaitForContainerOS UntilPortIsAvailable(int port, Action<IWaitStrategy> waitStrategyModifier = null);
70-
7161
/// <summary>
7262
/// Waits until a TCP port is available from within the container itself.
7363
/// This verifies that a service inside the container is listening on the specified port.

src/Testcontainers/Configurations/WaitStrategies/WaitForContainerOS.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@ protected WaitForContainerOS()
2727
/// <inheritdoc />
2828
public abstract IWaitForContainerOS UntilCommandIsCompleted(IEnumerable<string> command, Action<IWaitStrategy> waitStrategyModifier = null);
2929

30-
/// <inheritdoc />
31-
public abstract IWaitForContainerOS UntilPortIsAvailable(int port, Action<IWaitStrategy> waitStrategyModifier = null);
32-
3330
/// <inheritdoc />
3431
public abstract IWaitForContainerOS UntilInternalTcpPortIsAvailable(int containerPort, Action<IWaitStrategy> waitStrategyModifier = null);
3532

src/Testcontainers/Configurations/WaitStrategies/WaitForContainerUnix.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,6 @@ public override IWaitForContainerOS UntilCommandIsCompleted(IEnumerable<string>
2525
return AddCustomWaitStrategy(new UntilUnixCommandIsCompleted(command.ToArray()), waitStrategyModifier);
2626
}
2727

28-
/// <inheritdoc />
29-
public override IWaitForContainerOS UntilPortIsAvailable(int port, Action<IWaitStrategy> waitStrategyModifier = null)
30-
{
31-
return UntilInternalTcpPortIsAvailable(port, waitStrategyModifier);
32-
}
33-
3428
/// <inheritdoc />
3529
public override IWaitForContainerOS UntilInternalTcpPortIsAvailable(int containerPort, Action<IWaitStrategy> waitStrategyModifier = null)
3630
{

src/Testcontainers/Configurations/WaitStrategies/WaitForContainerWindows.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,6 @@ public override IWaitForContainerOS UntilCommandIsCompleted(IEnumerable<string>
2525
return AddCustomWaitStrategy(new UntilWindowsCommandIsCompleted(command.ToArray()), waitStrategyModifier);
2626
}
2727

28-
/// <inheritdoc />
29-
public override IWaitForContainerOS UntilPortIsAvailable(int port, Action<IWaitStrategy> waitStrategyModifier = null)
30-
{
31-
return UntilInternalTcpPortIsAvailable(port, waitStrategyModifier);
32-
}
33-
3428
/// <inheritdoc />
3529
public override IWaitForContainerOS UntilInternalTcpPortIsAvailable(int containerPort, Action<IWaitStrategy> waitStrategyModifier = null)
3630
{

0 commit comments

Comments
 (0)