Skip to content

Commit abd1e0d

Browse files
committed
roachtest: bugfix testeng grafana link missing cluster name
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: cockroachdb#107894 Release note (bug fix): The link to testeng grafana that is generated on a roachtest failure should now properly direct to grafana.
1 parent e57e974 commit abd1e0d

File tree

6 files changed

+84
-8
lines changed

6 files changed

+84
-8
lines changed

pkg/cmd/roachtest/github.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,13 @@ func generateHelpCommand(
6060
"How To Investigate (internal)",
6161
"https://cockroachlabs.atlassian.net/l/c/SSSBr8c7",
6262
)(renderer)
63-
issues.HelpCommandAsLink(
64-
"Grafana",
65-
fmt.Sprintf("https://go.crdb.dev/p/roachfana/%s/%d/%d", clusterName, start.UnixMilli(), end.UnixMilli()),
66-
)(renderer)
63+
// An empty clusterName corresponds to a cluster creation failure
64+
if clusterName != "" {
65+
issues.HelpCommandAsLink(
66+
"Grafana",
67+
fmt.Sprintf("https://go.crdb.dev/p/roachfana/%s/%d/%d", clusterName, start.UnixMilli(), end.UnixMilli()),
68+
)(renderer)
69+
}
6770
}
6871
}
6972

@@ -131,6 +134,7 @@ func (g *githubIssues) createPostRequest(
131134

132135
issueOwner := spec.Owner
133136
issueName := testName
137+
issueClusterName := ""
134138

135139
messagePrefix := ""
136140
var infraFlake bool
@@ -202,6 +206,7 @@ func (g *githubIssues) createPostRequest(
202206
// Hence, we only emit when arch was unspecified.
203207
clusterParams[roachtestPrefix("arch")] = string(g.cluster.arch)
204208
}
209+
issueClusterName = g.cluster.name
205210
}
206211

207212
issueMessage := messagePrefix + message
@@ -218,7 +223,7 @@ func (g *githubIssues) createPostRequest(
218223
Artifacts: artifacts,
219224
ExtraLabels: labels,
220225
ExtraParams: clusterParams,
221-
HelpCommand: generateHelpCommand(clusterName, start, end),
226+
HelpCommand: generateHelpCommand(issueClusterName, start, end),
222227
}, nil
223228
}
224229

pkg/cmd/roachtest/github_test.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,11 +184,13 @@ func TestCreatePostRequest(t *testing.T) {
184184
}
185185

186186
ti := &testImpl{
187-
spec: testSpec,
188-
l: nilLogger(),
187+
spec: testSpec,
188+
l: nilLogger(),
189+
start: time.Date(2023, time.July, 21, 16, 34, 3, 817, time.UTC),
190+
end: time.Date(2023, time.July, 21, 16, 42, 13, 137, time.UTC),
189191
}
190192

191-
testClusterImpl := &clusterImpl{spec: clusterSpec, arch: vm.ArchAMD64}
193+
testClusterImpl := &clusterImpl{spec: clusterSpec, arch: vm.ArchAMD64, name: "foo"}
192194
vo := vm.DefaultCreateOpts()
193195
vmOpts := &vo
194196

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

225+
r := &issues.Renderer{}
226+
req.HelpCommand(r)
227+
file := fmt.Sprintf("help_command_createpost_%d.txt", idx+1)
228+
echotest.Require(t, r.String(), filepath.Join("testdata", file))
229+
223230
if c.expectedParams != nil {
224231
require.Equal(t, c.expectedParams, req.ExtraParams)
225232
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
echo
2+
----
3+
----
4+
5+
6+
See: [roachtest README](https://github.com/cockroachdb/cockroach/blob/master/pkg/cmd/roachtest/README.md)
7+
8+
9+
10+
See: [How To Investigate \(internal\)](https://cockroachlabs.atlassian.net/l/c/SSSBr8c7)
11+
12+
13+
14+
See: [Grafana](https://go.crdb.dev/p/roachfana/foo/1689957243000/1689957733000)
15+
16+
----
17+
----
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
echo
2+
----
3+
----
4+
5+
6+
See: [roachtest README](https://github.com/cockroachdb/cockroach/blob/master/pkg/cmd/roachtest/README.md)
7+
8+
9+
10+
See: [How To Investigate \(internal\)](https://cockroachlabs.atlassian.net/l/c/SSSBr8c7)
11+
12+
13+
14+
See: [Grafana](https://go.crdb.dev/p/roachfana/foo/1689957243000/1689957733000)
15+
16+
----
17+
----
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
echo
2+
----
3+
----
4+
5+
6+
See: [roachtest README](https://github.com/cockroachdb/cockroach/blob/master/pkg/cmd/roachtest/README.md)
7+
8+
9+
10+
See: [How To Investigate \(internal\)](https://cockroachlabs.atlassian.net/l/c/SSSBr8c7)
11+
12+
----
13+
----
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
echo
2+
----
3+
----
4+
5+
6+
See: [roachtest README](https://github.com/cockroachdb/cockroach/blob/master/pkg/cmd/roachtest/README.md)
7+
8+
9+
10+
See: [How To Investigate \(internal\)](https://cockroachlabs.atlassian.net/l/c/SSSBr8c7)
11+
12+
13+
14+
See: [Grafana](https://go.crdb.dev/p/roachfana/foo/1689957243000/1689957733000)
15+
16+
----
17+
----

0 commit comments

Comments
 (0)