Skip to content

Commit

Permalink
Bump Testcontainers to 2.4.0 (#2144)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kielek authored Feb 2, 2023
1 parent f857312 commit fe24131
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 36 deletions.
2 changes: 1 addition & 1 deletion test/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<PackageVersion Include="System.ServiceModel.Http" Version="4.10.0" />
<PackageVersion Include="System.ServiceModel.NetTcp" Version="4.10.0" />
<PackageVersion Include="System.ValueTuple" Version="4.5.0" />
<PackageVersion Include="Testcontainers" Version="2.3.0" />
<PackageVersion Include="Testcontainers" Version="2.4.0" />
<PackageVersion Include="Verify.Xunit" Version="19.8.1" />
<PackageVersion Include="xunit" Version="2.4.2" />
<PackageVersion Include="xunit.abstractions" Version="2.0.3" />
Expand Down
4 changes: 2 additions & 2 deletions test/IntegrationTests/AspNetTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public async Task SubmitMetrics()
collector.AssertExpectations();
}

private async Task<TestcontainersContainer> StartContainerAsync(int webPort)
private async Task<IContainer> StartContainerAsync(int webPort)
{
// get path to test application that the profiler will attach to
string imageName = $"testapplication-aspnet-netframework";
Expand All @@ -131,7 +131,7 @@ private async Task<TestcontainersContainer> StartContainerAsync(int webPort)
Directory.CreateDirectory(logPath);
Output.WriteLine("Collecting docker logs to: " + logPath);

var builder = new TestcontainersBuilder<TestcontainersContainer>()
var builder = new ContainerBuilder()
.WithImage(imageName)
.WithCleanUp(cleanUp: true)
.WithOutputConsumer(Consume.RedirectStdoutAndStderrToConsole())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

using DotNet.Testcontainers.Configurations;
using DotNet.Testcontainers.Containers;
using Microsoft.Extensions.Logging;

namespace IntegrationTests.Helpers.TestContainers;

Expand All @@ -32,7 +31,7 @@ public UntilAsyncOperationIsSucceeded(Func<Task<bool>> operation, int maxCallCou
_maxCallCount = maxCallCount;
}

public async Task<bool> Until(ITestcontainersContainer testcontainers, ILogger logger)
public async Task<bool> UntilAsync(IContainer container)
{
if (++_tryCount > _maxCallCount)
{
Expand Down
9 changes: 4 additions & 5 deletions test/IntegrationTests/MongoDBCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class MongoDBFixture : IAsyncLifetime
private const int MongoDBPort = 27017;
private const string MongoDBImage = "mongo:5.0.6";

private TestcontainersContainer? _container;
private IContainer? _container;

public MongoDBFixture()
{
Expand All @@ -56,9 +56,9 @@ public async Task DisposeAsync()
}
}

private async Task<TestcontainersContainer> LaunchMongoContainerAsync(int port)
private async Task<IContainer> LaunchMongoContainerAsync(int port)
{
var mongoContainersBuilder = new TestcontainersBuilder<TestcontainersContainer>()
var mongoContainersBuilder = new ContainerBuilder()
.WithImage(MongoDBImage)
.WithName($"mongo-db-{port}")
.WithPortBinding(port, MongoDBPort)
Expand All @@ -70,9 +70,8 @@ private async Task<TestcontainersContainer> LaunchMongoContainerAsync(int port)
return container;
}

private async Task ShutdownMongoContainerAsync(TestcontainersContainer container)
private async Task ShutdownMongoContainerAsync(IContainer container)
{
await container.CleanUpAsync();
await container.DisposeAsync();
}
}
Expand Down
11 changes: 4 additions & 7 deletions test/IntegrationTests/MySqlCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@
// </copyright>

#if NET6_0_OR_GREATER
using System.Threading.Tasks;
using DotNet.Testcontainers.Builders;
using DotNet.Testcontainers.Containers;
using IntegrationTests.Helpers;
using Xunit;

namespace IntegrationTests;

Expand All @@ -34,7 +32,7 @@ public class MySqlFixture : IAsyncLifetime
private const int MySqlPort = 3306;
private const string MySqlImage = "mysql:8.0.29";

private TestcontainersContainer? _container;
private IContainer? _container;

public MySqlFixture()
{
Expand All @@ -56,9 +54,9 @@ public async Task DisposeAsync()
}
}

private async Task<TestcontainersContainer> LaunchMySqlContainerAsync(int port)
private async Task<IContainer> LaunchMySqlContainerAsync(int port)
{
var containersBuilder = new TestcontainersBuilder<TestcontainersContainer>()
var containersBuilder = new ContainerBuilder()
.WithImage(MySqlImage)
.WithName($"mysql-{port}")
.WithPortBinding(port, MySqlPort)
Expand All @@ -71,9 +69,8 @@ private async Task<TestcontainersContainer> LaunchMySqlContainerAsync(int port)
return container;
}

private async Task ShutdownMySqlContainerAsync(TestcontainersContainer container)
private async Task ShutdownMySqlContainerAsync(IContainer container)
{
await container.CleanUpAsync();
await container.DisposeAsync();
}
}
Expand Down
11 changes: 4 additions & 7 deletions test/IntegrationTests/PostgresCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@
// limitations under the License.
// </copyright>

using System.Threading.Tasks;
using DotNet.Testcontainers.Builders;
using DotNet.Testcontainers.Containers;
using IntegrationTests.Helpers;
using Xunit;

namespace IntegrationTests;

Expand All @@ -33,7 +31,7 @@ public class PostgresFixture : IAsyncLifetime
private const int PostgresPort = 5432;
private const string PostgresImage = "postgres:14.4";

private TestcontainersContainer? _container;
private IContainer? _container;

public PostgresFixture()
{
Expand All @@ -55,9 +53,9 @@ public async Task DisposeAsync()
}
}

private async Task<TestcontainersContainer> LaunchPostgresContainerAsync(int port)
private async Task<IContainer> LaunchPostgresContainerAsync(int port)
{
var containersBuilder = new TestcontainersBuilder<TestcontainersContainer>()
var containersBuilder = new ContainerBuilder()
.WithImage(PostgresImage)
.WithName($"postgres-{port}")
.WithPortBinding(port, PostgresPort)
Expand All @@ -70,9 +68,8 @@ private async Task<TestcontainersContainer> LaunchPostgresContainerAsync(int por
return container;
}

private async Task ShutdownPostgresContainerAsync(TestcontainersContainer container)
private async Task ShutdownPostgresContainerAsync(IContainer container)
{
await container.CleanUpAsync();
await container.DisposeAsync();
}
}
11 changes: 4 additions & 7 deletions test/IntegrationTests/RedisCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@

#if NET6_0_OR_GREATER

using System.Threading.Tasks;
using DotNet.Testcontainers.Builders;
using DotNet.Testcontainers.Containers;
using IntegrationTests.Helpers;
using Xunit;

namespace IntegrationTests;

Expand All @@ -35,7 +33,7 @@ public class RedisFixture : IAsyncLifetime
private const int RedisPort = 6379;
private const string RedisImage = "redis:7.0.4";

private TestcontainersContainer? _container;
private IContainer? _container;

public RedisFixture()
{
Expand All @@ -57,9 +55,9 @@ public async Task DisposeAsync()
}
}

private async Task<TestcontainersContainer> LaunchRedisContainerAsync(int port)
private async Task<IContainer> LaunchRedisContainerAsync(int port)
{
var containersBuilder = new TestcontainersBuilder<TestcontainersContainer>()
var containersBuilder = new ContainerBuilder()
.WithImage(RedisImage)
.WithName($"redis-{port}")
.WithPortBinding(port, RedisPort)
Expand All @@ -71,9 +69,8 @@ private async Task<TestcontainersContainer> LaunchRedisContainerAsync(int port)
return container;
}

private async Task ShutdownRedisContainerAsync(TestcontainersContainer container)
private async Task ShutdownRedisContainerAsync(IContainer container)
{
await container.CleanUpAsync();
await container.DisposeAsync();
}
}
Expand Down
9 changes: 4 additions & 5 deletions test/IntegrationTests/SqlServerCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class SqlServerFixture : IAsyncLifetime
private const int DatabasePort = 1433;
private const string DatabaseImage = "mcr.microsoft.com/mssql/server:2019-CU17-ubuntu-20.04";

private TestcontainersContainer? _container;
private IContainer? _container;

public SqlServerFixture()
{
Expand All @@ -57,15 +57,14 @@ public async Task DisposeAsync()
}
}

private static async Task ShutdownSqlServerContainerAsync(TestcontainersContainer container)
private static async Task ShutdownSqlServerContainerAsync(IContainer container)
{
await container.CleanUpAsync();
await container.DisposeAsync();
}

private async Task<TestcontainersContainer> LaunchSqlServerContainerAsync()
private async Task<IContainer> LaunchSqlServerContainerAsync()
{
var databaseContainersBuilder = new TestcontainersBuilder<TestcontainersContainer>()
var databaseContainersBuilder = new ContainerBuilder()
.WithImage(DatabaseImage)
.WithName($"sql-server-{Port}")
.WithPortBinding(Port, DatabasePort)
Expand Down

0 comments on commit fe24131

Please sign in to comment.