summaryrefslogtreecommitdiff
path: root/src/mongo/db/error_labels_test.cpp
diff options
context:
space:
mode:
authorAndrew Shuvalov <andrew.shuvalov@mongodb.com>2020-12-10 17:47:15 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-12-16 23:08:42 +0000
commitd5743ba8411a50534d33bc2e940377fb003dccea (patch)
tree27a3c8d0d84d192b300cb908b765668fd73cef04 /src/mongo/db/error_labels_test.cpp
parent97a76a9bab552e35e9bc3249d33a4c82ff354fee (diff)
downloadmongo-d5743ba8411a50534d33bc2e940377fb003dccea.tar.gz
SERVER-52947: Tenant migration donor should attach TransientTransactionError when returning TenantMigrationCommitted or TenantMigrationAborted on a transaction operation
Diffstat (limited to 'src/mongo/db/error_labels_test.cpp')
-rw-r--r--src/mongo/db/error_labels_test.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/mongo/db/error_labels_test.cpp b/src/mongo/db/error_labels_test.cpp
index a9d4cc27f0c..2bf321fab1c 100644
--- a/src/mongo/db/error_labels_test.cpp
+++ b/src/mongo/db/error_labels_test.cpp
@@ -39,6 +39,45 @@
namespace mongo {
namespace {
+TEST(IsTransientTransactionErrorTest, WriteConflictIsTransient) {
+ ASSERT_TRUE(isTransientTransactionError(
+ ErrorCodes::WriteConflict, false /* hasWriteConcernError */, false /* isCommitOrAbort */));
+}
+
+TEST(IsTransientTransactionErrorTest, LockTimeoutIsTransient) {
+ ASSERT_TRUE(isTransientTransactionError(
+ ErrorCodes::LockTimeout, false /* hasWriteConcernError */, false /* isCommitOrAbort */));
+}
+
+TEST(IsTransientTransactionErrorTest, PreparedTransactionInProgressIsTransient) {
+ ASSERT_TRUE(isTransientTransactionError(ErrorCodes::PreparedTransactionInProgress,
+ false /* hasWriteConcernError */,
+ false /* isCommitOrAbort */));
+}
+
+TEST(IsTransientTransactionErrorTest, TenantMigrationCommittedIsTransient) {
+ ASSERT_TRUE(isTransientTransactionError(ErrorCodes::TenantMigrationCommitted,
+ false /* hasWriteConcernError */,
+ false /* isCommitOrAbort */));
+}
+
+TEST(IsTransientTransactionErrorTest, TenantMigrationAbortedIsTransient) {
+ ASSERT_TRUE(isTransientTransactionError(ErrorCodes::TenantMigrationAborted,
+ false /* hasWriteConcernError */,
+ false /* isCommitOrAbort */));
+}
+
+TEST(IsTransientTransactionErrorTest, ShardInvalidatedForTargetingIsTransient) {
+ ASSERT_TRUE(isTransientTransactionError(ErrorCodes::ShardInvalidatedForTargeting,
+ false /* hasWriteConcernError */,
+ false /* isCommitOrAbort */));
+}
+
+TEST(IsTransientTransactionErrorTest, StaleDbVersionIsTransient) {
+ ASSERT_TRUE(isTransientTransactionError(
+ ErrorCodes::StaleDbVersion, false /* hasWriteConcernError */, false /* isCommitOrAbort */));
+}
+
TEST(IsTransientTransactionErrorTest, NetworkErrorsAreTransientBeforeCommit) {
ASSERT_TRUE(isTransientTransactionError(ErrorCodes::HostUnreachable,
false /* hasWriteConcernError */,