MCPcopy Index your code
hub / github.com/coder/coder / waitForExit

Function waitForExit

agent/agentproc/api_test.go:176–202  ·  view source on GitHub ↗

waitForExit polls the output endpoint until the process is no longer running or the context expires.

(t *testing.T, handler http.Handler, id string)

Source from the content-addressed store, hash-verified

174// waitForExit polls the output endpoint until the process is
175// no longer running or the context expires.
176func waitForExit(t *testing.T, handler http.Handler, id string) workspacesdk.ProcessOutputResponse {
177 t.Helper()
178
179 ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
180 defer cancel()
181
182 ticker := time.NewTicker(50 * time.Millisecond)
183 defer ticker.Stop()
184
185 for {
186 select {
187 case <-ctx.Done():
188 t.Fatal("timed out waiting for process to exit")
189 case <-ticker.C:
190 w := getOutput(t, handler, id)
191 require.Equal(t, http.StatusOK, w.Code)
192
193 var resp workspacesdk.ProcessOutputResponse
194 err := json.NewDecoder(w.Body).Decode(&resp)
195 require.NoError(t, err)
196
197 if !resp.Running {
198 return resp
199 }
200 }
201 }
202}
203
204// startAndGetID is a helper that starts a process and returns
205// the process ID.

Callers 5

TestStartProcessFunction · 0.85
TestListProcessesFunction · 0.85
TestProcessOutputFunction · 0.85
TestSignalProcessFunction · 0.85
TestProcessLifecycleFunction · 0.85

Calls 6

getOutputFunction · 0.85
FatalMethod · 0.80
HelperMethod · 0.65
StopMethod · 0.65
DoneMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected