summaryrefslogtreecommitdiff
path: root/jstests/noPassthroughWithMongod/timeseries_list_collections_missing_view.js
blob: 3e1f865918e8efa5a165f9e9c2b5397c52c3bed1 (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
/**
 * Tests that listCollections shows the time-series buckets collection, but not the view, if the
 * time-series view is missing.
 *
 * @tags: [
 *   does_not_support_transactions,
 *   requires_getmore,
 * ]
 */
(function() {
'use strict';

const testDB = db.getSiblingDB(jsTestName());
assert.commandWorked(testDB.dropDatabase());

const timeFieldName = 'time';
const coll = testDB.getCollection('t');

assert.commandWorked(
    testDB.createCollection(coll.getName(), {timeseries: {timeField: timeFieldName}}));

// Users are prohibited from dropping system.views when there are time-series collections present.
// However, this restriction isn't in place on earlier versions and its possible for users to
// upgrade to this version with a dropped system.views collection while having time-series
// collections present. This allows us to continue to test the behaviour of this scenario.
assert.commandWorked(
    testDB.adminCommand({configureFailPoint: "allowSystemViewsDrop", mode: "alwaysOn"}));
assert(testDB.system.views.drop());
assert.commandWorked(
    testDB.adminCommand({configureFailPoint: "allowSystemViewsDrop", mode: "off"}));

const collections = assert.commandWorked(testDB.runCommand({listCollections: 1})).cursor.firstBatch;
jsTestLog('Checking listCollections result: ' + tojson(collections));
assert.eq(collections.length, 1);
assert(collections.find(entry => entry.name === 'system.buckets.' + coll.getName()));
})();