mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-20 09:06:45 +00:00
fix(GODT-3124): Handling of sync child jobs
Improve the handling of sync child jobs to ensure it behaves correctly in all scenarios. The sync service now uses a isolated context to avoid all the pipeline stages shutting down before all the sync tasks have had the opportunity to run their course. The job waiter now immediately starts with a counter of 1 and waits until all the child and the parent job finish before considering the work to be finished. Finally, we also handle the case where a sync job can't be queued because the calling context has been cancelled.
This commit is contained in:
@ -83,6 +83,7 @@ func TestJob_WaitsOnAllChildrenOnError(t *testing.T) {
|
||||
|
||||
job1.onFinished(context.Background())
|
||||
job2.onError(jobErr)
|
||||
tj.job.end()
|
||||
}()
|
||||
|
||||
close(startCh)
|
||||
@ -115,6 +116,7 @@ func TestJob_MultipleChildrenReportError(t *testing.T) {
|
||||
}
|
||||
|
||||
wg.Wait()
|
||||
tj.job.end()
|
||||
close(startCh)
|
||||
err := tj.job.waitAndClose(context.Background())
|
||||
require.Error(t, err)
|
||||
@ -179,6 +181,7 @@ func TestJob_CtxCancelCancelsAllChildren(t *testing.T) {
|
||||
|
||||
go func() {
|
||||
wg.Wait()
|
||||
tj.job.end()
|
||||
cancel()
|
||||
}()
|
||||
|
||||
@ -201,6 +204,7 @@ func TestJob_CtxCancelBeforeBegin(t *testing.T) {
|
||||
go func() {
|
||||
wg.Wait()
|
||||
cancel()
|
||||
tj.job.end()
|
||||
}()
|
||||
|
||||
wg.Done()
|
||||
|
||||
Reference in New Issue
Block a user