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

Commit979951e

Browse files
committed
improve synchro
1 parentd3d0410 commit979951e

File tree

1 file changed

+24
-9
lines changed

1 file changed

+24
-9
lines changed

‎cli/ssh_test.go

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -154,17 +154,22 @@ func TestSSH(t *testing.T) {
154154
// a start build of the workspace.
155155
isFirstBuild:=true
156156
buildURL:=regexp.MustCompile("/api/v2/workspaces/.*/builds")
157-
buildSync:=make(chanstruct{})
158-
buildResume:=make(chanstruct{})
157+
buildPause:=make(chanstruct{})
158+
buildDone:=make(chanstruct{})
159+
buildReturnSync:=make(chanstruct{})
159160
buildSyncMW:=func(next http.Handler) http.Handler {
160161
returnhttp.HandlerFunc(func(w http.ResponseWriter,r*http.Request) {
161162
ifr.Method==http.MethodPost&&buildURL.MatchString(r.URL.Path) {
162163
if!isFirstBuild {
164+
t.Log("buildSyncMW: pausing build")
165+
<-buildPause
166+
t.Log("buildSyncMW: resuming build")
163167
deferfunc() {
164-
t.Log("buildSyncMW: blocking post-build")
165-
buildSync<-struct{}{}
166-
<-buildResume
167-
t.Log("buildSyncMW: resuming...")
168+
t.Log("buildSyncMW: sending build done")
169+
buildDone<-struct{}{}
170+
t.Log("buildSyncMW: waiting for return sync")
171+
<-buildReturnSync
172+
t.Log("buildSyncMW: returning")
168173
}()
169174
}else {
170175
isFirstBuild=false
@@ -213,10 +218,20 @@ func TestSSH(t *testing.T) {
213218
for_,pty:=rangeptys {
214219
pty.ExpectMatchContext(ctx,"Workspace was stopped, starting workspace to allow connecting to")
215220
}
216-
forrangeptys {
217-
testutil.RequireRecvCtx(ctx,t,buildSync)
221+
222+
// Allow one build to complete.
223+
testutil.RequireSendCtx(ctx,t,buildPause,struct{}{})
224+
testutil.RequireRecvCtx(ctx,t,buildDone)
225+
226+
// Allow the remaining builds to continue.
227+
fori:=0;i<len(ptys)-1;i++ {
228+
testutil.RequireSendCtx(ctx,t,buildPause,struct{}{})
229+
}
230+
fori:=0;i<len(ptys)-1;i++ {
231+
testutil.RequireRecvCtx(ctx,t,buildDone)
218232
}
219-
close(buildResume)
233+
// Allow all three endpoints to return.
234+
close(buildReturnSync)
220235

221236
varfoundConflictint
222237
for_,pty:=rangeptys {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp