package activator import ( "context" "testing" "time" ) // Region HA spec 2 ยง6: the sweeper's finished sweeps are the hosting // loop's beat. Nothing has swept before Start. func TestLastSweepBeatsAfterEachSweep(t *testing.T) { a, _, _, _ := testActivator(t, 400*time.Millisecond) // sweeps every 100ms if !a.LastSweep().IsZero() { t.Fatal("swept before Start") } var none *Service if !none.LastSweep().IsZero() { t.Fatal("a nil service swept") } a.Start() t.Cleanup(func() { a.Shutdown(context.Background()) }) waitFor(t, "a sweep", func() bool { return !a.LastSweep().IsZero() }) first := a.LastSweep() if time.Since(first) > 5*time.Second { t.Fatalf("beat %v is not wall-clock time", first) } waitFor(t, "a later sweep", func() bool { return a.LastSweep().After(first) }) }