Skip to content

Commit 9c41c48

Browse files
craig[bot]tbg
andcommitted
Merge #96865
96865: kvserver: deflake TestLearnerReplicateQueueRace r=pavelkalinnikov a=tbg It's not a good idea to `t.Fatal` on a goroutine. I verified that the test fails cleanly even when the callback doesn't actually do the removal. Fixes #95130. Epic: none Release note: None Co-authored-by: Tobias Grieger <tobias.b.grieger@gmail.com>
2 parents 3e26d85 + 6bcea7f commit 9c41c48

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

pkg/kv/kvserver/replica_learner_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import (
4646
"github.com/cockroachdb/cockroach/pkg/util/tracing/tracingpb"
4747
"github.com/cockroachdb/cockroach/pkg/util/uuid"
4848
"github.com/cockroachdb/errors"
49+
"github.com/stretchr/testify/assert"
4950
"github.com/stretchr/testify/require"
5051
"golang.org/x/sync/errgroup"
5152
)
@@ -1269,9 +1270,10 @@ func TestLearnerReplicateQueueRace(t *testing.T) {
12691270
// leaving the 2 voters.
12701271
startKey := tc.ScratchRange(t)
12711272
desc, err := tc.RemoveVoters(startKey, tc.Target(2))
1272-
require.NoError(t, err)
1273-
require.Len(t, desc.Replicas().VoterDescriptors(), 2)
1274-
require.Len(t, desc.Replicas().LearnerDescriptors(), 0)
1273+
// NB: don't fatal on this goroutine, as we can't recover cleanly.
1274+
assert.NoError(t, err)
1275+
assert.Len(t, desc.Replicas().VoterDescriptors(), 2)
1276+
assert.Len(t, desc.Replicas().LearnerDescriptors(), 0)
12751277
return false
12761278
}
12771279
tc = testcluster.StartTestCluster(t, 3, base.TestClusterArgs{
@@ -1300,10 +1302,8 @@ func TestLearnerReplicateQueueRace(t *testing.T) {
13001302
if err != nil {
13011303
return err
13021304
}
1303-
if !strings.Contains(processErr.Error(), `descriptor changed`) {
1304-
// NB: errors.Wrapf(nil, ...) returns nil.
1305-
// nolint:errwrap
1306-
return errors.Errorf(`expected "descriptor changed" error got: %+v`, processErr)
1305+
if processErr == nil || !strings.Contains(processErr.Error(), `descriptor changed`) {
1306+
return errors.Wrap(processErr, `expected "descriptor changed" error got: %+v`)
13071307
}
13081308
formattedTrace := trace.String()
13091309
expectedMessages := []string{

0 commit comments

Comments
 (0)