Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 817ec87

Browse files
ibetitsmikeEdwardAngert
authored andcommitted
fix: fixed flaking VPN tunnel tests & bump coder/quartz to 0.1.3 (#17737)
Closes: coder/internal#624
1 parent c90608d commit 817ec87

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ require (
9898
github.com/coder/flog v1.1.0
9999
github.com/coder/guts v1.3.1-0.20250428170043-ad369017e95b
100100
github.com/coder/pretty v0.0.0-20230908205945-e89ba86370e0
101-
github.com/coder/quartz v0.1.2
101+
github.com/coder/quartz v0.1.3
102102
github.com/coder/retry v1.5.1
103103
github.com/coder/serpent v0.10.0
104104
github.com/coder/terraform-provider-coder/v2 v2.4.0-pre1.0.20250417100258-c86bb5c3ddcd

go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -909,8 +909,8 @@ github.com/coder/pretty v0.0.0-20230908205945-e89ba86370e0 h1:3A0ES21Ke+FxEM8CXx
909909
github.com/coder/pretty v0.0.0-20230908205945-e89ba86370e0/go.mod h1:5UuS2Ts+nTToAMeOjNlnHFkPahrtDkmpydBen/3wgZc=
910910
github.com/coder/preview v0.0.2-0.20250506154333-6f500ca7b245 h1:RGoANNubwwPZF8puiYAk2qbzhVgipBMNu8WIrY1VIbI=
911911
github.com/coder/preview v0.0.2-0.20250506154333-6f500ca7b245/go.mod h1:5VnO9yw7vq19hBgBqqBksE2BH53UTmNYH1QltkYLXJI=
912-
github.com/coder/quartz v0.1.2 h1:PVhc9sJimTdKd3VbygXtS4826EOCpB1fXoRlLnCrE+s=
913-
github.com/coder/quartz v0.1.2/go.mod h1:vsiCc+AHViMKH2CQpGIpFgdHIEQsxwm8yCscqKmzbRA=
912+
github.com/coder/quartz v0.1.3 h1:hA2nI8uUA2fNN9uhXv2I4xZD4aHkA7oH3g2t03v4xf8=
913+
github.com/coder/quartz v0.1.3/go.mod h1:vsiCc+AHViMKH2CQpGIpFgdHIEQsxwm8yCscqKmzbRA=
914914
github.com/coder/retry v1.5.1 h1:iWu8YnD8YqHs3XwqrqsjoBTAVqT9ml6z9ViJ2wlMiqc=
915915
github.com/coder/retry v1.5.1/go.mod h1:blHMk9vs6LkoRT9ZHyuZo360cufXEhrxqvEzeMtRGoY=
916916
github.com/coder/serpent v0.10.0 h1:ofVk9FJXSek+SmL3yVE3GoArP83M+1tX+H7S4t8BSuM=

vpn/tunnel_internal_test.go

+8-2
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,6 @@ func TestTunnel_sendAgentUpdateReconnect(t *testing.T) {
573573
require.NoError(t, err)
574574

575575
// The new update only contains the new agent
576-
mClock.AdvanceNext()
577576
req = testutil.TryReceive(ctx, t, mgr.requests)
578577
require.Nil(t, req.msg.Rpc)
579578
peerUpdate := req.msg.GetPeerUpdate()
@@ -695,14 +694,19 @@ func TestTunnel_sendAgentUpdateWorkspaceReconnect(t *testing.T) {
695694
}
696695

697696
//nolint:revive // t takes precedence
698-
func setupTunnel(t *testing.T, ctx context.Context, client *fakeClient, mClock quartz.Clock) (*Tunnel, *speaker[*ManagerMessage, *TunnelMessage, TunnelMessage]) {
697+
func setupTunnel(t *testing.T, ctx context.Context, client *fakeClient, mClock *quartz.Mock) (*Tunnel, *speaker[*ManagerMessage, *TunnelMessage, TunnelMessage]) {
699698
mp, tp := net.Pipe()
700699
t.Cleanup(func() { _ = mp.Close() })
701700
t.Cleanup(func() { _ = tp.Close() })
702701
logger := testutil.Logger(t)
702+
// We're creating a trap for the mClock to ensure that
703+
// AdvanceNext() is not called before the ticker is created.
704+
trap := mClock.Trap().NewTicker()
705+
defer trap.Close()
703706

704707
var tun *Tunnel
705708
var mgr *speaker[*ManagerMessage, *TunnelMessage, TunnelMessage]
709+
706710
errCh := make(chan error, 2)
707711
go func() {
708712
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
719723
err = testutil.TryReceive(ctx, t, errCh)
720724
require.NoError(t, err)
721725
mgr.start()
726+
// We're releasing the trap to allow the clock to advance the ticker.
727+
trap.MustWait(ctx).Release()
722728
return tun, mgr
723729
}
724730

0 commit comments

Comments
 (0)