Skip to content

Commit 07926df

Browse files
committed
roachtest: improve flake detection for typeorm test
Release note: None
1 parent f6c4d9d commit 07926df

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

pkg/cmd/roachtest/tests/typeorm.go

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"context"
1515
"fmt"
1616
"regexp"
17+
"strconv"
1718
"strings"
1819

1920
"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/cluster"
@@ -166,12 +167,27 @@ func registerTypeORM(r registry.Registry) {
166167
rawResults := result.Stdout + result.Stderr
167168
t.L().Printf("Test Results: %s", rawResults)
168169
if err != nil {
170+
// We don't have a good way of parsing test results from javascript, so we
171+
// use substring matching and regexp instead of using a blocklist like
172+
// we use for other ORM tests.
173+
numFailingRegex := regexp.MustCompile(`(\d+) failing`)
174+
matches := numFailingRegex.FindStringSubmatch(rawResults)
175+
numFailing, convErr := strconv.Atoi(matches[1])
176+
if convErr != nil {
177+
t.Fatal(convErr)
178+
}
179+
180+
// One test is known to flake during setup.
181+
if strings.Contains(rawResults, `"before each" hook for "should select specific columns":`) {
182+
numFailing -= 1
183+
}
184+
185+
// Tests are allowed to flake due to transaction retry errors.
169186
txnRetryErrCount := strings.Count(rawResults, "restart transaction")
170-
if strings.Contains(rawResults, "1 failing") && txnRetryErrCount == 1 {
171-
err = nil
172-
} else if strings.Contains(rawResults, "2 failing") && txnRetryErrCount == 2 {
187+
if numFailing == txnRetryErrCount {
173188
err = nil
174189
}
190+
175191
if err != nil {
176192
t.Fatal(err)
177193
}

0 commit comments

Comments
 (0)