Skip to content

Commit 04ee4bf

Browse files
committed
tests/realtikvtest: tolerate next-gen lazy uniqueness conflict reasons
1 parent 8412422 commit 04ee4bf

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

tests/realtikvtest/pessimistictest/pessimistic_test.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2763,7 +2763,7 @@ func TestLazyUniquenessCheck(t *testing.T) {
27632763
if kerneltype.IsClassic() {
27642764
require.ErrorContains(t, err, "reason=LazyUniquenessCheck")
27652765
} else {
2766-
require.ErrorContains(t, err, "reason=NotLockedKeyConflict")
2766+
requireNextGenLazyUniquenessConflictReason(t, err)
27672767
}
27682768

27692769
// case: DML returns error => abort txn
@@ -3090,10 +3090,23 @@ func TestLazyUniquenessCheckWithInconsistentReadResult(t *testing.T) {
30903090
if kerneltype.IsClassic() {
30913091
require.ErrorContains(t, err, "reason=LazyUniquenessCheck")
30923092
} else {
3093-
require.ErrorContains(t, err, "reason=NotLockedKeyConflict")
3093+
requireNextGenLazyUniquenessConflictReason(t, err)
30943094
}
30953095
}
30963096

3097+
// Different next-gen engine families currently surface different write-conflict reasons
3098+
// for lazy uniqueness checks, so the TiDB-side assertion should accept both.
3099+
func requireNextGenLazyUniquenessConflictReason(t *testing.T, err error) {
3100+
t.Helper()
3101+
errMsg := err.Error()
3102+
require.Truef(
3103+
t,
3104+
strings.Contains(errMsg, "reason=LazyUniquenessCheck") || strings.Contains(errMsg, "reason=NotLockedKeyConflict"),
3105+
"expected next-gen lazy uniqueness conflict reason, got %s",
3106+
errMsg,
3107+
)
3108+
}
3109+
30973110
func TestLazyUniquenessCheckWithSavepoint(t *testing.T) {
30983111
store := realtikvtest.CreateMockStoreAndSetup(t)
30993112
tk := testkit.NewTestKit(t, store)

0 commit comments

Comments
 (0)