接入证书任务取消上下文

为证书导入、恢复、校验和当前部署工作流绑定任务取消回调,补充取消接口与回归测试,并同步四份整改清单进度。
This commit is contained in:
xuans committed 2026-09-30 02:32:58 +08:00
1 parent b8997512f9
commit 4cf9fb6076
11 files changed
+162 -14

No files matched your search

@@ -259,6 +259,38 @@ func TestCertificateTerminalPersistenceFailureIsReturnedWithoutReissue(t *testin
}
}
func TestCertificateTasksBindCancellationHook(t *testing.T) {
w, a := newCertificateTaskFixture(t)
registerCh := make(chan context.CancelFunc, 1)
unregisterCh := make(chan string, 1)
ctx := repository.WithTaskCancellationHooks(t.Context(), repository.TaskCancellationHooks{
Register: func(_ string, cancel context.CancelFunc) { registerCh <- cancel },
Unregister: func(taskID string) { unregisterCh <- taskID },
})
started := make(chan struct{})
finished := make(chan error, 1)
go func() {
_, err := w.run(ctx, "task-domain", "certificate_validate", "certificate_validate", 1, 0, func(ctx context.Context, _ string) (CertificateWorkflowResult, error) {
close(started)
<-ctx.Done()
return CertificateWorkflowResult{}, ctx.Err()
})
finished <- err
}()
<-started
cancel := <-registerCh
cancel()
if err := <-finished; !errors.Is(err, context.Canceled) {
t.Fatalf("task cancellation error = %v", err)
}
select {
case <-unregisterCh:
case <-time.After(time.Second):
t.Fatal("task cancellation hook was not unregistered")
}
assertCertificateTask(t, a, "cancelled", "cancelled")
}
func TestCertificateTasksRecordPartialDeploymentFailure(t *testing.T) {
w, a := newCertificateTaskFixture(t)
_, err := w.run(t.Context(), "task-domain", "renewal_run", "certificate_issue", 1, 0, func(context.Context, string) (CertificateWorkflowResult, error) {