Skip to content

Commit

Permalink
api: Log errors when executing setup and teardown
Browse files Browse the repository at this point in the history
This commit adds error logging when executing the setup and teardown
functions in the k6 API. If an error occurs during setup or teardown, it
will now be logged with the corresponding error message. This improves
error reporting and makes it easier to diagnose issues related to setup
and teardown.

Related issue: #2422
  • Loading branch information
kmtym1998 authored and olegbespalov committed Aug 24, 2023
1 parent 6556342 commit d8ebbd3
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions api/v1/setup_teardown_routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ func handleRunSetup(cs *ControlSurface, rw http.ResponseWriter, r *http.Request)
runner := cs.RunState.Runner

if err := cs.RunState.Runner.Setup(r.Context(), cs.Samples); err != nil {
cs.RunState.Logger.WithError(err).Error("Error executing setup")
apiError(rw, "Error executing setup", err.Error(), http.StatusInternalServerError)
return
}
Expand All @@ -81,6 +82,7 @@ func handleRunSetup(cs *ControlSurface, rw http.ResponseWriter, r *http.Request)
// handleRunTeardown executes the runner's Teardown() method
func handleRunTeardown(cs *ControlSurface, rw http.ResponseWriter, r *http.Request) {
if err := cs.RunState.Runner.Teardown(r.Context(), cs.Samples); err != nil {
cs.RunState.Logger.WithError(err).Error("Error executing teardown")
apiError(rw, "Error executing teardown", err.Error(), http.StatusInternalServerError)
}
}

0 comments on commit d8ebbd3

Please sign in to comment.