Skip to content

Commit

Permalink
Added retry in creating test TestWebApplicationFactory case Marten wa…
Browse files Browse the repository at this point in the history
…sn't able to attain global lock (or other transient error)
  • Loading branch information
oskardudycz committed May 23, 2024
1 parent fe66531 commit 023955b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Core.Testing/TestWebApplicationFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Open.ChannelExtensions;
using Polly;

namespace Core.Testing;

Expand Down Expand Up @@ -38,7 +39,9 @@ protected override IHost CreateHost(IHostBuilder builder)

Environment.SetEnvironmentVariable("SchemaName", schemaName);

return base.CreateHost(builder);
return Policy.Handle<Exception>()
.WaitAndRetry(5, _=>TimeSpan.FromMilliseconds(500))
.Execute(() =>base.CreateHost(builder));
}

public void PublishedExternalEventsOfType<TEvent>() where TEvent : IExternalEvent =>
Expand Down
1 change: 1 addition & 0 deletions Sample/ECommerce/Carts/Carts/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public static class Config
services
.AddMarten(config, options =>
{
options.Projections.DaemonLockId = 222222;
options.ConfigureCarts();
//options.DisableNpgsqlLogging = true;
}).UseNpgsqlDataSource()
Expand Down

0 comments on commit 023955b

Please sign in to comment.