vole
Site
Clone
Read only, no credentials:
https://rodent.software/vole.git
Write over SSH with a registered key:
git clone ssh://git@rodent.software/vole.git
Self-hosted forge that lives in your Git repo.
|
484548cd
Keenan Nemetz
9d ago
|
1 | package server |
| 2 | ||
| 3 | import ( | |
| 4 | "testing" | |
| 5 | "time" | |
| 6 | ) | |
| 7 | ||
| 8 | // leaseSweep is the lag between a runner dying and its job going back on the | |
| 9 | // queue, so it follows the lease instead of being a constant: a two-second lease | |
| 10 | // with a five-second sweep would look dead for longer than the lease it replaced. | |
| 11 | func TestLeaseSweepFollowsTheLease(t *testing.T) { | |
| 12 | for _, tc := range []struct { | |
| 13 | lease, want time.Duration | |
| 14 | }{ | |
| 15 | {60 * time.Second, 5 * time.Second}, | |
| 16 | {30 * time.Second, 5 * time.Second}, | |
| 17 | {20 * time.Second, 5 * time.Second}, | |
| 18 | {8 * time.Second, 2 * time.Second}, | |
| 19 | {2 * time.Second, 500 * time.Millisecond}, | |
| 20 | {400 * time.Millisecond, 100 * time.Millisecond}, | |
| 21 | {10 * time.Millisecond, 100 * time.Millisecond}, | |
| 22 | } { | |
| 23 | if got := leaseSweep(tc.lease); got != tc.want { | |
| 24 | t.Errorf("leaseSweep(%s) = %s, want %s", tc.lease, got, tc.want) | |
| 25 | } | |
| 26 | } | |
| 27 | } |