From 1107b48200ce8ff9ee9ec53c12fdada914d5ffe3 Mon Sep 17 00:00:00 2001 From: Sipke Schoorstra Date: Thu, 11 Dec 2025 09:45:37 +0100 Subject: [PATCH] Switch component tests from PostgreSQL to SQL Server and update related configurations. --- Directory.Packages.props | 1 + test/component/Directory.Build.props | 17 +++++------ .../Elsa.Workflows.ComponentTests.csproj | 1 + .../Helpers/Fixtures/Infrastructure.cs | 28 +++++++++++-------- .../Helpers/Fixtures/WorkflowServer.cs | 26 +++++++++++++---- 5 files changed, 49 insertions(+), 24 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 4a0ce735c..ce19a6446 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -165,6 +165,7 @@ + diff --git a/test/component/Directory.Build.props b/test/component/Directory.Build.props index e6ff014e4..fb63b368e 100644 --- a/test/component/Directory.Build.props +++ b/test/component/Directory.Build.props @@ -1,14 +1,15 @@ - + - - 40 - + + 40 + - - - - + + + + + \ No newline at end of file diff --git a/test/component/Elsa.Workflows.ComponentTests/Elsa.Workflows.ComponentTests.csproj b/test/component/Elsa.Workflows.ComponentTests/Elsa.Workflows.ComponentTests.csproj index 7d4751127..dbfd8dcec 100644 --- a/test/component/Elsa.Workflows.ComponentTests/Elsa.Workflows.ComponentTests.csproj +++ b/test/component/Elsa.Workflows.ComponentTests/Elsa.Workflows.ComponentTests.csproj @@ -22,6 +22,7 @@ + diff --git a/test/component/Elsa.Workflows.ComponentTests/Helpers/Fixtures/Infrastructure.cs b/test/component/Elsa.Workflows.ComponentTests/Helpers/Fixtures/Infrastructure.cs index 49f1e1382..45e547ac8 100644 --- a/test/component/Elsa.Workflows.ComponentTests/Helpers/Fixtures/Infrastructure.cs +++ b/test/component/Elsa.Workflows.ComponentTests/Helpers/Fixtures/Infrastructure.cs @@ -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() diff --git a/test/component/Elsa.Workflows.ComponentTests/Helpers/Fixtures/WorkflowServer.cs b/test/component/Elsa.Workflows.ComponentTests/Helpers/Fixtures/WorkflowServer.cs index 3c590c0e0..1a10ecba1 100644 --- a/test/component/Elsa.Workflows.ComponentTests/Helpers/Fixtures/WorkflowServer.cs +++ b/test/component/Elsa.Workflows.ComponentTests/Helpers/Fixtures/WorkflowServer.cs @@ -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 => {