fix(admin): complete processing diagnostics and failure evidence
This commit is contained in:
@@ -37,6 +37,47 @@ public sealed class UserOperationHistoryPersistenceTests
|
||||
Assert.Equal(DateTimeKind.Utc, item.AtUtc.Kind);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Admin_diagnostic_filters_translate_and_preserve_owner_joins_in_MariaDB()
|
||||
{
|
||||
await using var database = await MariaDbDatabase.CreateAsync();
|
||||
await using var db = database.Context();
|
||||
db.Users.Add(new() { Id = "rd21-owner", UserName = "diagnostic-owner", Email = "diagnostic@example.test" });
|
||||
db.Users.Add(new() { Id = "foreign", UserName = "diagnostic-foreign", Email = "foreign@example.test" });
|
||||
var company = new Company { OwnerUserId = "rd21-owner", Name = "Diagnostic company" };
|
||||
var job = new JobApplication { OwnerUserId = "rd21-owner", Company = company, JobTitle = "Diagnostic engineer", Status = "Applied" };
|
||||
var artifact = new CvUploadArtifact { OwnerUserId = "rd21-owner", OriginalFileName = "synthetic.pdf", MimeType = "application/pdf", ByteSize = 400 };
|
||||
db.JobApplications.Add(job); db.CvUploadArtifacts.Add(artifact);
|
||||
await db.SaveChangesAsync();
|
||||
var run = new CvExtractionRun { OwnerUserId = "rd21-owner", ArtifactId = artifact.Id, Trigger = "document_import", ParserVersion = ProfileCvController.DocumentParserVersion };
|
||||
db.CvExtractionRuns.Add(run); await db.SaveChangesAsync();
|
||||
var store = new UserOperationStore(db, TimeProvider.System);
|
||||
await store.CreateAsync(Request("diagnostic-document") with { SubjectType = CvProcessingQueue.SubjectType, SubjectId = run.Id.ToString() }, default);
|
||||
var strategy = (await store.CreateAsync(Request("diagnostic-strategy") with { TaskType = StrategySnapshotService.TaskType, SubjectType = "job_strategy", SubjectId = StrategySnapshotService.EncodeSubject(job.Id, []) }, default)).Operation;
|
||||
strategy.CreatedAtUtc = new DateTime(2026, 10, 15, 12, 0, 0, DateTimeKind.Utc);
|
||||
strategy.FailureCategory = "timeout";
|
||||
var failedAt = DateTime.UtcNow.AddMinutes(-5);
|
||||
db.UserOperationEvents.Add(new() { OperationId = strategy.Id, OwnerUserId = strategy.OwnerUserId, Kind = "RetryScheduled", Status = OperationStatuses.WaitingForRetry, AtUtc = failedAt, Stage = "cv_extracting", FailureCode = "timeout" });
|
||||
db.UserOperations.Add(new() { Id = Guid.NewGuid(), OwnerUserId = "foreign", IdempotencyKey = "foreign-diagnostic", TaskType = StrategySnapshotService.TaskType, SubjectType = "job_strategy", SubjectId = StrategySnapshotService.EncodeSubject(job.Id, []), Status = OperationStatuses.Queued, CreatedAtUtc = DateTime.UtcNow });
|
||||
await db.SaveChangesAsync();
|
||||
var controller = new AdminProcessingController(db, new ConfigurationBuilder().Build(), TimeProvider.System);
|
||||
var results = new[]
|
||||
{
|
||||
await controller.List(jobId: job.Id), await controller.List(q: "Diagnostic engineer"),
|
||||
await controller.List(worker: "document"), await controller.List(failureCode: "timeout"),
|
||||
await controller.List(createdBefore: new DateTimeOffset(2026, 10, 16, 0, 0, 0, TimeSpan.Zero)),
|
||||
};
|
||||
foreach (var result in results)
|
||||
{
|
||||
var page = Assert.IsType<AdminProcessingController.PageDto>(Assert.IsType<OkObjectResult>(result.Result).Value);
|
||||
Assert.Equal(1, page.Total);
|
||||
Assert.Equal("rd21-owner", Assert.Single(page.Items).Owner.Id);
|
||||
}
|
||||
var detail = Assert.IsType<AdminProcessingController.ItemDto>(Assert.IsType<OkObjectResult>((await controller.Detail(strategy.Id, default)).Result).Value);
|
||||
Assert.Equal(failedAt, Assert.IsType<DateTime>(detail.LastFailureAtUtc), TimeSpan.FromMilliseconds(1));
|
||||
Assert.Equal("cv_extracting", detail.LastFailureStage);
|
||||
}
|
||||
|
||||
private static CreateUserOperation Request(string key) => new("cv.process", key, "authorized", "local_only");
|
||||
|
||||
[Fact]
|
||||
|
||||
Reference in New Issue
Block a user