Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf418ece

Browse files
authored
test(cli): prevent flake due to outdated build in TestSSH (#12760)
Fixes#12752
1 parent51491fc commitf418ece

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

‎cli/ssh_test.go

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,26 @@ func TestSSH(t *testing.T) {
117117
clitest.SetupConfig(t,client,root)
118118
pty:=ptytest.New(t).Attach(inv)
119119

120-
ctx,cancel:=context.WithTimeout(context.Background(),testutil.WaitLong)
120+
ctx,cancel:=context.WithTimeout(context.Background(),testutil.WaitSuperLong)
121121
defercancel()
122122

123123
cmdDone:=tGo(t,func() {
124124
err:=inv.WithContext(ctx).Run()
125125
assert.NoError(t,err)
126126
})
127127

128+
// Delay until workspace is starting, otherwise the agent may be
129+
// booted due to outdated build.
130+
varerrerror
131+
for {
132+
workspace,err=client.Workspace(ctx,workspace.ID)
133+
require.NoError(t,err)
134+
ifworkspace.LatestBuild.Transition==codersdk.WorkspaceTransitionStart {
135+
break
136+
}
137+
time.Sleep(testutil.IntervalFast)
138+
}
139+
128140
// When the agent connects, the workspace was started, and we should
129141
// have access to the shell.
130142
_=agenttest.New(t,client.URL,authToken)
@@ -365,7 +377,7 @@ func TestSSH(t *testing.T) {
365377
workspaceBuild:=coderdtest.CreateWorkspaceBuild(t,client,workspace,database.WorkspaceTransitionStop)
366378
coderdtest.AwaitWorkspaceBuildJobCompleted(t,client,workspaceBuild.ID)
367379

368-
ctx,cancel:=context.WithTimeout(context.Background(),testutil.WaitLong)
380+
ctx,cancel:=context.WithTimeout(context.Background(),testutil.WaitSuperLong)
369381
defercancel()
370382

371383
clientStdinR,clientStdinW:=io.Pipe()
@@ -461,6 +473,18 @@ func TestSSH(t *testing.T) {
461473
assert.NoError(t,err)
462474
})
463475

476+
// Delay until workspace is starting, otherwise the agent may be
477+
// booted due to outdated build.
478+
varerrerror
479+
for {
480+
workspace,err=client.Workspace(ctx,workspace.ID)
481+
require.NoError(t,err)
482+
ifworkspace.LatestBuild.Transition==codersdk.WorkspaceTransitionStart {
483+
break
484+
}
485+
time.Sleep(testutil.IntervalFast)
486+
}
487+
464488
// When the agent connects, the workspace was started, and we should
465489
// have access to the shell.
466490
_=agenttest.New(t,client.URL,authToken)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp