Skip to content

Commit 89c8d02

Browse files
committed
changefeedccl: deflake TestChangefeedRandomExpressions
This PR uses strings instead of pgcodes to determine what kinds of errors to ignore if the changefeed fails in TestChangefeedRandomExpressions. This is necessary because the error is scraped from the changefeed job failure error, so it does not contain the original pgcode. In the future, we may consider including pgcodes in the changefeed job error. Epic: none Fixes: #138325 Fixes: #137986 Fixes: #137978 Fixes: #137974 Fixes: #137824 Release note: none
1 parent 4fe1d00 commit 89c8d02

File tree

1 file changed

+28
-9
lines changed

1 file changed

+28
-9
lines changed

pkg/ccl/changefeedccl/changefeed_test.go

+28-9
Original file line numberDiff line numberDiff line change
@@ -1302,21 +1302,40 @@ func TestChangefeedRandomExpressions(t *testing.T) {
13021302
err = assertPayloadsBaseErr(context.Background(), seedFeed, assertedPayloads, false, false)
13031303
closeFeedIgnoreError(t, seedFeed)
13041304
if err != nil {
1305-
code := pgerror.GetPGCode(err)
13061305
// Skip errors that may come up during SQL execution. If the SQL query
13071306
// didn't fail with these errors, it's likely because the query was built in
13081307
// a way that did not have to execute on the row that caused the error, but
13091308
// the CDC query did.
1310-
switch code {
1311-
case pgcode.ConfigFile,
1312-
pgcode.DatetimeFieldOverflow,
1313-
pgcode.InvalidEscapeCharacter,
1314-
pgcode.InvalidEscapeSequence,
1315-
pgcode.InvalidParameterValue,
1316-
pgcode.InvalidRegularExpression:
1317-
t.Logf("Skipping statement %s because it encountered pgerror %s: %s", createStmt, code, err)
1309+
// Since we get the error that caused the changefeed job to
1310+
// fail from scraping the job status and creating a new
1311+
// error, we unfortunately don't have the pgcode and have to
1312+
// rely on known strings.
1313+
validPgErrs := []string{
1314+
"cannot subtract infinite dates",
1315+
"regexp compilation failed",
1316+
"invalid regular expression",
1317+
"error parsing GeoJSON",
1318+
"error parsing EWKT",
1319+
"geometry type is unsupported",
1320+
"should be of length",
1321+
"dwithin distance cannot be less than zero",
1322+
"parameter has to be of type Point",
1323+
"expected LineString",
1324+
"no locations to init GEOS",
1325+
}
1326+
containsKnownPgErr := func(e error) (interface{}, bool) {
1327+
for _, v := range validPgErrs {
1328+
if strings.Contains(e.Error(), v) {
1329+
return nil, true
1330+
}
1331+
}
1332+
return nil, false
1333+
}
1334+
if _, contains := errors.If(err, containsKnownPgErr); contains {
1335+
t.Logf("Skipping statement %s because it encountered pgerror %s", createStmt, err)
13181336
continue
13191337
}
1338+
13201339
t.Fatal(err)
13211340
}
13221341
numNonTrivialTestRuns++

0 commit comments

Comments
 (0)