(t *testing.T, leaseUntil time.Time, timeout time.Duration)
| 4146 | } |
| 4147 | |
| 4148 | func waitUntilLeaseExpires(t *testing.T, leaseUntil time.Time, timeout time.Duration) { |
| 4149 | t.Helper() |
| 4150 | |
| 4151 | ctx, cancel := context.WithTimeout(context.Background(), timeout) |
| 4152 | defer cancel() |
| 4153 | ticker := time.NewTicker(10 * time.Millisecond) |
| 4154 | defer ticker.Stop() |
| 4155 | |
| 4156 | for { |
| 4157 | if time.Now().After(leaseUntil) { |
| 4158 | return |
| 4159 | } |
| 4160 | select { |
| 4161 | case <-ctx.Done(): |
| 4162 | t.Fatalf("timed out waiting for lease expiry at %s", leaseUntil.Format(time.RFC3339Nano)) |
| 4163 | case <-ticker.C: |
| 4164 | } |
| 4165 | } |
| 4166 | } |
no test coverage detected