Skip to content

Commit 728981f

Browse files
authored
Merge branch 'main' into cj/notifications-pubsub
2 parents a21c241 + daafa0d commit 728981f

File tree

91 files changed

+2120
-956
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+2120
-956
lines changed

.github/actions/setup-go/action.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: |
44
inputs:
55
version:
66
description: "The Go version to use."
7-
default: "1.24.1"
7+
default: "1.24.2"
88
runs:
99
using: "composite"
1010
steps:

agent/agent_test.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ func TestAgent_ImmediateClose(t *testing.T) {
110110
})
111111

112112
// wait until the agent has connected and is starting to find races in the startup code
113-
_ = testutil.RequireRecvCtx(ctx, t, client.GetStartup())
113+
_ = testutil.TryReceive(ctx, t, client.GetStartup())
114114
t.Log("Closing Agent")
115115
err := agentUnderTest.Close()
116116
require.NoError(t, err)
@@ -1700,7 +1700,7 @@ func TestAgent_Lifecycle(t *testing.T) {
17001700
// In order to avoid shutting down the agent before it is fully started and triggering
17011701
// errors, we'll wait until the agent is fully up. It's a bit hokey, but among the last things the agent starts
17021702
// is the stats reporting, so getting a stats report is a good indication the agent is fully up.
1703-
_ = testutil.RequireRecvCtx(ctx, t, statsCh)
1703+
_ = testutil.TryReceive(ctx, t, statsCh)
17041704

17051705
err := agent.Close()
17061706
require.NoError(t, err, "agent should be closed successfully")
@@ -1730,7 +1730,7 @@ func TestAgent_Startup(t *testing.T) {
17301730
_, client, _, _, _ := setupAgent(t, agentsdk.Manifest{
17311731
Directory: "",
17321732
}, 0)
1733-
startup := testutil.RequireRecvCtx(ctx, t, client.GetStartup())
1733+
startup := testutil.TryReceive(ctx, t, client.GetStartup())
17341734
require.Equal(t, "", startup.GetExpandedDirectory())
17351735
})
17361736

@@ -1741,7 +1741,7 @@ func TestAgent_Startup(t *testing.T) {
17411741
_, client, _, _, _ := setupAgent(t, agentsdk.Manifest{
17421742
Directory: "~",
17431743
}, 0)
1744-
startup := testutil.RequireRecvCtx(ctx, t, client.GetStartup())
1744+
startup := testutil.TryReceive(ctx, t, client.GetStartup())
17451745
homeDir, err := os.UserHomeDir()
17461746
require.NoError(t, err)
17471747
require.Equal(t, homeDir, startup.GetExpandedDirectory())
@@ -1754,7 +1754,7 @@ func TestAgent_Startup(t *testing.T) {
17541754
_, client, _, _, _ := setupAgent(t, agentsdk.Manifest{
17551755
Directory: "coder/coder",
17561756
}, 0)
1757-
startup := testutil.RequireRecvCtx(ctx, t, client.GetStartup())
1757+
startup := testutil.TryReceive(ctx, t, client.GetStartup())
17581758
homeDir, err := os.UserHomeDir()
17591759
require.NoError(t, err)
17601760
require.Equal(t, filepath.Join(homeDir, "coder/coder"), startup.GetExpandedDirectory())
@@ -1767,7 +1767,7 @@ func TestAgent_Startup(t *testing.T) {
17671767
_, client, _, _, _ := setupAgent(t, agentsdk.Manifest{
17681768
Directory: "$HOME",
17691769
}, 0)
1770-
startup := testutil.RequireRecvCtx(ctx, t, client.GetStartup())
1770+
startup := testutil.TryReceive(ctx, t, client.GetStartup())
17711771
homeDir, err := os.UserHomeDir()
17721772
require.NoError(t, err)
17731773
require.Equal(t, homeDir, startup.GetExpandedDirectory())
@@ -2632,7 +2632,7 @@ done
26322632

26332633
n := 1
26342634
for n <= 5 {
2635-
logs := testutil.RequireRecvCtx(ctx, t, logsCh)
2635+
logs := testutil.TryReceive(ctx, t, logsCh)
26362636
require.NotNil(t, logs)
26372637
for _, l := range logs.GetLogs() {
26382638
require.Equal(t, fmt.Sprintf("start %d", n), l.GetOutput())
@@ -2645,7 +2645,7 @@ done
26452645

26462646
n = 1
26472647
for n <= 3000 {
2648-
logs := testutil.RequireRecvCtx(ctx, t, logsCh)
2648+
logs := testutil.TryReceive(ctx, t, logsCh)
26492649
require.NotNil(t, logs)
26502650
for _, l := range logs.GetLogs() {
26512651
require.Equal(t, fmt.Sprintf("stop %d", n), l.GetOutput())

agent/agentscripts/agentscripts_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func TestExecuteBasic(t *testing.T) {
4444
}}, aAPI.ScriptCompleted)
4545
require.NoError(t, err)
4646
require.NoError(t, runner.Execute(context.Background(), agentscripts.ExecuteAllScripts))
47-
log := testutil.RequireRecvCtx(ctx, t, fLogger.logs)
47+
log := testutil.TryReceive(ctx, t, fLogger.logs)
4848
require.Equal(t, "hello", log.Output)
4949
}
5050

@@ -136,7 +136,7 @@ func TestScriptReportsTiming(t *testing.T) {
136136
require.NoError(t, runner.Execute(ctx, agentscripts.ExecuteAllScripts))
137137
runner.Close()
138138

139-
log := testutil.RequireRecvCtx(ctx, t, fLogger.logs)
139+
log := testutil.TryReceive(ctx, t, fLogger.logs)
140140
require.Equal(t, "hello", log.Output)
141141

142142
timings := aAPI.GetTimings()

agent/apphealth_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ func TestAppHealth_Healthy(t *testing.T) {
9292
mClock.Advance(999 * time.Millisecond).MustWait(ctx) // app2 is now healthy
9393

9494
mClock.Advance(time.Millisecond).MustWait(ctx) // report gets triggered
95-
update := testutil.RequireRecvCtx(ctx, t, fakeAPI.AppHealthCh())
95+
update := testutil.TryReceive(ctx, t, fakeAPI.AppHealthCh())
9696
require.Len(t, update.GetUpdates(), 2)
9797
applyUpdate(t, apps, update)
9898
require.Equal(t, codersdk.WorkspaceAppHealthHealthy, apps[1].Health)
@@ -101,7 +101,7 @@ func TestAppHealth_Healthy(t *testing.T) {
101101
mClock.Advance(999 * time.Millisecond).MustWait(ctx) // app3 is now healthy
102102

103103
mClock.Advance(time.Millisecond).MustWait(ctx) // report gets triggered
104-
update = testutil.RequireRecvCtx(ctx, t, fakeAPI.AppHealthCh())
104+
update = testutil.TryReceive(ctx, t, fakeAPI.AppHealthCh())
105105
require.Len(t, update.GetUpdates(), 2)
106106
applyUpdate(t, apps, update)
107107
require.Equal(t, codersdk.WorkspaceAppHealthHealthy, apps[1].Health)
@@ -155,7 +155,7 @@ func TestAppHealth_500(t *testing.T) {
155155
mClock.Advance(999 * time.Millisecond).MustWait(ctx) // 2nd check, crosses threshold
156156
mClock.Advance(time.Millisecond).MustWait(ctx) // 2nd report, sends update
157157

158-
update := testutil.RequireRecvCtx(ctx, t, fakeAPI.AppHealthCh())
158+
update := testutil.TryReceive(ctx, t, fakeAPI.AppHealthCh())
159159
require.Len(t, update.GetUpdates(), 1)
160160
applyUpdate(t, apps, update)
161161
require.Equal(t, codersdk.WorkspaceAppHealthUnhealthy, apps[0].Health)
@@ -223,7 +223,7 @@ func TestAppHealth_Timeout(t *testing.T) {
223223
timeoutTrap.MustWait(ctx).Release()
224224
mClock.Set(ms(3001)).MustWait(ctx) // report tick, sends changes
225225

226-
update := testutil.RequireRecvCtx(ctx, t, fakeAPI.AppHealthCh())
226+
update := testutil.TryReceive(ctx, t, fakeAPI.AppHealthCh())
227227
require.Len(t, update.GetUpdates(), 1)
228228
applyUpdate(t, apps, update)
229229
require.Equal(t, codersdk.WorkspaceAppHealthUnhealthy, apps[0].Health)

agent/checkpoint_internal_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,6 @@ func TestCheckpoint_WaitComplete(t *testing.T) {
4444
errCh <- uut.wait(ctx)
4545
}()
4646
uut.complete(err)
47-
got := testutil.RequireRecvCtx(ctx, t, errCh)
47+
got := testutil.TryReceive(ctx, t, errCh)
4848
require.Equal(t, err, got)
4949
}

agent/stats_internal_test.go

+13-13
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@ func TestStatsReporter(t *testing.T) {
3434
}()
3535

3636
// initial request to get duration
37-
req := testutil.RequireRecvCtx(ctx, t, fDest.reqs)
37+
req := testutil.TryReceive(ctx, t, fDest.reqs)
3838
require.NotNil(t, req)
3939
require.Nil(t, req.Stats)
4040
interval := time.Second * 34
41-
testutil.RequireSendCtx(ctx, t, fDest.resps, &proto.UpdateStatsResponse{ReportInterval: durationpb.New(interval)})
41+
testutil.RequireSend(ctx, t, fDest.resps, &proto.UpdateStatsResponse{ReportInterval: durationpb.New(interval)})
4242

4343
// call to source to set the callback and interval
44-
gotInterval := testutil.RequireRecvCtx(ctx, t, fSource.period)
44+
gotInterval := testutil.TryReceive(ctx, t, fSource.period)
4545
require.Equal(t, interval, gotInterval)
4646

4747
// callback returning netstats
@@ -60,7 +60,7 @@ func TestStatsReporter(t *testing.T) {
6060
fSource.callback(time.Now(), time.Now(), netStats, nil)
6161

6262
// collector called to complete the stats
63-
gotNetStats := testutil.RequireRecvCtx(ctx, t, fCollector.calls)
63+
gotNetStats := testutil.TryReceive(ctx, t, fCollector.calls)
6464
require.Equal(t, netStats, gotNetStats)
6565

6666
// while we are collecting the stats, send in two new netStats to simulate
@@ -94,13 +94,13 @@ func TestStatsReporter(t *testing.T) {
9494

9595
// complete first collection
9696
stats := &proto.Stats{SessionCountJetbrains: 55}
97-
testutil.RequireSendCtx(ctx, t, fCollector.stats, stats)
97+
testutil.RequireSend(ctx, t, fCollector.stats, stats)
9898

9999
// destination called to report the first stats
100-
update := testutil.RequireRecvCtx(ctx, t, fDest.reqs)
100+
update := testutil.TryReceive(ctx, t, fDest.reqs)
101101
require.NotNil(t, update)
102102
require.Equal(t, stats, update.Stats)
103-
testutil.RequireSendCtx(ctx, t, fDest.resps, &proto.UpdateStatsResponse{ReportInterval: durationpb.New(interval)})
103+
testutil.RequireSend(ctx, t, fDest.resps, &proto.UpdateStatsResponse{ReportInterval: durationpb.New(interval)})
104104

105105
// second update -- netStat0 and netStats1 are accumulated and reported
106106
wantNetStats := map[netlogtype.Connection]netlogtype.Counts{
@@ -115,22 +115,22 @@ func TestStatsReporter(t *testing.T) {
115115
RxBytes: 21,
116116
},
117117
}
118-
gotNetStats = testutil.RequireRecvCtx(ctx, t, fCollector.calls)
118+
gotNetStats = testutil.TryReceive(ctx, t, fCollector.calls)
119119
require.Equal(t, wantNetStats, gotNetStats)
120120
stats = &proto.Stats{SessionCountJetbrains: 66}
121-
testutil.RequireSendCtx(ctx, t, fCollector.stats, stats)
122-
update = testutil.RequireRecvCtx(ctx, t, fDest.reqs)
121+
testutil.RequireSend(ctx, t, fCollector.stats, stats)
122+
update = testutil.TryReceive(ctx, t, fDest.reqs)
123123
require.NotNil(t, update)
124124
require.Equal(t, stats, update.Stats)
125125
interval2 := 27 * time.Second
126-
testutil.RequireSendCtx(ctx, t, fDest.resps, &proto.UpdateStatsResponse{ReportInterval: durationpb.New(interval2)})
126+
testutil.RequireSend(ctx, t, fDest.resps, &proto.UpdateStatsResponse{ReportInterval: durationpb.New(interval2)})
127127

128128
// set the new interval
129-
gotInterval = testutil.RequireRecvCtx(ctx, t, fSource.period)
129+
gotInterval = testutil.TryReceive(ctx, t, fSource.period)
130130
require.Equal(t, interval2, gotInterval)
131131

132132
loopCancel()
133-
err := testutil.RequireRecvCtx(ctx, t, loopErr)
133+
err := testutil.TryReceive(ctx, t, loopErr)
134134
require.NoError(t, err)
135135
}
136136

cli/cliui/prompt_test.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func TestPrompt(t *testing.T) {
3535
}()
3636
ptty.ExpectMatch("Example")
3737
ptty.WriteLine("hello")
38-
resp := testutil.RequireRecvCtx(ctx, t, msgChan)
38+
resp := testutil.TryReceive(ctx, t, msgChan)
3939
require.Equal(t, "hello", resp)
4040
})
4141

@@ -54,7 +54,7 @@ func TestPrompt(t *testing.T) {
5454
}()
5555
ptty.ExpectMatch("Example")
5656
ptty.WriteLine("yes")
57-
resp := testutil.RequireRecvCtx(ctx, t, doneChan)
57+
resp := testutil.TryReceive(ctx, t, doneChan)
5858
require.Equal(t, "yes", resp)
5959
})
6060

@@ -91,7 +91,7 @@ func TestPrompt(t *testing.T) {
9191
doneChan <- resp
9292
}()
9393

94-
resp := testutil.RequireRecvCtx(ctx, t, doneChan)
94+
resp := testutil.TryReceive(ctx, t, doneChan)
9595
require.Equal(t, "yes", resp)
9696
// Close the reader to end the io.Copy
9797
require.NoError(t, ptty.Close(), "close eof reader")
@@ -115,7 +115,7 @@ func TestPrompt(t *testing.T) {
115115
}()
116116
ptty.ExpectMatch("Example")
117117
ptty.WriteLine("{}")
118-
resp := testutil.RequireRecvCtx(ctx, t, doneChan)
118+
resp := testutil.TryReceive(ctx, t, doneChan)
119119
require.Equal(t, "{}", resp)
120120
})
121121

@@ -133,7 +133,7 @@ func TestPrompt(t *testing.T) {
133133
}()
134134
ptty.ExpectMatch("Example")
135135
ptty.WriteLine("{a")
136-
resp := testutil.RequireRecvCtx(ctx, t, doneChan)
136+
resp := testutil.TryReceive(ctx, t, doneChan)
137137
require.Equal(t, "{a", resp)
138138
})
139139

@@ -153,7 +153,7 @@ func TestPrompt(t *testing.T) {
153153
ptty.WriteLine(`{
154154
"test": "wow"
155155
}`)
156-
resp := testutil.RequireRecvCtx(ctx, t, doneChan)
156+
resp := testutil.TryReceive(ctx, t, doneChan)
157157
require.Equal(t, `{"test":"wow"}`, resp)
158158
})
159159

@@ -178,7 +178,7 @@ func TestPrompt(t *testing.T) {
178178
}()
179179
ptty.ExpectMatch("Example")
180180
ptty.WriteLine("foo\nbar\nbaz\n\n\nvalid\n")
181-
resp := testutil.RequireRecvCtx(ctx, t, doneChan)
181+
resp := testutil.TryReceive(ctx, t, doneChan)
182182
require.Equal(t, "valid", resp)
183183
})
184184
}

0 commit comments

Comments
 (0)