Switch component tests from PostgreSQL to SQL Server and update related configurations.

This commit is contained in:
Sipke Schoorstra 2025-12-11 09:45:37 +01:00
parent 7add1030c4
commit 1107b48200
No known key found for this signature in database
GPG key ID: 5C10502B28A4268F
5 changed files with 49 additions and 24 deletions

View file

@ -165,6 +165,7 @@
<PackageVersion Include="System.Text.Json" Version="10.0.1"/>
<PackageVersion Include="System.Text.RegularExpressions" Version="4.3.1"/>
<PackageVersion Include="Testcontainers" Version="4.9.0"/>
<PackageVersion Include="Testcontainers.MsSql" Version="4.9.0"/>
<PackageVersion Include="Testcontainers.PostgreSql" Version="4.9.0"/>
<PackageVersion Include="Testcontainers.RabbitMq" Version="4.9.0"/>
<PackageVersion Include="Testcontainers.Redis" Version="4.9.0"/>

View file

@ -1,14 +1,15 @@
<Project>
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))"/>
<PropertyGroup>
<Threshold>40</Threshold>
</PropertyGroup>
<PropertyGroup>
<Threshold>40</Threshold>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Testcontainers.PostgreSql"/>
<PackageReference Include="Testcontainers.RabbitMq"/>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Testcontainers.PostgreSql"/>
<PackageReference Include="Testcontainers.RabbitMq"/>
<PackageReference Include="Testcontainers.MsSql"/>
</ItemGroup>
</Project>

View file

@ -22,6 +22,7 @@
<ProjectReference Include="..\..\..\src\clients\Elsa.Api.Client\Elsa.Api.Client.csproj" />
<ProjectReference Include="..\..\..\src\common\Elsa.Testing.Shared.Component\Elsa.Testing.Shared.Component.csproj" />
<ProjectReference Include="..\..\..\src\modules\Elsa.Persistence.EFCore.PostgreSql\Elsa.Persistence.EFCore.PostgreSql.csproj" />
<ProjectReference Include="..\..\..\src\modules\Elsa.Persistence.EFCore.SqlServer\Elsa.Persistence.EFCore.SqlServer.csproj" />
<ProjectReference Include="..\..\..\src\modules\Elsa.Scheduling\Elsa.Scheduling.csproj" />
<ProjectReference Include="..\..\..\src\modules\Elsa.WorkflowProviders.BlobStorage\Elsa.WorkflowProviders.BlobStorage.csproj" />
<ProjectReference Include="..\..\..\src\modules\Elsa.Workflows.Runtime.Distributed\Elsa.Workflows.Runtime.Distributed.csproj" />

View file

@ -1,3 +1,4 @@
using Testcontainers.MsSql;
using Testcontainers.PostgreSql;
using Testcontainers.RabbitMq;
@ -5,17 +6,22 @@ namespace Elsa.Workflows.ComponentTests.Fixtures;
public class Infrastructure : IAsyncLifetime
{
public readonly PostgreSqlContainer DbContainer = new PostgreSqlBuilder()
.WithImage("postgres:16-alpine")
.WithDatabase("elsa")
.WithUsername("postgres")
.WithPassword("postgres")
.WithCommand(
"-c", "max_connections=100",
"-c", "shared_buffers=128MB",
"-c", "work_mem=4MB",
"-c", "effective_cache_size=256MB"
)
// public readonly PostgreSqlContainer DbContainer = new PostgreSqlBuilder()
// .WithImage("postgres:16-alpine")
// .WithDatabase("elsa")
// .WithUsername("postgres")
// .WithPassword("postgres")
// .WithCommand(
// "-c", "max_connections=100",
// "-c", "shared_buffers=128MB",
// "-c", "work_mem=4MB",
// "-c", "effective_cache_size=256MB"
// )
// .Build();
public readonly MsSqlContainer DbContainer = new MsSqlBuilder()
.WithImage("mcr.microsoft.com/mssql/server:2022-latest")
.WithPassword("!Elsa2025@")
.Build();
public readonly RabbitMqContainer RabbitMqContainer = new RabbitMqBuilder()

View file

@ -55,7 +55,7 @@ public class WorkflowServer(Infrastructure infrastructure, string url) : WebAppl
protected override void ConfigureWebHost(IWebHostBuilder builder)
{
var dbConnectionString = infrastructure.DbContainer.GetConnectionString() + ";Minimum Pool Size=0;Maximum Pool Size=10";
var dbConnectionString = infrastructure.DbContainer.GetConnectionString();
var rabbitMqConnectionString = infrastructure.RabbitMqContainer.GetConnectionString();
builder.UseUrls(url);
@ -78,15 +78,27 @@ public class WorkflowServer(Infrastructure infrastructure, string url) : WebAppl
var workflowsDirectory = Path.Join(workflowsDirectorySegments);
return StorageFactory.Blobs.DirectoryFiles(workflowsDirectory);
});
elsa.UseIdentity(identity => identity.UseEntityFrameworkCore(ef => ef.UsePostgreSql(dbConnectionString)));
elsa.UseIdentity(identity => identity.UseEntityFrameworkCore(ef =>
{
//ef.UsePostgreSql(dbConnectionString);
ef.UseSqlServer(dbConnectionString);
}));
elsa.UseWorkflowManagement(management =>
{
management.UseEntityFrameworkCore(ef => ef.UsePostgreSql(dbConnectionString));
management.UseEntityFrameworkCore(ef =>
{
//ef.UsePostgreSql(dbConnectionString);
ef.UseSqlServer(dbConnectionString);
});
management.UseCache();
});
elsa.UseWorkflowRuntime(runtime =>
{
runtime.UseEntityFrameworkCore(ef => ef.UsePostgreSql(dbConnectionString));
runtime.UseEntityFrameworkCore(ef =>
{
//ef.UsePostgreSql(dbConnectionString);
ef.UseSqlServer(dbConnectionString);
});
runtime.UseCache();
runtime.UseDistributedRuntime();
});
@ -100,7 +112,11 @@ public class WorkflowServer(Infrastructure infrastructure, string url) : WebAppl
});
elsa.UseAlterations(alterations =>
{
alterations.UseEntityFrameworkCore(ef => ef.UsePostgreSql(dbConnectionString));
alterations.UseEntityFrameworkCore(ef =>
{
//ef.UsePostgreSql(dbConnectionString);
ef.UseSqlServer(dbConnectionString);
});
});
elsa.UseHttp(http =>
{