carlos / platform Public

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

Plain git — no account needed to clone.

Download

Download this file

1package activator
2
3import (
4 "context"
5 "testing"
6 "time"
7)
8
9// Region HA spec 2 §6: the sweeper's finished sweeps are the hosting
10// loop's beat. Nothing has swept before Start.
11func TestLastSweepBeatsAfterEachSweep(t *testing.T) {
12 a, _, _, _ := testActivator(t, 400*time.Millisecond) // sweeps every 100ms
13 if !a.LastSweep().IsZero() {
14 t.Fatal("swept before Start")
15 }
16 var none *Service
17 if !none.LastSweep().IsZero() {
18 t.Fatal("a nil service swept")
19 }
20 a.Start()
21 t.Cleanup(func() { a.Shutdown(context.Background()) })
22 waitFor(t, "a sweep", func() bool { return !a.LastSweep().IsZero() })
23 first := a.LastSweep()
24 if time.Since(first) > 5*time.Second {
25 t.Fatalf("beat %v is not wall-clock time", first)
26 }
27 waitFor(t, "a later sweep", func() bool { return a.LastSweep().After(first) })
28}
29