Skip to content

sql, storage: use error predicates to test the GC threshold error #38128

@knz

Description

@knz

Requested by @andreimatei in #38127 (comment)

the following code bits test this roachpb error using a string comparison:

pkg/ccl/changefeedccl/changefeed_test.go:               // Verify that, at some point, Next() returns a "must be after replica GC
pkg/ccl/changefeedccl/changefeed_test.go:                       if testutils.IsError(err, `must be after replica GC threshold`) {
pkg/ccl/storageccl/export.go:                   return result.Result{}, errors.Errorf("start timestamp %v must be after replica GC threshold %v", args.StartTime, gcThreshold)
pkg/ccl/storageccl/export_test.go:      if !testutils.IsPError(pErr, "must be after replica GC threshold") {
pkg/ccl/storageccl/export_test.go:              t.Fatalf(`expected "must be after replica GC threshold" error got: %+v`, pErr)
pkg/roachpb/errors.go:  return fmt.Sprintf("batch timestamp %v must be after replica GC threshold %v", e.Timestamp, e.Threshold)
pkg/sql/create_stats_test.go:                   if !testutils.IsError(err, "batch timestamp .* must be after replica GC threshold") {
pkg/sql/schema_changer.go:              if strings.Contains(err.Error(), "must be after replica GC threshold") {
pkg/storage/replica_rangefeed_test.go:                          pErr, `must be after replica GC threshold`,
pkg/storage/replica_test.go:    }, &gArgs); !testutils.IsPError(pErr, `batch timestamp 0.\d+,\d+ must be after replica GC threshold 0.\d+,\d+`) {
pkg/storage/replica_test.go:    }, &cpArgs); !testutils.IsPError(pErr, `batch timestamp 0.\d+,\d+ must be after replica GC threshold 0.\d+,\d+`) {

Instead they should be changed to use errors.Is() or similar.

This needs to be gated by a cluster version check.

Jira issue: CRDB-5650

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-error-handlingError messages, error propagations/annotationsC-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.T-kvKV Teamno-issue-activity

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions