Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge branch 'main' into colin/rm-wsconncache2
  • Loading branch information
coadler committed Jun 28, 2023
commit 5901f686b2cc95e86709b5d832cb3d5c92d1d857
26 changes: 12 additions & 14 deletions agent/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
"github.com/stretchr/testify/require"
"go.uber.org/goleak"
"golang.org/x/crypto/ssh"
"golang.org/x/exp/slices"
"golang.org/x/xerrors"
"tailscale.com/net/speedtest"
"tailscale.com/tailcfg"
Expand Down Expand Up @@ -1109,7 +1110,7 @@ func TestAgent_Lifecycle(t *testing.T) {
var got []codersdk.WorkspaceAgentLifecycle
assert.Eventually(t, func() bool {
got = client.GetLifecycleStates()
return len(got) > 0 && got[len(got)-1] == want[len(want)-1]
return slices.Contains(got, want[len(want)-1])
}, testutil.WaitShort, testutil.IntervalMedium)

require.Equal(t, want, got[:len(want)])
Expand All @@ -1131,7 +1132,7 @@ func TestAgent_Lifecycle(t *testing.T) {
var got []codersdk.WorkspaceAgentLifecycle
assert.Eventually(t, func() bool {
got = client.GetLifecycleStates()
return len(got) > 0 && got[len(got)-1] == want[len(want)-1]
return slices.Contains(got, want[len(want)-1])
}, testutil.WaitShort, testutil.IntervalMedium)

require.Equal(t, want, got[:len(want)])
Expand Down Expand Up @@ -1168,8 +1169,7 @@ func TestAgent_Lifecycle(t *testing.T) {
}, 0)

assert.Eventually(t, func() bool {
ready = client.GetLifecycleStates()
return len(ready) > 0 && ready[len(ready)-1] == codersdk.WorkspaceAgentLifecycleReady
return slices.Contains(client.GetLifecycleStates(), codersdk.WorkspaceAgentLifecycleReady)
}, testutil.WaitShort, testutil.IntervalMedium)

// Start close asynchronously so that we an inspect the state.
Expand All @@ -1191,8 +1191,8 @@ func TestAgent_Lifecycle(t *testing.T) {

var got []codersdk.WorkspaceAgentLifecycle
assert.Eventually(t, func() bool {
got = client.GetLifecycleStates()[len(ready):]
return len(got) > 0 && got[len(got)-1] == want[len(want)-1]
got = client.GetLifecycleStates()
return slices.Contains(got, want[len(want)-1])
}, testutil.WaitShort, testutil.IntervalMedium)

require.Equal(t, want, got[:len(want)])
Expand All @@ -1207,8 +1207,7 @@ func TestAgent_Lifecycle(t *testing.T) {
}, 0)

assert.Eventually(t, func() bool {
ready = client.GetLifecycleStates()
return len(ready) > 0 && ready[len(ready)-1] == codersdk.WorkspaceAgentLifecycleReady
return slices.Contains(client.GetLifecycleStates(), codersdk.WorkspaceAgentLifecycleReady)
}, testutil.WaitShort, testutil.IntervalMedium)

// Start close asynchronously so that we an inspect the state.
Expand All @@ -1231,8 +1230,8 @@ func TestAgent_Lifecycle(t *testing.T) {

var got []codersdk.WorkspaceAgentLifecycle
assert.Eventually(t, func() bool {
got = client.GetLifecycleStates()[len(ready):]
return len(got) > 0 && got[len(got)-1] == want[len(want)-1]
got = client.GetLifecycleStates()
return slices.Contains(got, want[len(want)-1])
}, testutil.WaitShort, testutil.IntervalMedium)

require.Equal(t, want, got[:len(want)])
Expand All @@ -1247,8 +1246,7 @@ func TestAgent_Lifecycle(t *testing.T) {
}, 0)

assert.Eventually(t, func() bool {
ready = client.GetLifecycleStates()
return len(ready) > 0 && ready[len(ready)-1] == codersdk.WorkspaceAgentLifecycleReady
return slices.Contains(client.GetLifecycleStates(), codersdk.WorkspaceAgentLifecycleReady)
}, testutil.WaitShort, testutil.IntervalMedium)

// Start close asynchronously so that we an inspect the state.
Expand All @@ -1271,8 +1269,8 @@ func TestAgent_Lifecycle(t *testing.T) {

var got []codersdk.WorkspaceAgentLifecycle
assert.Eventually(t, func() bool {
got = client.GetLifecycleStates()[len(ready):]
return len(got) > 0 && got[len(got)-1] == want[len(want)-1]
got = client.GetLifecycleStates()
return slices.Contains(got, want[len(want)-1])
}, testutil.WaitShort, testutil.IntervalMedium)

require.Equal(t, want, got[:len(want)])
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.