mirror of https://github.com/coder/coder.git
test(cli): prevent flake due to outdated build in TestSSH (#12760)
Fixes #12752
This commit is contained in:
parent
51491fc01b
commit
f418ece9ae
|
@ -117,7 +117,7 @@ func TestSSH(t *testing.T) {
|
|||
clitest.SetupConfig(t, client, root)
|
||||
pty := ptytest.New(t).Attach(inv)
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitSuperLong)
|
||||
defer cancel()
|
||||
|
||||
cmdDone := tGo(t, func() {
|
||||
|
@ -125,6 +125,18 @@ func TestSSH(t *testing.T) {
|
|||
assert.NoError(t, err)
|
||||
})
|
||||
|
||||
// Delay until workspace is starting, otherwise the agent may be
|
||||
// booted due to outdated build.
|
||||
var err error
|
||||
for {
|
||||
workspace, err = client.Workspace(ctx, workspace.ID)
|
||||
require.NoError(t, err)
|
||||
if workspace.LatestBuild.Transition == codersdk.WorkspaceTransitionStart {
|
||||
break
|
||||
}
|
||||
time.Sleep(testutil.IntervalFast)
|
||||
}
|
||||
|
||||
// When the agent connects, the workspace was started, and we should
|
||||
// have access to the shell.
|
||||
_ = agenttest.New(t, client.URL, authToken)
|
||||
|
@ -365,7 +377,7 @@ func TestSSH(t *testing.T) {
|
|||
workspaceBuild := coderdtest.CreateWorkspaceBuild(t, client, workspace, database.WorkspaceTransitionStop)
|
||||
coderdtest.AwaitWorkspaceBuildJobCompleted(t, client, workspaceBuild.ID)
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitSuperLong)
|
||||
defer cancel()
|
||||
|
||||
clientStdinR, clientStdinW := io.Pipe()
|
||||
|
@ -461,6 +473,18 @@ func TestSSH(t *testing.T) {
|
|||
assert.NoError(t, err)
|
||||
})
|
||||
|
||||
// Delay until workspace is starting, otherwise the agent may be
|
||||
// booted due to outdated build.
|
||||
var err error
|
||||
for {
|
||||
workspace, err = client.Workspace(ctx, workspace.ID)
|
||||
require.NoError(t, err)
|
||||
if workspace.LatestBuild.Transition == codersdk.WorkspaceTransitionStart {
|
||||
break
|
||||
}
|
||||
time.Sleep(testutil.IntervalFast)
|
||||
}
|
||||
|
||||
// When the agent connects, the workspace was started, and we should
|
||||
// have access to the shell.
|
||||
_ = agenttest.New(t, client.URL, authToken)
|
||||
|
|
Loading…
Reference in New Issue