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

Commit3954f5b

Browse files
committed
improve synchro
1 parentd3d0410 commit3954f5b

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

‎cli/ssh_test.go

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,17 +155,19 @@ func TestSSH(t *testing.T) {
155155
isFirstBuild:=true
156156
buildURL:=regexp.MustCompile("/api/v2/workspaces/.*/builds")
157157
buildSync:=make(chanstruct{})
158+
buildDone:=make(chanstruct{})
158159
buildResume:=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: blocking post-build")
165+
<-buildSync
163166
deferfunc() {
164-
t.Log("buildSyncMW: blocking post-build")
165-
buildSync<-struct{}{}
167+
buildDone<-struct{}{}
166168
<-buildResume
167-
t.Log("buildSyncMW: resuming...")
168169
}()
170+
t.Log("buildSyncMW: resuming...")
169171
}else {
170172
isFirstBuild=false
171173
}
@@ -213,9 +215,19 @@ func TestSSH(t *testing.T) {
213215
for_,pty:=rangeptys {
214216
pty.ExpectMatchContext(ctx,"Workspace was stopped, starting workspace to allow connecting to")
215217
}
216-
forrangeptys {
217-
testutil.RequireRecvCtx(ctx,t,buildSync)
218+
219+
// Allow one build to complete.
220+
testutil.RequireSendCtx(ctx,t,buildSync,struct{}{})
221+
testutil.RequireRecvCtx(ctx,t,buildDone)
222+
223+
// Allow the remaining builds to continue.
224+
fori:=0;i<len(ptys)-1;i++ {
225+
testutil.RequireSendCtx(ctx,t,buildSync,struct{}{})
226+
}
227+
fori:=0;i<len(ptys)-1;i++ {
228+
testutil.RequireRecvCtx(ctx,t,buildDone)
218229
}
230+
// Allow all three endpoints to return.
219231
close(buildResume)
220232

221233
varfoundConflictint

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp