Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add EnableThreadSafetyChecks support and Enable it for all test #15961

Merged
merged 1 commit into from
May 3, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@ public class YesSqlOptions
public IAccessorFactory VersionAccessorFactory { get; set; }

public IContentSerializer ContentSerializer { get; set; }

public bool EnableThreadSafetyChecks { get; set; }
}
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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