Skip to content
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

roachtest: log queried URL in HealthStatus #141414

Merged
merged 1 commit into from
Feb 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
10 changes: 7 additions & 3 deletions pkg/cmd/roachtest/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -1501,14 +1501,18 @@ func selectedNodesOrDefault(

type HealthStatusResult struct {
Node int
URL string
Status int
Body []byte
Err error
}

func newHealthStatusResult(node int, status int, body []byte, err error) *HealthStatusResult {
func newHealthStatusResult(
node int, url string, status int, body []byte, err error,
) *HealthStatusResult {
return &HealthStatusResult{
Node: node,
URL: url,
Status: status,
Body: body,
Err: err,
Expand Down Expand Up @@ -1538,13 +1542,13 @@ func (c *clusterImpl) HealthStatus(
url := fmt.Sprintf(`%s://%s/health?ready=1`, protocol, adminAddrs[nodeIndex])
resp, err := client.Get(ctx, url)
if err != nil {
return newHealthStatusResult(node, 0, nil, err)
return newHealthStatusResult(node, url, 0, nil, err)
}

defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)

return newHealthStatusResult(node, resp.StatusCode, body, err)
return newHealthStatusResult(node, url, resp.StatusCode, body, err)
}

results := make([]*HealthStatusResult, nodeCount)
Expand Down
6 changes: 3 additions & 3 deletions pkg/cmd/roachtest/test_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -1494,19 +1494,19 @@ func (r *testRunner) postTestAssertions(
validationNode := 0
for _, s := range statuses {
if s.Err != nil {
t.L().Printf("n%d:/health?ready=1 error=%s", s.Node, s.Err)
t.L().Printf("n%d: %s error=%s", s.Node, s.URL, s.Err)
continue
}

if s.Status != http.StatusOK {
t.L().Printf("n%d:/health?ready=1 status=%d body=%s", s.Node, s.Status, s.Body)
t.L().Printf("n%d: %s status=%d body=%s", s.Node, s.URL, s.Status, s.Body)
continue
}

if validationNode == 0 {
validationNode = s.Node // NB: s.Node is never zero
}
t.L().Printf("n%d:/health?ready=1 status=200 ok", s.Node)
t.L().Printf("n%d: %s status=200 ok", s.Node, s.URL)
}

// We avoid trying to do this when t.Failed() (and in particular when there
Expand Down