summaryrefslogtreecommitdiff
path: root/jstests/sharding/internal_txns/retryable_writes_basic.js
blob: 666bf93416a7bda57767f3630166b54af45d743f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
 * Tests that retryable internal transactions for insert, update and delete are retryable and
 * other kinds of transactions for insert, update and delete are not retryable.
 *
 * Exclude this test from large_txn variants because the variant enforces that the max transaction
 * oplog entry length is 2 operations, and the oplog length assertions in this test do not account
 * for this. We are not losing test coverage as this test inherently tests large transactions.
 *
 * @tags: [requires_fcv_60, uses_transactions, exclude_from_large_txns]
 */
(function() {
'use strict';

load("jstests/sharding/internal_txns/libs/retryable_internal_transaction_test.js");

const transactionTest = new RetryableInternalTransactionTest();

{
    jsTest.log("Test that non-internal transactions cannot be retried");
    const makeSessionIdFunc = () => {
        return {id: UUID()};
    };
    const expectRetryToSucceed = false;
    transactionTest.runInsertUpdateDeleteTests(
        {txnOptions: {makeSessionIdFunc}, expectRetryToSucceed});
}

{
    jsTest.log("Test that non-retryable internal transactions cannot be retried");
    const makeSessionIdFunc = () => {
        return {id: UUID(), txnUUID: UUID()};
    };
    const expectRetryToSucceed = false;
    transactionTest.runInsertUpdateDeleteTests(
        {txnOptions: {makeSessionIdFunc}, expectRetryToSucceed});
}

{
    jsTest.log("Test that retryable internal transactions can be retried");
    transactionTest.runTestsForAllRetryableInternalTransactionTypes(
        transactionTest.runInsertUpdateDeleteTests, transactionTest.TestMode.kNonRecovery);
}

{
    jsTest.log("Test multi writes are allowed in non retryable transactions");
    transactionTest.testNonRetryableTxnMultiWrites();
}

{
    jsTest.log(
        "Test multi writes with an initialized statement id are rejected in retryable transactions");
    transactionTest.testRetryableTxnMultiWrites();
}

transactionTest.stop();
})();