diff --git a/go.mod b/go.mod index 536bce2fe28b7..656d4e8068882 100644 --- a/go.mod +++ b/go.mod @@ -98,7 +98,7 @@ require ( github.com/coder/flog v1.1.0 github.com/coder/guts v1.3.1-0.20250428170043-ad369017e95b github.com/coder/pretty v0.0.0-20230908205945-e89ba86370e0 - github.com/coder/quartz v0.1.2 + github.com/coder/quartz v0.1.3 github.com/coder/retry v1.5.1 github.com/coder/serpent v0.10.0 github.com/coder/terraform-provider-coder/v2 v2.4.0-pre1.0.20250417100258-c86bb5c3ddcd diff --git a/go.sum b/go.sum index a3fc878ef2653..555332e8a8173 100644 --- a/go.sum +++ b/go.sum @@ -909,8 +909,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/preview v0.0.2-0.20250506154333-6f500ca7b245 h1:RGoANNubwwPZF8puiYAk2qbzhVgipBMNu8WIrY1VIbI= github.com/coder/preview v0.0.2-0.20250506154333-6f500ca7b245/go.mod h1:5VnO9yw7vq19hBgBqqBksE2BH53UTmNYH1QltkYLXJI= -github.com/coder/quartz v0.1.2 h1:PVhc9sJimTdKd3VbygXtS4826EOCpB1fXoRlLnCrE+s= -github.com/coder/quartz v0.1.2/go.mod h1:vsiCc+AHViMKH2CQpGIpFgdHIEQsxwm8yCscqKmzbRA= +github.com/coder/quartz v0.1.3 h1:hA2nI8uUA2fNN9uhXv2I4xZD4aHkA7oH3g2t03v4xf8= +github.com/coder/quartz v0.1.3/go.mod h1:vsiCc+AHViMKH2CQpGIpFgdHIEQsxwm8yCscqKmzbRA= github.com/coder/retry v1.5.1 h1:iWu8YnD8YqHs3XwqrqsjoBTAVqT9ml6z9ViJ2wlMiqc= github.com/coder/retry v1.5.1/go.mod h1:blHMk9vs6LkoRT9ZHyuZo360cufXEhrxqvEzeMtRGoY= github.com/coder/serpent v0.10.0 h1:ofVk9FJXSek+SmL3yVE3GoArP83M+1tX+H7S4t8BSuM= diff --git a/vpn/tunnel_internal_test.go b/vpn/tunnel_internal_test.go index 2beba66d7a7d2..7325cfc813cf1 100644 --- a/vpn/tunnel_internal_test.go +++ b/vpn/tunnel_internal_test.go @@ -573,7 +573,6 @@ func TestTunnel_sendAgentUpdateReconnect(t *testing.T) { require.NoError(t, err) // The new update only contains the new agent - mClock.AdvanceNext() req = testutil.TryReceive(ctx, t, mgr.requests) require.Nil(t, req.msg.Rpc) peerUpdate := req.msg.GetPeerUpdate() @@ -695,14 +694,19 @@ func TestTunnel_sendAgentUpdateWorkspaceReconnect(t *testing.T) { } //nolint:revive // t takes precedence -func setupTunnel(t *testing.T, ctx context.Context, client *fakeClient, mClock quartz.Clock) (*Tunnel, *speaker[*ManagerMessage, *TunnelMessage, TunnelMessage]) { +func setupTunnel(t *testing.T, ctx context.Context, client *fakeClient, mClock *quartz.Mock) (*Tunnel, *speaker[*ManagerMessage, *TunnelMessage, TunnelMessage]) { mp, tp := net.Pipe() t.Cleanup(func() { _ = mp.Close() }) t.Cleanup(func() { _ = tp.Close() }) logger := testutil.Logger(t) + // We're creating a trap for the mClock to ensure that + // AdvanceNext() is not called before the ticker is created. + trap := mClock.Trap().NewTicker() + defer trap.Close() var tun *Tunnel var mgr *speaker[*ManagerMessage, *TunnelMessage, TunnelMessage] + errCh := make(chan error, 2) go func() { tunnel, err := NewTunnel(ctx, logger.Named("tunnel"), tp, client, WithClock(mClock)) @@ -719,6 +723,8 @@ func setupTunnel(t *testing.T, ctx context.Context, client *fakeClient, mClock q err = testutil.TryReceive(ctx, t, errCh) require.NoError(t, err) mgr.start() + // We're releasing the trap to allow the clock to advance the ticker. + trap.MustWait(ctx).Release() return tun, mgr }