carlos / platform Public

Clone
git clone https://amadan.net/carlos/platform

Plain git — no account needed to clone.

Download

Download this file

1package host
2
3import (
4 "testing"
5 "time"
6)
7
8func TestAgentNoCensusShutdownBudget(t *testing.T) {
9 startup, duties := make(chan struct{}), make(chan struct{})
10 cancelled := make(chan struct{})
11 go func() { <-cancelled; time.Sleep(200 * time.Millisecond); close(startup); close(duties) }()
12 began := time.Now()
13 ctx, cancel, err := joinAgentShutdown(nil, nil, nil, func() { close(cancelled) }, startup, duties)
14 defer cancel()
15 if err != nil {
16 t.Fatal(err)
17 }
18 if time.Since(began) < 200*time.Millisecond {
19 t.Fatal("did not join delayed duties")
20 }
21 deadline, ok := ctx.Deadline()
22 if !ok || time.Until(deadline) < 59950*time.Millisecond || ctx.Err() != nil {
23 t.Fatal("no-census shutdown lost its fresh 60 seconds", deadline, ctx.Err())
24 }
25}
26