Skip to content

Commit

Permalink
ccl/backupccl: skip TestBackupRestorePartitioned under race
Browse files Browse the repository at this point in the history
Refs: cockroachdb#50984

Reason: flaky test

Generated by bin/skip-test.

Release justification: non-production code changes

Release note: None
  • Loading branch information
rytaft committed Oct 22, 2020
1 parent ee2e28d commit f179fd2
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 6 deletions.
1 change: 1 addition & 0 deletions pkg/ccl/backupccl/backup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ func TestBackupRestoreMultiNodeRemote(t *testing.T) {

func TestBackupRestorePartitioned(t *testing.T) {
defer leaktest.AfterTest(t)()
skip.UnderRaceWithIssue(t, 50984, "flaky test")
defer log.Scope(t).Close(t)

const numAccounts = 1000
Expand Down
28 changes: 22 additions & 6 deletions pkg/cmd/skip-test/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ var flagReason = flag.String(
"flaky test",
"reason to put under skip.",
)
var flagUnderRace = flag.Bool(
"under_race",
false,
"if true, only skip under race",
)

func main() {
flag.Parse()
Expand Down Expand Up @@ -126,7 +131,11 @@ func main() {
if err := spawn("git", "add", fileName); err != nil {
log.Fatal(errors.Wrapf(err, "failed to add %s to commit", fileName))
}
commitMsg := fmt.Sprintf(`%s: skip %s
var underRaceStr string
if *flagUnderRace {
underRaceStr = " under race"
}
commitMsg := fmt.Sprintf(`%s: skip %s%s
Refs: #%d
Expand All @@ -137,7 +146,7 @@ Generated by bin/skip-test.
Release justification: non-production code changes
Release note: None
`, pkgPrefix, testName, issueNum, *flagReason)
`, pkgPrefix, testName, underRaceStr, issueNum, *flagReason)
if err := spawn("git", "commit", "-m", commitMsg); err != nil {
log.Fatal(errors.Wrapf(err, "failed to commit %s", fileName))
}
Expand Down Expand Up @@ -194,10 +203,17 @@ func replaceFile(fileName, testName string, issueNum int) {
[]string{},
lines[:insertLineIdx]...,
)
newLines = append(
newLines,
fmt.Sprintf(`skip.WithIssue(t, %d, "%s")`, issueNum, *flagReason),
)
if *flagUnderRace {
newLines = append(
newLines,
fmt.Sprintf(`skip.UnderRaceWithIssue(t, %d, "%s")`, issueNum, *flagReason),
)
} else {
newLines = append(
newLines,
fmt.Sprintf(`skip.WithIssue(t, %d, "%s")`, issueNum, *flagReason),
)
}
newLines = append(
newLines,
lines[insertLineIdx:]...,
Expand Down
10 changes: 10 additions & 0 deletions pkg/testutils/skip/skip.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@ func UnderRace(t SkippableTest, args ...interface{}) {
}
}

// UnderRaceWithIssue skips this test if the race detector is enabled,
// logging the given issue ID as the reason.
func UnderRaceWithIssue(t SkippableTest, githubIssueID int, args ...interface{}) {
if util.RaceEnabled {
t.Skip(append([]interface{}{fmt.Sprintf(
"disabled under race. issue: https://github.com/cockroachdb/cockroach/issue/%d", githubIssueID,
)}, args...))
}
}

// UnderShort skips this test if the -short flag is specified.
func UnderShort(t SkippableTest, args ...interface{}) {
if testing.Short() {
Expand Down

0 comments on commit f179fd2

Please sign in to comment.