Heimdall Gitea / Detect CI scope (push) Successful in 4s
Heimdall Gitea / Build and tests (push) Failing after 4m42s
Heimdall Gitea / Build and scan server image (push) Skipped
Heimdall Gitea / Build and scan agent image (push) Skipped
Heimdall Gitea / Build and scan NVIDIA Agent image (push) Skipped
Heimdall Gitea / Publish Docker Hub latest tags (push) Skipped
Heimdall Gitea / Publish versioned release (push) Skipped
Heimdall Gitea / CI policy (push) Failing after 1s
Refs #214 ## Résumé - Réessaie l’enregistrement complet et idempotent des jobs Hangfire après une `PostgreSqlDistributedLockException`, avec nouveau scope par tentative, délais bornés et annulation à l’arrêt. - Ajoute un test ciblé de contention transitoire et la skill projet `hangfire-startup-lock`. ## Vérifications - `dotnet test tests/Heimdall.Api.Tests/Heimdall.Api.Tests.csproj --no-restore --filter FullyQualifiedName~RecurringJobStartupRetryTests` — 1 passé. - `dotnet build src/Heimdall.Web/Heimdall.Web.csproj --no-restore` — réussi, 0 avertissement. - Compose disposable depuis la source: projet `heimdall214-261107080901-ae486b`, sans ports hôtes publiés; Central healthy et `hangfire.hash` confirme `recurring-job:agent-failover` avec cron `*/1 * * * *`. - Trap de nettoyage: aucun conteneur/volume/réseau du projet et tag `heimdall:heimdall214-261107080901-ae486b-acceptance` absent. Bases PostgreSQL/.NET conservées. Le critère de télémétrie après déploiement reste ouvert dans #214. Aucun déploiement réel n’est déclaré validé. Reviewed-on: #278
33 lines
999 B
C#
33 lines
999 B
C#
using Hangfire;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Logging;
|
|
using NSubstitute;
|
|
using Shouldly;
|
|
|
|
namespace Heimdall.Api.Tests;
|
|
|
|
public sealed class RecurringJobStartupRetryTests
|
|
{
|
|
[Fact]
|
|
public async Task ConfigureRecurringJobs_RetriesDistributedLockContention()
|
|
{
|
|
var manager = Substitute.For<IRecurringJobManager>();
|
|
var calls = 0;
|
|
manager.When(x => x.RemoveIfExists(Arg.Any<string>())).Do(_ =>
|
|
{
|
|
if (Interlocked.Increment(ref calls) == 1)
|
|
throw new Hangfire.PostgreSql.PostgreSqlDistributedLockException("synthetic lock contention");
|
|
});
|
|
|
|
using var services = new ServiceCollection()
|
|
.AddLogging()
|
|
.AddSingleton(manager)
|
|
.BuildServiceProvider();
|
|
|
|
await Program.ConfigureRecurringJobsAsync(services, CancellationToken.None);
|
|
|
|
calls.ShouldBe(2);
|
|
manager.Received(2).RemoveIfExists("heartbeat-monitor");
|
|
}
|
|
}
|