File: convert_to_capped_collection_index.js

package info (click to toggle)
mongodb 1%3A3.2.11-2%2Bdeb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 196,404 kB
  • sloc: cpp: 1,412,793; ansic: 504,961; python: 78,522; perl: 5,837; sh: 5,661; java: 4,202; makefile: 1,784; pascal: 617; xml: 176; asm: 128
file content (29 lines) | stat: -rw-r--r-- 1,136 bytes parent folder | download
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;
    });