Skip to content

Commit

Permalink
roachtest: include link to testeng grafana in issue posts
Browse files Browse the repository at this point in the history
This adds a link, populated with relevant cluster name and test timeframe,
to the testeng grafana instance for failed roachtests.

Fixes: cockroachdb#105894
Release note: None
  • Loading branch information
annrpom committed Jul 26, 2023
1 parent 9e9a66f commit 7f37edf
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 10 deletions.
2 changes: 2 additions & 0 deletions pkg/cmd/roachtest/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ go_test(
"test_test.go",
],
args = ["-test.timeout=55s"],
data = glob(["testdata/**"]),
embed = [":roachtest_lib"],
deps = [
"//pkg/cmd/internal/issues",
Expand All @@ -90,6 +91,7 @@ go_test(
"//pkg/roachprod/logger",
"//pkg/roachprod/vm",
"//pkg/testutils",
"//pkg/testutils/echotest",
"//pkg/util/quotapool",
"//pkg/util/stop",
"//pkg/util/syncutil",
Expand Down
31 changes: 21 additions & 10 deletions pkg/cmd/roachtest/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,26 @@ func roachtestPrefix(p string) string {
return "ROACHTEST_" + p
}

// generateHelpCommand creates a HelpCommand for createPostRequest
func generateHelpCommand(
clusterName string, start time.Time, end time.Time,
) func(renderer *issues.Renderer) {
return func(renderer *issues.Renderer) {
issues.HelpCommandAsLink(
"roachtest README",
"https://github.com/cockroachdb/cockroach/blob/master/pkg/cmd/roachtest/README.md",
)(renderer)
issues.HelpCommandAsLink(
"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.Unix()*1000, end.Unix()*1000),
)(renderer)
}
}

// postIssueCondition encapsulates a condition that causes issue
// posting to be skipped. The `reason` field contains a textual
// description as to why issue posting was skipped.
Expand Down Expand Up @@ -197,16 +217,7 @@ func (g *githubIssues) createPostRequest(
Artifacts: artifacts,
ExtraLabels: labels,
ExtraParams: clusterParams,
HelpCommand: func(renderer *issues.Renderer) {
issues.HelpCommandAsLink(
"roachtest README",
"https://github.com/cockroachdb/cockroach/blob/master/pkg/cmd/roachtest/README.md",
)(renderer)
issues.HelpCommandAsLink(
"How To Investigate (internal)",
"https://cockroachlabs.atlassian.net/l/c/SSSBr8c7",
)(renderer)
},
HelpCommand: generateHelpCommand(clusterName, start, end),
}, nil
}

Expand Down
13 changes: 13 additions & 0 deletions pkg/cmd/roachtest/github_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ import (
"context"
"errors"
"fmt"
"path/filepath"
"strings"
"testing"
"time"

"github.com/cockroachdb/cockroach/pkg/cmd/internal/issues"
"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/cluster"
Expand All @@ -25,6 +27,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/internal/team"
rperrors "github.com/cockroachdb/cockroach/pkg/roachprod/errors"
"github.com/cockroachdb/cockroach/pkg/roachprod/vm"
"github.com/cockroachdb/cockroach/pkg/testutils/echotest"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
Expand Down Expand Up @@ -103,6 +106,16 @@ func TestShouldPost(t *testing.T) {
}
}

func TestGenerateHelpCommand(t *testing.T) {
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)

r := &issues.Renderer{}
generateHelpCommand("foo-cluster", start, end)(r)

echotest.Require(t, r.String(), filepath.Join("testdata", "help_command.txt"))
}

func TestCreatePostRequest(t *testing.T) {
createFailure := func(ref error) failure {
return failure{squashedErr: ref}
Expand Down
17 changes: 17 additions & 0 deletions pkg/cmd/roachtest/testdata/help_command.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-cluster/1689957243000/1689957733000)

----
----

0 comments on commit 7f37edf

Please sign in to comment.