Skip to content

Commit

Permalink
roachtest: bugfix testeng grafana link missing cluster name
Browse files Browse the repository at this point in the history
Previously, the testeng grafana link generated after a roachtest
failure directed the user to cockroachlabs.com due to a missing cluster
name from the link. This patch should fix this issue by getting the cluster
name from a `*githubIssues.cluster.name` instead of the `clusterName`
from roachtest/cluster.go.

Fixes: #107894

Release note (bug fix): The link to testeng grafana that is generated
on a roachtest failure should now properly direct to grafana.
  • Loading branch information
annrpom committed Aug 2, 2023
1 parent e57e974 commit abd1e0d
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 8 deletions.
15 changes: 10 additions & 5 deletions pkg/cmd/roachtest/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,13 @@ func generateHelpCommand(
"How To Investigate (internal)",
"https://cockroachlabs.atlassian.net/l/c/SSSBr8c7",
)(renderer)
issues.HelpCommandAsLink(
"Grafana",
fmt.Sprintf("https://go.crdb.dev/p/roachfana/%s/%d/%d", clusterName, start.UnixMilli(), end.UnixMilli()),
)(renderer)
// An empty clusterName corresponds to a cluster creation failure
if clusterName != "" {
issues.HelpCommandAsLink(
"Grafana",
fmt.Sprintf("https://go.crdb.dev/p/roachfana/%s/%d/%d", clusterName, start.UnixMilli(), end.UnixMilli()),
)(renderer)
}
}
}

Expand Down Expand Up @@ -131,6 +134,7 @@ func (g *githubIssues) createPostRequest(

issueOwner := spec.Owner
issueName := testName
issueClusterName := ""

messagePrefix := ""
var infraFlake bool
Expand Down Expand Up @@ -202,6 +206,7 @@ func (g *githubIssues) createPostRequest(
// Hence, we only emit when arch was unspecified.
clusterParams[roachtestPrefix("arch")] = string(g.cluster.arch)
}
issueClusterName = g.cluster.name
}

issueMessage := messagePrefix + message
Expand All @@ -218,7 +223,7 @@ func (g *githubIssues) createPostRequest(
Artifacts: artifacts,
ExtraLabels: labels,
ExtraParams: clusterParams,
HelpCommand: generateHelpCommand(clusterName, start, end),
HelpCommand: generateHelpCommand(issueClusterName, start, end),
}, nil
}

Expand Down
13 changes: 10 additions & 3 deletions pkg/cmd/roachtest/github_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,13 @@ func TestCreatePostRequest(t *testing.T) {
}

ti := &testImpl{
spec: testSpec,
l: nilLogger(),
spec: testSpec,
l: nilLogger(),
start: time.Date(2023, time.July, 21, 16, 34, 3, 817, time.UTC),
end: time.Date(2023, time.July, 21, 16, 42, 13, 137, time.UTC),
}

testClusterImpl := &clusterImpl{spec: clusterSpec, arch: vm.ArchAMD64}
testClusterImpl := &clusterImpl{spec: clusterSpec, arch: vm.ArchAMD64, name: "foo"}
vo := vm.DefaultCreateOpts()
vmOpts := &vo

Expand Down Expand Up @@ -220,6 +222,11 @@ func TestCreatePostRequest(t *testing.T) {
req, err := github.createPostRequest("github_test", ti.start, ti.end, testSpec, c.failure, "message")
assert.NoError(t, err, "Expected no error in createPostRequest")

r := &issues.Renderer{}
req.HelpCommand(r)
file := fmt.Sprintf("help_command_createpost_%d.txt", idx+1)
echotest.Require(t, r.String(), filepath.Join("testdata", file))

if c.expectedParams != nil {
require.Equal(t, c.expectedParams, req.ExtraParams)
}
Expand Down
17 changes: 17 additions & 0 deletions pkg/cmd/roachtest/testdata/help_command_createpost_1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
echo
----
----


See: [roachtest README](https://github.com/cockroachdb/cockroach/blob/master/pkg/cmd/roachtest/README.md)



See: [How To Investigate \(internal\)](https://cockroachlabs.atlassian.net/l/c/SSSBr8c7)



See: [Grafana](https://go.crdb.dev/p/roachfana/foo/1689957243000/1689957733000)

----
----
17 changes: 17 additions & 0 deletions pkg/cmd/roachtest/testdata/help_command_createpost_2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
echo
----
----


See: [roachtest README](https://github.com/cockroachdb/cockroach/blob/master/pkg/cmd/roachtest/README.md)



See: [How To Investigate \(internal\)](https://cockroachlabs.atlassian.net/l/c/SSSBr8c7)



See: [Grafana](https://go.crdb.dev/p/roachfana/foo/1689957243000/1689957733000)

----
----
13 changes: 13 additions & 0 deletions pkg/cmd/roachtest/testdata/help_command_createpost_3.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
echo
----
----


See: [roachtest README](https://github.com/cockroachdb/cockroach/blob/master/pkg/cmd/roachtest/README.md)



See: [How To Investigate \(internal\)](https://cockroachlabs.atlassian.net/l/c/SSSBr8c7)

----
----
17 changes: 17 additions & 0 deletions pkg/cmd/roachtest/testdata/help_command_createpost_5.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
echo
----
----


See: [roachtest README](https://github.com/cockroachdb/cockroach/blob/master/pkg/cmd/roachtest/README.md)



See: [How To Investigate \(internal\)](https://cockroachlabs.atlassian.net/l/c/SSSBr8c7)



See: [Grafana](https://go.crdb.dev/p/roachfana/foo/1689957243000/1689957733000)

----
----

0 comments on commit abd1e0d

Please sign in to comment.