Skip to content

Commit

Permalink
Add EnableThreadSafetyChecks support and Enable it for all test (#15961)
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeAlhayek committed May 3, 2024
1 parent 4bd2294 commit dc0d4fc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
Expand Up @@ -15,4 +15,6 @@ public class YesSqlOptions
public IAccessorFactory VersionAccessorFactory { get; set; }

public IContentSerializer ContentSerializer { get; set; }

public bool EnableThreadSafetyChecks { get; set; }
}
Expand Up @@ -186,10 +186,11 @@ private static YesSql.Configuration GetStoreConfiguration(IServiceProvider sp, Y
{
CommandsPageSize = yesSqlOptions.CommandsPageSize,
QueryGatingEnabled = yesSqlOptions.QueryGatingEnabled,
EnableThreadSafetyChecks = yesSqlOptions.EnableThreadSafetyChecks,
TableNameConvention = tableNameFactory.Create(databaseTableOptions),
IdentityColumnSize = Enum.Parse<IdentityColumnSize>(databaseTableOptions.IdentityColumnSize),
Logger = loggerFactory.CreateLogger("YesSql"),
ContentSerializer = new DefaultContentJsonSerializer(serializerOptions.Value.SerializerOptions)
ContentSerializer = new DefaultContentJsonSerializer(serializerOptions.Value.SerializerOptions),
};

if (yesSqlOptions.IdGenerator != null)
Expand Down
7 changes: 7 additions & 0 deletions test/OrchardCore.Tests/Apis/Context/SiteStartup.cs
@@ -1,3 +1,4 @@
using OrchardCore.Data.YesSql;
using OrchardCore.Modules;
using OrchardCore.Modules.Manifest;
using OrchardCore.Recipes.Services;
Expand Down Expand Up @@ -26,6 +27,12 @@ public void ConfigureServices(IServiceCollection services)
)
.ConfigureServices(collection =>
{
collection.Configure<YesSqlOptions>(options =>
{
// To ensure we don't encounter any concurrent issue, enable EnableThreadSafetyChecks for all test.
options.EnableThreadSafetyChecks = true;
});
collection.AddScoped<IRecipeHarvester, TestRecipeHarvester>();
collection.AddScoped<IAuthorizationHandler, PermissionContextAuthorizationHandler>(sp =>
Expand Down

0 comments on commit dc0d4fc

Please sign in to comment.