Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ updates:
- "Shouldly"
- "Microsoft.NET.Test.Sdk"
- "Brutal.Dev.StrongNameSigner"
- "Testcontainers*"
packaging-dependencies:
patterns:
- "SourceLink*"
Expand Down
58 changes: 58 additions & 0 deletions test/FluentMigrator.Tests/Containers/ContainerBase.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#region License
// Copyright (c) 2024, Fluent Migrator Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#endregion

using System.Threading;
using System.Threading.Tasks;

using DotNet.Testcontainers.Containers;

namespace FluentMigrator.Tests.Containers;

public abstract class ContainerBase
{
/// <summary>
/// Server options
/// </summary>
protected abstract IntegrationTestOptions.DatabaseServerOptions ServerOptions { get; }

/// <summary>
/// Default container database port
/// </summary>
protected abstract int Port { get; }

/// <summary>
/// Builds the test-container container
/// </summary>
protected abstract DockerContainer Build();

public async Task Start(CancellationToken cancellationToken = default)
{
if (!ServerOptions.IsEnabled || !ServerOptions.ContainerEnabled)
{
return;
}

// Build containers
var container = Build();

// Start it
await container.StartAsync(cancellationToken);

// Get the external port
var publicPort = container.GetMappedPublicPort(Port);
ServerOptions.ConnectionString = ServerOptions.ConnectionString.Replace(Port.ToString(), publicPort.ToString());
}
}
33 changes: 33 additions & 0 deletions test/FluentMigrator.Tests/Containers/Db2Container.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#region License
// Copyright (c) 2024, Fluent Migrator Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#endregion

using DotNet.Testcontainers.Containers;

using Testcontainers.Db2;

namespace FluentMigrator.Tests.Containers;

public class Db2Container : ContainerBase
{
/// <inheritdoc />
protected override IntegrationTestOptions.DatabaseServerOptions ServerOptions => IntegrationTestOptions.Db2;

/// <inheritdoc />
protected override int Port => 50000;

/// <inheritdoc />
protected override DockerContainer Build() => new Db2Builder().WithAcceptLicenseAgreement(true).WithReuse(true).Build();
}
33 changes: 33 additions & 0 deletions test/FluentMigrator.Tests/Containers/FirebirdContainer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#region License
// Copyright (c) 2024, Fluent Migrator Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#endregion

using DotNet.Testcontainers.Containers;

using Testcontainers.FirebirdSql;

namespace FluentMigrator.Tests.Containers;

public class FirebirdContainer : ContainerBase
{
/// <inheritdoc />
protected override IntegrationTestOptions.DatabaseServerOptions ServerOptions => IntegrationTestOptions.Firebird;

/// <inheritdoc />
protected override int Port => 3050;

/// <inheritdoc />
protected override DockerContainer Build() => new FirebirdSqlBuilder().WithReuse(true).Build();
Comment thread
jzabroski marked this conversation as resolved.
}
33 changes: 33 additions & 0 deletions test/FluentMigrator.Tests/Containers/MySqlContainer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#region License
// Copyright (c) 2024, Fluent Migrator Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#endregion

using DotNet.Testcontainers.Containers;

using Testcontainers.MySql;

namespace FluentMigrator.Tests.Containers;

public class MySqlContainer : ContainerBase
{
/// <inheritdoc />
protected override IntegrationTestOptions.DatabaseServerOptions ServerOptions => IntegrationTestOptions.MySql;

/// <inheritdoc />
protected override int Port => 3306;

/// <inheritdoc />
protected override DockerContainer Build() => new MySqlBuilder().WithReuse(true).Build();
}
33 changes: 33 additions & 0 deletions test/FluentMigrator.Tests/Containers/OracleContainer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#region License
// Copyright (c) 2024, Fluent Migrator Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#endregion

using DotNet.Testcontainers.Containers;

using Testcontainers.Oracle;

namespace FluentMigrator.Tests.Containers;

public class OracleContainer : ContainerBase
{
/// <inheritdoc />
protected override IntegrationTestOptions.DatabaseServerOptions ServerOptions => IntegrationTestOptions.Oracle;

/// <inheritdoc />
protected override int Port => 1521;

/// <inheritdoc />
protected override DockerContainer Build() => new OracleBuilder().WithReuse(true).Build();
}
33 changes: 33 additions & 0 deletions test/FluentMigrator.Tests/Containers/PostgresContainer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#region License
// Copyright (c) 2024, Fluent Migrator Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#endregion

using DotNet.Testcontainers.Containers;

using Testcontainers.PostgreSql;

namespace FluentMigrator.Tests.Containers;

public class PostgresContainer : ContainerBase
{
/// <inheritdoc />
protected override IntegrationTestOptions.DatabaseServerOptions ServerOptions => IntegrationTestOptions.Postgres;

/// <inheritdoc />
protected override int Port => 5432;

/// <inheritdoc />
protected override DockerContainer Build() => new PostgreSqlBuilder().WithReuse(true).Build();
}
33 changes: 33 additions & 0 deletions test/FluentMigrator.Tests/Containers/SqlServerContainer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#region License
// Copyright (c) 2024, Fluent Migrator Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#endregion

using DotNet.Testcontainers.Containers;

using Testcontainers.MsSql;

namespace FluentMigrator.Tests.Containers;

public class SqlServerContainer : ContainerBase
{
/// <inheritdoc />
protected override IntegrationTestOptions.DatabaseServerOptions ServerOptions => IntegrationTestOptions.SqlServer2016;

/// <inheritdoc />
protected override int Port => 1433;

/// <inheritdoc />
protected override DockerContainer Build() => new MsSqlBuilder().WithReuse(true).Build();
}
10 changes: 9 additions & 1 deletion test/FluentMigrator.Tests/FluentMigrator.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<PackageReference Include="FirebirdSql.Data.FirebirdClient" Version="10.3.2" />
<PackageReference Include="Microsoft.Data.Sqlite" Version="9.0.2" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="9.0.2" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="9.0.2" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="9.0.2" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="9.0.2" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="9.0.2" />
Expand All @@ -34,6 +35,13 @@
<PackageReference Include="Shouldly" Version="4.3.0" />
<PackageReference Include="Snowflake.Data" Version="4.3.0" />
<PackageReference Include="SQLitePCLRaw.bundle_e_sqlite3" Version="2.1.10" />
<PackageReference Include="Testcontainers" Version="4.3.0" />
<PackageReference Include="Testcontainers.FirebirdSql" Version="4.3.0" />
<PackageReference Include="Testcontainers.MsSql" Version="4.3.0" />
<PackageReference Include="Testcontainers.MySql" Version="4.3.0" />
<PackageReference Include="Testcontainers.Oracle" Version="4.3.0" />
<PackageReference Include="Testcontainers.PostgreSql" Version="4.3.0" />
<PackageReference Include="Testcontainers.Db2" Version="4.3.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\FluentMigrator.Console\FluentMigrator.Console.csproj" />
Expand Down Expand Up @@ -87,4 +95,4 @@
<ItemGroup>
<PackageReference Update="JetBrains.Annotations" Version="2024.3.0" />
</ItemGroup>
</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ private void ExecuteWithProcessor(
if (processorType == typeof(FirebirdProcessor) && _isFirstExecuteForFirebird)
{
_isFirstExecuteForFirebird = false;
FbConnection.CreateDatabase(serverOptions.ConnectionString, overwrite: true);
FbConnection.CreateDatabase(serverOptions.ConnectionString, pageSize:16384, overwrite: true);
}

using (serviceProvider)
Expand Down
43 changes: 43 additions & 0 deletions test/FluentMigrator.Tests/Integration/IntegrationTestsSetup.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#region License
//
// Copyright (c) 2007-2024, Fluent Migrator Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#endregion

using System.Threading.Tasks;

using FluentMigrator.Tests.Containers;

using NUnit.Framework;

namespace FluentMigrator.Tests.Integration
{
[SetUpFixture]
public class IntegrationTestsSetup
{
[OneTimeSetUp]
public async Task Setup()
{
await Task.WhenAll([
Comment thread
jzabroski marked this conversation as resolved.
new MySqlContainer().Start(),
Comment thread
jzabroski marked this conversation as resolved.
new OracleContainer().Start(),
new SqlServerContainer().Start(),
new PostgresContainer().Start(),
new FirebirdContainer().Start(),
new Db2Container().Start(),
]);
}
}
}
Loading