summaryrefslogtreecommitdiff
path: root/jstests/core/txns/timeseries_create_in_txn.js
blob: 550bfbca3e438b09ae40883a707fa20203f1cc9b (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
/**
 * Tests that it is illegal to create a time-series collection within a transaction.
 * @tags: [
 *     uses_transactions,
 *     requires_fcv_49,
 * ]
 */
(function() {
"use strict";

load("jstests/core/timeseries/libs/timeseries.js");

if (!TimeseriesTest.timeseriesCollectionsEnabled(db.getMongo())) {
    jsTestLog("Skipping test because the time-series collection feature flag is disabled");
    return;
}

const session = db.getMongo().startSession();
// Use a custom database, to avoid conflict with other tests that use the system.js collection.
session.startTransaction();
const sessionDB = session.getDatabase('test');
assert.commandFailedWithCode(
    sessionDB.createCollection('timeseries_create_in_txn', {timeseries: {timeField: 'time'}}),
    ErrorCodes.OperationNotSupportedInTransaction);
assert.commandFailedWithCode(session.abortTransaction_forTesting(), ErrorCodes.NoSuchTransaction);
})();