8000 test(cli/ssh): fix ssh start conflict test by faking API response by mafredri · Pull Request #16082 · coder/coder · GitHub
[go: up one dir, main page]

Skip to content

test(cli/ssh): fix ssh start conflict test by faking API response #16082

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 10, 2025
Merged
Changes from 1 commit
Commits
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
Next Next commit
test(cli/ssh): sync post-build to fix build race on slow runners
  • Loading branch information
mafredri committed Jan 9, 2025
commit d3d041094ef88da50330da0cbfb94ea270d380ea
14 changes: 8 additions & 6 deletions cli/ssh_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,16 +154,18 @@ func TestSSH(t *testing.T) {
// a start build of the workspace.
isFirstBuild := true
buildURL := regexp.MustCompile("/api/v2/workspaces/.*/builds")
buildReq := make(chan struct{})
buildSync := make(chan struct{})
buildResume := make(chan struct{})
buildSyncMW := func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.Method == http.MethodPost && buildURL.MatchString(r.URL.Path) {
if !isFirstBuild {
t.Log("buildSyncMW: blocking build")
buildReq <- struct{}{}
<-buildResume
t.Log("buildSyncMW: resuming build")
defer func() {
t.Log("buildSyncMW: blocking post-build")
buildSync <- struct{}{}
<-buildResume
t.Log("buildSyncMW: resuming...")
}()
} else {
isFirstBuild = false
}
Expand Down Expand Up @@ -212,7 +214,7 @@ func TestSSH(t *testing.T) {
pty.ExpectMatchContext(ctx, "Workspace was stopped, starting workspace to allow connecting to")
}
for range ptys {
testutil.RequireRecvCtx(ctx, t, buildReq)
testutil.RequireRecvCtx(ctx, t, buildSync)
}
close(buildResume)

Expand Down
Loading
0