@@ -458,7 +458,8 @@ func (h *Harness) cmdCurl(ts *testscript.TestScript, neg bool, args []string) {
458458
459459 if neg {
460460 if ! statusOK {
461- // Expected to fail - success!
461+ // Expected to fail - write body to stdout and return
462+ _ , _ = ts .Stdout ().Write ([]byte (respBody ))
462463 return
463464 }
464465 } else {
@@ -551,9 +552,9 @@ type healthCheckResponse struct {
551552 Status string `json:"status"`
552553}
553554
554- // waitForServer polls the server's health-check endpoint until it returns READY status.
555- // The server may return HTTP 200 while still in STARTING state (during setup),
556- // so we must check the actual status field in the response .
555+ // waitForServer polls the server's health-check endpoint until it returns a
556+ // post-setup status. It checks the status field in the JSON response body
557+ // regardless of HTTP status code .
557558func waitForServer (serverURL string , timeout time.Duration ) bool {
558559 client := & http.Client {Timeout : 5 * time .Second }
559560 deadline := time .Now ().Add (timeout )
@@ -565,34 +566,30 @@ func waitForServer(serverURL string, timeout time.Duration) bool {
565566 continue
566567 }
567568
568- if resp .StatusCode == http .StatusOK {
569- body , err := io .ReadAll (resp .Body )
570- _ = resp .Body .Close ()
571- if err != nil {
572- time .Sleep (200 * time .Millisecond )
573- continue
574- }
569+ body , err := io .ReadAll (resp .Body )
570+ _ = resp .Body .Close ()
571+ if err != nil {
572+ time .Sleep (200 * time .Millisecond )
573+ continue
574+ }
575575
576- var health healthCheckResponse
577- if err := json .Unmarshal (body , & health ); err != nil {
578- time .Sleep (200 * time .Millisecond )
579- continue
580- }
576+ var health healthCheckResponse
577+ if err := json .Unmarshal (body , & health ); err != nil {
578+ time .Sleep (200 * time .Millisecond )
579+ continue
580+ }
581581
582- // Return success when the server has completed setup
583- // READY = setup completed, healthcheck passed (or no healthcheck)
584- // UNHEALTHY = setup completed, but user healthcheck failed
585- // BUSY = setup completed, prediction in progress
586- if health .Status == "READY" || health .Status == "UNHEALTHY" || health .Status == "BUSY" {
587- return true
588- }
582+ // Return success when the server has completed setup
583+ // READY = setup completed, healthcheck passed (or no healthcheck)
584+ // UNHEALTHY = setup completed, but user healthcheck failed
585+ // BUSY = setup completed, prediction in progress
586+ if health .Status == "READY" || health .Status == "UNHEALTHY" || health .Status == "BUSY" {
587+ return true
588+ }
589589
590- // If setup failed, no point waiting
591- if health .Status == "SETUP_FAILED" || health .Status == "DEFUNCT" {
592- return false
593- }
594- } else {
595- _ = resp .Body .Close ()
590+ // If setup failed, no point waiting
591+ if health .Status == "SETUP_FAILED" || health .Status == "DEFUNCT" {
592+ return false
596593 }
597594
598595 time .Sleep (200 * time .Millisecond )
0 commit comments