summaryrefslogtreecommitdiff
path: root/jstests/concurrency/fsm_workloads/convert_to_capped_collection_index.js
blob: 2eaa8e261b236da0abda04f28275a9eeffe7083f (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
/**
 * convert_to_capped_collection_index.js
 *
 * Creates a non-capped collection. Converts it to a
 * capped collection. After each iteration, truncates the
 * collection, ensuring that the storage size of the
 * collection is still a multiple of 256.
 *
 * MongoDB raises the storage size of a capped collection
 * to an integer multiple of 256.
 *
 * Make sure that we can create indexes on any collection
 * but that only the _id index remains after (re-)converting
 * to a capped collection.
 */
load('jstests/concurrency/fsm_libs/extend_workload.js');  // for extendWorkload
load('jstests/concurrency/fsm_workloads/convert_to_capped_collection.js');  // for $config

var $config = extendWorkload(
    $config,
    function($config, $super) {
        $config.states.convertToCapped = function convertToCapped(db, collName) {
            assertWhenOwnDB.commandWorked(db[this.threadCollName].ensureIndex({i: 1, rand: 1}));
            assertWhenOwnDB.eq(2, db[this.threadCollName].getIndexes().length);
            $super.states.convertToCapped.apply(this, arguments);
        };

        return $config;
    });