feat(storage): add native PostgreSQL runtime and verified offline application import
Build and publish container images / images (push) Failing after 12m29s
Build and publish container images / images (push) Failing after 12m29s
This commit is contained in:
1 parent
96065d1e89
commit
0ba1dcfef0
243 files changed
+21441
-3090
No files matched your search
@@ -14,6 +14,53 @@ type finishedJob struct {
|
||||
err error
|
||||
at time.Time
|
||||
}
|
||||
|
||||
func TestRunnerStopWaitsAndClosesAdmission(t *testing.T) {
|
||||
q := newFakeQueue(1)
|
||||
reg := &Registry{}
|
||||
started := make(chan struct{})
|
||||
cancelled := make(chan struct{})
|
||||
exit := make(chan struct{})
|
||||
if err := reg.Register("synthetic", func(ctx context.Context, _ *Job) error {
|
||||
close(started)
|
||||
<-ctx.Done()
|
||||
close(cancelled)
|
||||
<-exit // simulate cleanup that cannot be interrupted
|
||||
return ctx.Err()
|
||||
}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
r := NewRunner(q, reg, RunnerOptions{})
|
||||
r.Dispatch(context.Background())
|
||||
receive(t, started)
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
cancel()
|
||||
if err := r.Stop(ctx); !errors.Is(err, context.Canceled) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
receive(t, cancelled)
|
||||
if r.Running() != 1 {
|
||||
t.Fatal("worker exited before cleanup")
|
||||
}
|
||||
r.Dispatch(context.Background())
|
||||
if q.claimed != 1 {
|
||||
t.Fatal("admission remained open")
|
||||
}
|
||||
close(exit)
|
||||
ctx, cancel = context.WithTimeout(context.Background(), time.Second)
|
||||
defer cancel()
|
||||
if err := r.Stop(ctx); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
receive(t, q.finished)
|
||||
if r.Running() != 0 {
|
||||
t.Fatal("worker slot retained after stop")
|
||||
}
|
||||
if err := r.Stop(ctx); err != nil {
|
||||
t.Fatal("idempotent stop", err)
|
||||
}
|
||||
}
|
||||
|
||||
type fakeQueue struct {
|
||||
mu sync.Mutex
|
||||
settings Settings
|
||||
|
||||
Reference in new issue
Block a user