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
<what was there before: Previously, ...>
This adds a link, with relevant cluster and test timeframe, to the testeng
grafana instance for failed roachtests.
<why it needed to change: This was inadequate because ...>
<what you did about it: To address this, this patch ...>
Fixes: cockroachdb#105894
Release note: None
  • Loading branch information
annrpom committed Jul 24, 2023
1 parent 73f51aa commit b6215f9
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 10 deletions.
31 changes: 21 additions & 10 deletions pkg/cmd/roachtest/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"context"
"fmt"
"os"
"time"

"github.com/cockroachdb/cockroach/pkg/cmd/internal/issues"
"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/registry"
Expand Down Expand Up @@ -46,6 +47,25 @@ func roachtestPrefix(p string) string {
return "ROACHTEST_" + p
}

// TODO(BEFORE MERGING): the 'from' timestamp is zeroed out for now, until I find the correct
// way to get the 'start' time of a roachtest
func generateHelpCommand(g *githubIssues) 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", g.cluster.name, 0, time.Now().Unix()),
)(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 @@ -192,16 +212,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(g),
}
}

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

Expand All @@ -25,6 +26,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 +105,27 @@ func TestShouldPost(t *testing.T) {
}
}

func TestGenerateHelpCommand(t *testing.T) {
vo := vm.DefaultCreateOpts()
vmOpts := &vo

reg := makeTestRegistry(spec.GCE, "", "", false, false)
clusterSpec := reg.MakeClusterSpec(1, spec.Arch("arm64"))
testClusterImpl := &clusterImpl{name: "foo-cluster", spec: clusterSpec, arch: vm.ArchAMD64}

github := &githubIssues{
vmCreateOpts: vmOpts,
cluster: testClusterImpl,
teamLoader: validTeamsFn,
}

r := &issues.Renderer{}
generateHelpCommand(github)(r)

// TODO (BEFORE MERGE): time.Now() in tests == no bueno. could do regex, but want something like utils.TimeNow() that cc has
echotest.Require(t, strings.Replace(r.String(), "\n", "", -1), filepath.Join("testdata", "help_command.txt"))
}

func TestCreatePostRequest(t *testing.T) {
createFailure := func(ref error) failure {
return failure{squashedErr: ref}
Expand Down
3 changes: 3 additions & 0 deletions pkg/cmd/roachtest/testdata/help_command.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
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//0/1689971380)

0 comments on commit b6215f9

Please sign in to comment.