mirror of
https://github.com/coder/coder.git
synced 2026-06-02 20:48:20 +00:00
chore: update to coder/quartz v0.2.0 (#18007)
Upgrade to coder/quartz v0.2.0 including fixing up a minor API breaking change.
This commit is contained in:
@@ -257,7 +257,7 @@ func TestAPI(t *testing.T) {
|
|||||||
|
|
||||||
// Make sure the ticker function has been registered
|
// Make sure the ticker function has been registered
|
||||||
// before advancing the clock.
|
// before advancing the clock.
|
||||||
tickerTrap.MustWait(ctx).Release()
|
tickerTrap.MustWait(ctx).MustRelease(ctx)
|
||||||
tickerTrap.Close()
|
tickerTrap.Close()
|
||||||
|
|
||||||
// Initial request returns the initial data.
|
// Initial request returns the initial data.
|
||||||
@@ -432,7 +432,7 @@ func TestAPI(t *testing.T) {
|
|||||||
|
|
||||||
// Make sure the ticker function has been registered
|
// Make sure the ticker function has been registered
|
||||||
// before advancing the clock.
|
// before advancing the clock.
|
||||||
tickerTrap.MustWait(ctx).Release()
|
tickerTrap.MustWait(ctx).MustRelease(ctx)
|
||||||
tickerTrap.Close()
|
tickerTrap.Close()
|
||||||
|
|
||||||
for i := range tt.wantStatus {
|
for i := range tt.wantStatus {
|
||||||
@@ -486,7 +486,7 @@ func TestAPI(t *testing.T) {
|
|||||||
nowRecreateSuccessTrap.Close()
|
nowRecreateSuccessTrap.Close()
|
||||||
// The timestamp for the error will be stored, which gives
|
// The timestamp for the error will be stored, which gives
|
||||||
// us a good anchor point to know when to do our request.
|
// us a good anchor point to know when to do our request.
|
||||||
nowRecreateErrorTrap.MustWait(ctx).Release()
|
nowRecreateErrorTrap.MustWait(ctx).MustRelease(ctx)
|
||||||
nowRecreateErrorTrap.Close()
|
nowRecreateErrorTrap.Close()
|
||||||
|
|
||||||
// Advance the clock to run the devcontainer state update routine.
|
// Advance the clock to run the devcontainer state update routine.
|
||||||
@@ -507,7 +507,7 @@ func TestAPI(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Ensure the devcontainer ends up in success state.
|
// Ensure the devcontainer ends up in success state.
|
||||||
nowRecreateSuccessTrap.MustWait(ctx).Release()
|
nowRecreateSuccessTrap.MustWait(ctx).MustRelease(ctx)
|
||||||
nowRecreateSuccessTrap.Close()
|
nowRecreateSuccessTrap.Close()
|
||||||
|
|
||||||
// Advance the clock to run the devcontainer state update routine.
|
// Advance the clock to run the devcontainer state update routine.
|
||||||
@@ -911,7 +911,7 @@ func TestAPI(t *testing.T) {
|
|||||||
|
|
||||||
// Make sure the ticker function has been registered
|
// Make sure the ticker function has been registered
|
||||||
// before advancing any use of mClock.Advance.
|
// before advancing any use of mClock.Advance.
|
||||||
tickerTrap.MustWait(ctx).Release()
|
tickerTrap.MustWait(ctx).MustRelease(ctx)
|
||||||
tickerTrap.Close()
|
tickerTrap.Close()
|
||||||
|
|
||||||
// Make sure the start loop has been called.
|
// Make sure the start loop has been called.
|
||||||
@@ -1007,7 +1007,7 @@ func TestAPI(t *testing.T) {
|
|||||||
|
|
||||||
// Make sure the ticker function has been registered
|
// Make sure the ticker function has been registered
|
||||||
// before advancing any use of mClock.Advance.
|
// before advancing any use of mClock.Advance.
|
||||||
tickerTrap.MustWait(ctx).Release()
|
tickerTrap.MustWait(ctx).MustRelease(ctx)
|
||||||
tickerTrap.Close()
|
tickerTrap.Close()
|
||||||
|
|
||||||
// Call the list endpoint first to ensure config files are
|
// Call the list endpoint first to ensure config files are
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ func TestAppHealth_Healthy(t *testing.T) {
|
|||||||
healthchecksStarted := make([]string, 2)
|
healthchecksStarted := make([]string, 2)
|
||||||
for i := 0; i < 2; i++ {
|
for i := 0; i < 2; i++ {
|
||||||
c := healthcheckTrap.MustWait(ctx)
|
c := healthcheckTrap.MustWait(ctx)
|
||||||
c.Release()
|
c.MustRelease(ctx)
|
||||||
healthchecksStarted[i] = c.Tags[1]
|
healthchecksStarted[i] = c.Tags[1]
|
||||||
}
|
}
|
||||||
slices.Sort(healthchecksStarted)
|
slices.Sort(healthchecksStarted)
|
||||||
@@ -87,7 +87,7 @@ func TestAppHealth_Healthy(t *testing.T) {
|
|||||||
// advance the clock 1ms before the report ticker starts, so that it's not
|
// advance the clock 1ms before the report ticker starts, so that it's not
|
||||||
// simultaneous with the checks.
|
// simultaneous with the checks.
|
||||||
mClock.Advance(time.Millisecond).MustWait(ctx)
|
mClock.Advance(time.Millisecond).MustWait(ctx)
|
||||||
reportTrap.MustWait(ctx).Release()
|
reportTrap.MustWait(ctx).MustRelease(ctx)
|
||||||
|
|
||||||
mClock.Advance(999 * time.Millisecond).MustWait(ctx) // app2 is now healthy
|
mClock.Advance(999 * time.Millisecond).MustWait(ctx) // app2 is now healthy
|
||||||
|
|
||||||
@@ -143,11 +143,11 @@ func TestAppHealth_500(t *testing.T) {
|
|||||||
|
|
||||||
fakeAPI, closeFn := setupAppReporter(ctx, t, slices.Clone(apps), handlers, mClock)
|
fakeAPI, closeFn := setupAppReporter(ctx, t, slices.Clone(apps), handlers, mClock)
|
||||||
defer closeFn()
|
defer closeFn()
|
||||||
healthcheckTrap.MustWait(ctx).Release()
|
healthcheckTrap.MustWait(ctx).MustRelease(ctx)
|
||||||
// advance the clock 1ms before the report ticker starts, so that it's not
|
// advance the clock 1ms before the report ticker starts, so that it's not
|
||||||
// simultaneous with the checks.
|
// simultaneous with the checks.
|
||||||
mClock.Advance(time.Millisecond).MustWait(ctx)
|
mClock.Advance(time.Millisecond).MustWait(ctx)
|
||||||
reportTrap.MustWait(ctx).Release()
|
reportTrap.MustWait(ctx).MustRelease(ctx)
|
||||||
|
|
||||||
mClock.Advance(999 * time.Millisecond).MustWait(ctx) // check gets triggered
|
mClock.Advance(999 * time.Millisecond).MustWait(ctx) // check gets triggered
|
||||||
mClock.Advance(time.Millisecond).MustWait(ctx) // report gets triggered, but unsent since we are at the threshold
|
mClock.Advance(time.Millisecond).MustWait(ctx) // report gets triggered, but unsent since we are at the threshold
|
||||||
@@ -202,25 +202,25 @@ func TestAppHealth_Timeout(t *testing.T) {
|
|||||||
|
|
||||||
fakeAPI, closeFn := setupAppReporter(ctx, t, apps, handlers, mClock)
|
fakeAPI, closeFn := setupAppReporter(ctx, t, apps, handlers, mClock)
|
||||||
defer closeFn()
|
defer closeFn()
|
||||||
healthcheckTrap.MustWait(ctx).Release()
|
healthcheckTrap.MustWait(ctx).MustRelease(ctx)
|
||||||
// advance the clock 1ms before the report ticker starts, so that it's not
|
// advance the clock 1ms before the report ticker starts, so that it's not
|
||||||
// simultaneous with the checks.
|
// simultaneous with the checks.
|
||||||
mClock.Set(ms(1)).MustWait(ctx)
|
mClock.Set(ms(1)).MustWait(ctx)
|
||||||
reportTrap.MustWait(ctx).Release()
|
reportTrap.MustWait(ctx).MustRelease(ctx)
|
||||||
|
|
||||||
w := mClock.Set(ms(1000)) // 1st check starts
|
w := mClock.Set(ms(1000)) // 1st check starts
|
||||||
timeoutTrap.MustWait(ctx).Release()
|
timeoutTrap.MustWait(ctx).MustRelease(ctx)
|
||||||
mClock.Set(ms(1001)).MustWait(ctx) // report tick, no change
|
mClock.Set(ms(1001)).MustWait(ctx) // report tick, no change
|
||||||
mClock.Set(ms(1999)) // timeout pops
|
mClock.Set(ms(1999)) // timeout pops
|
||||||
w.MustWait(ctx) // 1st check finished
|
w.MustWait(ctx) // 1st check finished
|
||||||
w = mClock.Set(ms(2000)) // 2nd check starts
|
w = mClock.Set(ms(2000)) // 2nd check starts
|
||||||
timeoutTrap.MustWait(ctx).Release()
|
timeoutTrap.MustWait(ctx).MustRelease(ctx)
|
||||||
mClock.Set(ms(2001)).MustWait(ctx) // report tick, no change
|
mClock.Set(ms(2001)).MustWait(ctx) // report tick, no change
|
||||||
mClock.Set(ms(2999)) // timeout pops
|
mClock.Set(ms(2999)) // timeout pops
|
||||||
w.MustWait(ctx) // 2nd check finished
|
w.MustWait(ctx) // 2nd check finished
|
||||||
// app is now unhealthy after 2 timeouts
|
// app is now unhealthy after 2 timeouts
|
||||||
mClock.Set(ms(3000)) // 3rd check starts
|
mClock.Set(ms(3000)) // 3rd check starts
|
||||||
timeoutTrap.MustWait(ctx).Release()
|
timeoutTrap.MustWait(ctx).MustRelease(ctx)
|
||||||
mClock.Set(ms(3001)).MustWait(ctx) // report tick, sends changes
|
mClock.Set(ms(3001)).MustWait(ctx) // report tick, sends changes
|
||||||
|
|
||||||
update := testutil.TryReceive(ctx, t, fakeAPI.AppHealthCh())
|
update := testutil.TryReceive(ctx, t, fakeAPI.AppHealthCh())
|
||||||
|
|||||||
@@ -206,7 +206,7 @@ func TestCloserStack_Timeout(t *testing.T) {
|
|||||||
defer close(closed)
|
defer close(closed)
|
||||||
uut.close(nil)
|
uut.close(nil)
|
||||||
}()
|
}()
|
||||||
trap.MustWait(ctx).Release()
|
trap.MustWait(ctx).MustRelease(ctx)
|
||||||
// top starts right away, but it hangs
|
// top starts right away, but it hangs
|
||||||
testutil.TryReceive(ctx, t, ac[2].started)
|
testutil.TryReceive(ctx, t, ac[2].started)
|
||||||
// timer pops and we start the middle one
|
// timer pops and we start the middle one
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ func TestNotifier(t *testing.T) {
|
|||||||
n := notify.New(cond, testCase.PollInterval, testCase.Countdown, notify.WithTestClock(mClock))
|
n := notify.New(cond, testCase.PollInterval, testCase.Countdown, notify.WithTestClock(mClock))
|
||||||
defer n.Close()
|
defer n.Close()
|
||||||
|
|
||||||
trap.MustWait(ctx).Release() // ensure ticker started
|
trap.MustWait(ctx).MustRelease(ctx) // ensure ticker started
|
||||||
for i := 0; i < testCase.NTicks; i++ {
|
for i := 0; i < testCase.NTicks; i++ {
|
||||||
interval, w := mClock.AdvanceNext()
|
interval, w := mClock.AdvanceNext()
|
||||||
w.MustWait(ctx)
|
w.MustWait(ctx)
|
||||||
|
|||||||
@@ -423,7 +423,7 @@ func TestCryptoKeyCache(t *testing.T) {
|
|||||||
require.Equal(t, 2, ff.called)
|
require.Equal(t, 2, ff.called)
|
||||||
require.Equal(t, decodedSecret(t, newKey), key)
|
require.Equal(t, decodedSecret(t, newKey), key)
|
||||||
|
|
||||||
trapped.Release()
|
trapped.MustRelease(ctx)
|
||||||
wait.MustWait(ctx)
|
wait.MustWait(ctx)
|
||||||
require.Equal(t, 2, ff.called)
|
require.Equal(t, 2, ff.called)
|
||||||
trap.Close()
|
trap.Close()
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ func TestRotator(t *testing.T) {
|
|||||||
require.Len(t, dbkeys, initialKeyLen)
|
require.Len(t, dbkeys, initialKeyLen)
|
||||||
requireContainsAllFeatures(t, dbkeys)
|
requireContainsAllFeatures(t, dbkeys)
|
||||||
|
|
||||||
trap.MustWait(ctx).Release()
|
trap.MustWait(ctx).MustRelease(ctx)
|
||||||
_, wait := clock.AdvanceNext()
|
_, wait := clock.AdvanceNext()
|
||||||
wait.MustWait(ctx)
|
wait.MustWait(ctx)
|
||||||
|
|
||||||
|
|||||||
@@ -279,10 +279,10 @@ func awaitDoTick(ctx context.Context, t *testing.T, clk *quartz.Mock) chan struc
|
|||||||
defer trapStop.Close()
|
defer trapStop.Close()
|
||||||
defer trapNow.Close()
|
defer trapNow.Close()
|
||||||
// Wait for the initial tick signified by a call to Now().
|
// Wait for the initial tick signified by a call to Now().
|
||||||
trapNow.MustWait(ctx).Release()
|
trapNow.MustWait(ctx).MustRelease(ctx)
|
||||||
// doTick runs here. Wait for the next
|
// doTick runs here. Wait for the next
|
||||||
// ticker reset event that signifies it's completed.
|
// ticker reset event that signifies it's completed.
|
||||||
trapReset.MustWait(ctx).Release()
|
trapReset.MustWait(ctx).MustRelease(ctx)
|
||||||
// Ensure that the next tick happens in 10 minutes from start.
|
// Ensure that the next tick happens in 10 minutes from start.
|
||||||
d, w := clk.AdvanceNext()
|
d, w := clk.AdvanceNext()
|
||||||
if !assert.Equal(t, 10*time.Minute, d) {
|
if !assert.Equal(t, 10*time.Minute, d) {
|
||||||
@@ -290,7 +290,7 @@ func awaitDoTick(ctx context.Context, t *testing.T, clk *quartz.Mock) chan struc
|
|||||||
}
|
}
|
||||||
w.MustWait(ctx)
|
w.MustWait(ctx)
|
||||||
// Wait for the ticker stop event.
|
// Wait for the ticker stop event.
|
||||||
trapStop.MustWait(ctx).Release()
|
trapStop.MustWait(ctx).MustRelease(ctx)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
return ch
|
return ch
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ func TestWatchdog_NoTimeout(t *testing.T) {
|
|||||||
// right baseline time.
|
// right baseline time.
|
||||||
pc, err := pubTrap.Wait(ctx)
|
pc, err := pubTrap.Wait(ctx)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
pc.Release()
|
pc.MustRelease(ctx)
|
||||||
require.Equal(t, 15*time.Second, pc.Duration)
|
require.Equal(t, 15*time.Second, pc.Duration)
|
||||||
|
|
||||||
// we subscribe after starting the timer, so we know the timer also starts
|
// we subscribe after starting the timer, so we know the timer also starts
|
||||||
@@ -66,7 +66,7 @@ func TestWatchdog_NoTimeout(t *testing.T) {
|
|||||||
}()
|
}()
|
||||||
sc, err := subTrap.Wait(ctx) // timer.Stop() called
|
sc, err := subTrap.Wait(ctx) // timer.Stop() called
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
sc.Release()
|
sc.MustRelease(ctx)
|
||||||
err = testutil.TryReceive(ctx, t, errCh)
|
err = testutil.TryReceive(ctx, t, errCh)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
@@ -88,7 +88,7 @@ func TestWatchdog_Timeout(t *testing.T) {
|
|||||||
// right baseline time.
|
// right baseline time.
|
||||||
pc, err := pubTrap.Wait(ctx)
|
pc, err := pubTrap.Wait(ctx)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
pc.Release()
|
pc.MustRelease(ctx)
|
||||||
require.Equal(t, 15*time.Second, pc.Duration)
|
require.Equal(t, 15*time.Second, pc.Duration)
|
||||||
|
|
||||||
// we subscribe after starting the timer, so we know the timer also starts
|
// we subscribe after starting the timer, so we know the timer also starts
|
||||||
|
|||||||
@@ -276,8 +276,8 @@ func TestPendingUpdatesMetric(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
mgr.Run(ctx)
|
mgr.Run(ctx)
|
||||||
trap.MustWait(ctx).Release() // ensures ticker has been set
|
trap.MustWait(ctx).MustRelease(ctx) // ensures ticker has been set
|
||||||
fetchTrap.MustWait(ctx).Release()
|
fetchTrap.MustWait(ctx).MustRelease(ctx)
|
||||||
|
|
||||||
// Advance to the first fetch
|
// Advance to the first fetch
|
||||||
mClock.Advance(cfg.FetchInterval.Value()).MustWait(ctx)
|
mClock.Advance(cfg.FetchInterval.Value()).MustWait(ctx)
|
||||||
|
|||||||
@@ -341,8 +341,8 @@ func TestBackpressure(t *testing.T) {
|
|||||||
|
|
||||||
// Start the notifier.
|
// Start the notifier.
|
||||||
mgr.Run(ctx)
|
mgr.Run(ctx)
|
||||||
syncTrap.MustWait(ctx).Release()
|
syncTrap.MustWait(ctx).MustRelease(ctx)
|
||||||
fetchTrap.MustWait(ctx).Release()
|
fetchTrap.MustWait(ctx).MustRelease(ctx)
|
||||||
|
|
||||||
// THEN:
|
// THEN:
|
||||||
|
|
||||||
|
|||||||
@@ -1137,7 +1137,7 @@ func TestRunLoop(t *testing.T) {
|
|||||||
trap := clock.Trap().NewTicker()
|
trap := clock.Trap().NewTicker()
|
||||||
go reconciler.Run(ctx)
|
go reconciler.Run(ctx)
|
||||||
// wait until ticker is initialized
|
// wait until ticker is initialized
|
||||||
trap.MustWait(ctx).Release()
|
trap.MustWait(ctx).MustRelease(ctx)
|
||||||
// start 1st iteration of ReconciliationLoop
|
// start 1st iteration of ReconciliationLoop
|
||||||
// NOTE: at this point MustWait waits that iteration is started (ReconcileAll is called), but it doesn't wait until it completes
|
// NOTE: at this point MustWait waits that iteration is started (ReconcileAll is called), but it doesn't wait until it completes
|
||||||
clock.Advance(cfg.ReconciliationInterval.Value()).MustWait(ctx)
|
clock.Advance(cfg.ReconciliationInterval.Value()).MustWait(ctx)
|
||||||
|
|||||||
@@ -63,9 +63,8 @@ func TestHeartbeats_Cleanup(t *testing.T) {
|
|||||||
uut.wg.Add(1)
|
uut.wg.Add(1)
|
||||||
go uut.cleanupLoop()
|
go uut.cleanupLoop()
|
||||||
|
|
||||||
call, err := trap.Wait(ctx)
|
call := trap.MustWait(ctx)
|
||||||
require.NoError(t, err)
|
call.MustRelease(ctx)
|
||||||
call.Release()
|
|
||||||
require.Equal(t, cleanupPeriod, call.Duration)
|
require.Equal(t, cleanupPeriod, call.Duration)
|
||||||
mClock.Advance(cleanupPeriod).MustWait(ctx)
|
mClock.Advance(cleanupPeriod).MustWait(ctx)
|
||||||
}
|
}
|
||||||
@@ -99,7 +98,7 @@ func TestHeartbeats_recvBeat_resetSkew(t *testing.T) {
|
|||||||
// coord 3 heartbeat comes very soon after
|
// coord 3 heartbeat comes very soon after
|
||||||
mClock.Advance(time.Millisecond).MustWait(ctx)
|
mClock.Advance(time.Millisecond).MustWait(ctx)
|
||||||
go uut.listen(ctx, []byte(coord3.String()), nil)
|
go uut.listen(ctx, []byte(coord3.String()), nil)
|
||||||
trap.MustWait(ctx).Release()
|
trap.MustWait(ctx).MustRelease(ctx)
|
||||||
|
|
||||||
// both coordinators are present
|
// both coordinators are present
|
||||||
uut.lock.RLock()
|
uut.lock.RLock()
|
||||||
@@ -112,11 +111,11 @@ func TestHeartbeats_recvBeat_resetSkew(t *testing.T) {
|
|||||||
// however, several ms pass between expiring 2 and computing the time until 3 expires
|
// however, several ms pass between expiring 2 and computing the time until 3 expires
|
||||||
c := trap.MustWait(ctx)
|
c := trap.MustWait(ctx)
|
||||||
mClock.Advance(2 * time.Millisecond).MustWait(ctx) // 3 has now expired _in the past_
|
mClock.Advance(2 * time.Millisecond).MustWait(ctx) // 3 has now expired _in the past_
|
||||||
c.Release()
|
c.MustRelease(ctx)
|
||||||
w.MustWait(ctx)
|
w.MustWait(ctx)
|
||||||
|
|
||||||
// expired in the past means we immediately reschedule checkExpiry, so we get another call
|
// expired in the past means we immediately reschedule checkExpiry, so we get another call
|
||||||
trap.MustWait(ctx).Release()
|
trap.MustWait(ctx).MustRelease(ctx)
|
||||||
|
|
||||||
uut.lock.RLock()
|
uut.lock.RLock()
|
||||||
require.NotContains(t, uut.coordinators, coord2)
|
require.NotContains(t, uut.coordinators, coord2)
|
||||||
@@ -411,7 +410,7 @@ func TestPGCoordinatorUnhealthy(t *testing.T) {
|
|||||||
expectedPeriod := HeartbeatPeriod
|
expectedPeriod := HeartbeatPeriod
|
||||||
tfCall, err := tfTrap.Wait(ctx)
|
tfCall, err := tfTrap.Wait(ctx)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
tfCall.Release()
|
tfCall.MustRelease(ctx)
|
||||||
require.Equal(t, expectedPeriod, tfCall.Duration)
|
require.Equal(t, expectedPeriod, tfCall.Duration)
|
||||||
|
|
||||||
// Now that the ticker has started, we can advance 2 more beats to get to 3
|
// Now that the ticker has started, we can advance 2 more beats to get to 3
|
||||||
|
|||||||
@@ -286,7 +286,7 @@ func TestPGCoordinatorSingle_MissedHeartbeats(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fCoord2.heartbeat()
|
fCoord2.heartbeat()
|
||||||
afTrap.MustWait(ctx).Release() // heartbeat timeout started
|
afTrap.MustWait(ctx).MustRelease(ctx) // heartbeat timeout started
|
||||||
|
|
||||||
fCoord2.agentNode(agent.ID, &agpl.Node{PreferredDERP: 12})
|
fCoord2.agentNode(agent.ID, &agpl.Node{PreferredDERP: 12})
|
||||||
client.AssertEventuallyHasDERP(agent.ID, 12)
|
client.AssertEventuallyHasDERP(agent.ID, 12)
|
||||||
@@ -298,20 +298,20 @@ func TestPGCoordinatorSingle_MissedHeartbeats(t *testing.T) {
|
|||||||
id: uuid.New(),
|
id: uuid.New(),
|
||||||
}
|
}
|
||||||
fCoord3.heartbeat()
|
fCoord3.heartbeat()
|
||||||
rstTrap.MustWait(ctx).Release() // timeout gets reset
|
rstTrap.MustWait(ctx).MustRelease(ctx) // timeout gets reset
|
||||||
fCoord3.agentNode(agent.ID, &agpl.Node{PreferredDERP: 13})
|
fCoord3.agentNode(agent.ID, &agpl.Node{PreferredDERP: 13})
|
||||||
client.AssertEventuallyHasDERP(agent.ID, 13)
|
client.AssertEventuallyHasDERP(agent.ID, 13)
|
||||||
|
|
||||||
// fCoord2 sends in a second heartbeat, one period later (on time)
|
// fCoord2 sends in a second heartbeat, one period later (on time)
|
||||||
mClock.Advance(tailnet.HeartbeatPeriod).MustWait(ctx)
|
mClock.Advance(tailnet.HeartbeatPeriod).MustWait(ctx)
|
||||||
fCoord2.heartbeat()
|
fCoord2.heartbeat()
|
||||||
rstTrap.MustWait(ctx).Release() // timeout gets reset
|
rstTrap.MustWait(ctx).MustRelease(ctx) // timeout gets reset
|
||||||
|
|
||||||
// when the fCoord3 misses enough heartbeats, the real coordinator should send an update with the
|
// when the fCoord3 misses enough heartbeats, the real coordinator should send an update with the
|
||||||
// node from fCoord2 for the agent.
|
// node from fCoord2 for the agent.
|
||||||
mClock.Advance(tailnet.HeartbeatPeriod).MustWait(ctx)
|
mClock.Advance(tailnet.HeartbeatPeriod).MustWait(ctx)
|
||||||
w := mClock.Advance(tailnet.HeartbeatPeriod)
|
w := mClock.Advance(tailnet.HeartbeatPeriod)
|
||||||
rstTrap.MustWait(ctx).Release()
|
rstTrap.MustWait(ctx).MustRelease(ctx)
|
||||||
w.MustWait(ctx)
|
w.MustWait(ctx)
|
||||||
client.AssertEventuallyHasDERP(agent.ID, 12)
|
client.AssertEventuallyHasDERP(agent.ID, 12)
|
||||||
|
|
||||||
@@ -323,7 +323,7 @@ func TestPGCoordinatorSingle_MissedHeartbeats(t *testing.T) {
|
|||||||
|
|
||||||
// send fCoord3 heartbeat, which should trigger us to consider that mapping valid again.
|
// send fCoord3 heartbeat, which should trigger us to consider that mapping valid again.
|
||||||
fCoord3.heartbeat()
|
fCoord3.heartbeat()
|
||||||
rstTrap.MustWait(ctx).Release() // timeout gets reset
|
rstTrap.MustWait(ctx).MustRelease(ctx) // timeout gets reset
|
||||||
client.AssertEventuallyHasDERP(agent.ID, 13)
|
client.AssertEventuallyHasDERP(agent.ID, 13)
|
||||||
|
|
||||||
agent.UngracefulDisconnect(ctx)
|
agent.UngracefulDisconnect(ctx)
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ require (
|
|||||||
github.com/coder/flog v1.1.0
|
github.com/coder/flog v1.1.0
|
||||||
github.com/coder/guts v1.5.0
|
github.com/coder/guts v1.5.0
|
||||||
github.com/coder/pretty v0.0.0-20230908205945-e89ba86370e0
|
github.com/coder/pretty v0.0.0-20230908205945-e89ba86370e0
|
||||||
github.com/coder/quartz v0.1.3
|
github.com/coder/quartz v0.2.1-0.20250527113331-b71761ce32df
|
||||||
github.com/coder/retry v1.5.1
|
github.com/coder/retry v1.5.1
|
||||||
github.com/coder/serpent v0.10.0
|
github.com/coder/serpent v0.10.0
|
||||||
github.com/coder/terraform-provider-coder/v2 v2.5.0
|
github.com/coder/terraform-provider-coder/v2 v2.5.0
|
||||||
|
|||||||
@@ -913,8 +913,8 @@ github.com/coder/pretty v0.0.0-20230908205945-e89ba86370e0 h1:3A0ES21Ke+FxEM8CXx
|
|||||||
github.com/coder/pretty v0.0.0-20230908205945-e89ba86370e0/go.mod h1:5UuS2Ts+nTToAMeOjNlnHFkPahrtDkmpydBen/3wgZc=
|
github.com/coder/pretty v0.0.0-20230908205945-e89ba86370e0/go.mod h1:5UuS2Ts+nTToAMeOjNlnHFkPahrtDkmpydBen/3wgZc=
|
||||||
github.com/coder/preview v0.0.2-0.20250521212114-e6a60ffa74f2 h1:D52yPPupcbNWppZzWAjZJG5L34TGpNyKj7vG1VT13FU=
|
github.com/coder/preview v0.0.2-0.20250521212114-e6a60ffa74f2 h1:D52yPPupcbNWppZzWAjZJG5L34TGpNyKj7vG1VT13FU=
|
||||||
github.com/coder/preview v0.0.2-0.20250521212114-e6a60ffa74f2/go.mod h1:9bwyhQSVDjcxAWuFFaG6/qBqhaiW5oqF5PEQMhevKLs=
|
github.com/coder/preview v0.0.2-0.20250521212114-e6a60ffa74f2/go.mod h1:9bwyhQSVDjcxAWuFFaG6/qBqhaiW5oqF5PEQMhevKLs=
|
||||||
github.com/coder/quartz v0.1.3 h1:hA2nI8uUA2fNN9uhXv2I4xZD4aHkA7oH3g2t03v4xf8=
|
github.com/coder/quartz v0.2.1-0.20250527113331-b71761ce32df h1:o6lpiSrGKVopPv6Fnh3S+FrI5ntRE0eSUo6Bqpzpkgo=
|
||||||
github.com/coder/quartz v0.1.3/go.mod h1:vsiCc+AHViMKH2CQpGIpFgdHIEQsxwm8yCscqKmzbRA=
|
github.com/coder/quartz v0.2.1-0.20250527113331-b71761ce32df/go.mod h1:vsiCc+AHViMKH2CQpGIpFgdHIEQsxwm8yCscqKmzbRA=
|
||||||
github.com/coder/retry v1.5.1 h1:iWu8YnD8YqHs3XwqrqsjoBTAVqT9ml6z9ViJ2wlMiqc=
|
github.com/coder/retry v1.5.1 h1:iWu8YnD8YqHs3XwqrqsjoBTAVqT9ml6z9ViJ2wlMiqc=
|
||||||
github.com/coder/retry v1.5.1/go.mod h1:blHMk9vs6LkoRT9ZHyuZo360cufXEhrxqvEzeMtRGoY=
|
github.com/coder/retry v1.5.1/go.mod h1:blHMk9vs6LkoRT9ZHyuZo360cufXEhrxqvEzeMtRGoY=
|
||||||
github.com/coder/serpent v0.10.0 h1:ofVk9FJXSek+SmL3yVE3GoArP83M+1tX+H7S4t8BSuM=
|
github.com/coder/serpent v0.10.0 h1:ofVk9FJXSek+SmL3yVE3GoArP83M+1tX+H7S4t8BSuM=
|
||||||
|
|||||||
@@ -828,7 +828,7 @@ func TestBasicResumeTokenController_Mainline(t *testing.T) {
|
|||||||
RefreshIn: durationpb.New(100 * time.Second),
|
RefreshIn: durationpb.New(100 * time.Second),
|
||||||
ExpiresAt: timestamppb.New(mClock.Now().Add(200 * time.Second)),
|
ExpiresAt: timestamppb.New(mClock.Now().Add(200 * time.Second)),
|
||||||
})
|
})
|
||||||
trp.MustWait(ctx).Release() // initial refresh done
|
trp.MustWait(ctx).MustRelease(ctx) // initial refresh done
|
||||||
token, ok := uut.Token()
|
token, ok := uut.Token()
|
||||||
require.True(t, ok)
|
require.True(t, ok)
|
||||||
require.Equal(t, "test token 1", token)
|
require.Equal(t, "test token 1", token)
|
||||||
@@ -843,7 +843,7 @@ func TestBasicResumeTokenController_Mainline(t *testing.T) {
|
|||||||
})
|
})
|
||||||
resetCall := trp.MustWait(ctx)
|
resetCall := trp.MustWait(ctx)
|
||||||
require.Equal(t, resetCall.Duration, 50*time.Second)
|
require.Equal(t, resetCall.Duration, 50*time.Second)
|
||||||
resetCall.Release()
|
resetCall.MustRelease(ctx)
|
||||||
w.MustWait(ctx)
|
w.MustWait(ctx)
|
||||||
token, ok = uut.Token()
|
token, ok = uut.Token()
|
||||||
require.True(t, ok)
|
require.True(t, ok)
|
||||||
@@ -903,7 +903,7 @@ func TestBasicResumeTokenController_NewWhileRefreshing(t *testing.T) {
|
|||||||
ExpiresAt: timestamppb.New(mClock.Now().Add(200 * time.Second)),
|
ExpiresAt: timestamppb.New(mClock.Now().Add(200 * time.Second)),
|
||||||
})
|
})
|
||||||
|
|
||||||
trp.MustWait(ctx).Release()
|
trp.MustWait(ctx).MustRelease(ctx)
|
||||||
|
|
||||||
token, ok := uut.Token()
|
token, ok := uut.Token()
|
||||||
require.True(t, ok)
|
require.True(t, ok)
|
||||||
@@ -923,7 +923,7 @@ func TestBasicResumeTokenController_NewWhileRefreshing(t *testing.T) {
|
|||||||
})
|
})
|
||||||
resetCall := trp.MustWait(ctx)
|
resetCall := trp.MustWait(ctx)
|
||||||
require.Equal(t, resetCall.Duration, 50*time.Second)
|
require.Equal(t, resetCall.Duration, 50*time.Second)
|
||||||
resetCall.Release()
|
resetCall.MustRelease(ctx)
|
||||||
w.MustWait(ctx)
|
w.MustWait(ctx)
|
||||||
token, ok = uut.Token()
|
token, ok = uut.Token()
|
||||||
require.True(t, ok)
|
require.True(t, ok)
|
||||||
|
|||||||
@@ -724,7 +724,7 @@ func setupTunnel(t *testing.T, ctx context.Context, client *fakeClient, mClock *
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
mgr.start()
|
mgr.start()
|
||||||
// We're releasing the trap to allow the clock to advance the ticker.
|
// We're releasing the trap to allow the clock to advance the ticker.
|
||||||
trap.MustWait(ctx).Release()
|
trap.MustWait(ctx).MustRelease(ctx)
|
||||||
return tun, mgr
|
return tun, mgr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user