From da17e9ee7ea13b99142eb2e0c867e27492e9c2ef Mon Sep 17 00:00:00 2001 From: Roland Schmitt Date: Wed, 14 Aug 2024 18:08:44 +0200 Subject: [PATCH 1/2] Fixed usage of CreateIndexes for mongo to avoid database connection already opening during ioc --- .../Services/MongoPersistenceProvider.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/providers/WorkflowCore.Persistence.MongoDB/Services/MongoPersistenceProvider.cs b/src/providers/WorkflowCore.Persistence.MongoDB/Services/MongoPersistenceProvider.cs index fdab92cf6..d38ded2a5 100644 --- a/src/providers/WorkflowCore.Persistence.MongoDB/Services/MongoPersistenceProvider.cs +++ b/src/providers/WorkflowCore.Persistence.MongoDB/Services/MongoPersistenceProvider.cs @@ -23,7 +23,6 @@ public class MongoPersistenceProvider : IPersistenceProvider public MongoPersistenceProvider(IMongoDatabase database) { _database = database; - CreateIndexes(this); } static MongoPersistenceProvider() @@ -263,7 +262,7 @@ public async Task ClearSubscriptionToken(string eventSubscriptionId, string toke public void EnsureStoreExists() { - + CreateIndexes(this); } public async Task> GetSubscriptions(string eventName, string eventKey, DateTime asOf, CancellationToken cancellationToken = default) From 0b51d8ef84375354864da4d18a5b8c62ce2b7272 Mon Sep 17 00:00:00 2001 From: Roland Schmitt Date: Wed, 14 Aug 2024 18:35:44 +0200 Subject: [PATCH 2/2] Fixed mongo tests to call EnsureStoreExists --- .../MongoPersistenceProviderFixture.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/WorkflowCore.Tests.MongoDB/MongoPersistenceProviderFixture.cs b/test/WorkflowCore.Tests.MongoDB/MongoPersistenceProviderFixture.cs index c61b4b5e2..fd6546aca 100644 --- a/test/WorkflowCore.Tests.MongoDB/MongoPersistenceProviderFixture.cs +++ b/test/WorkflowCore.Tests.MongoDB/MongoPersistenceProviderFixture.cs @@ -1,5 +1,4 @@ using MongoDB.Driver; -using System; using WorkflowCore.Interface; using WorkflowCore.Persistence.MongoDB.Services; using WorkflowCore.UnitTests; @@ -23,7 +22,9 @@ protected override IPersistenceProvider Subject { var client = new MongoClient(MongoDockerSetup.ConnectionString); var db = client.GetDatabase(nameof(MongoPersistenceProviderFixture)); - return new MongoPersistenceProvider(db); + var provider = new MongoPersistenceProvider(db); + provider.EnsureStoreExists(); + return provider; } } }