'use strict';
load('jstests/concurrency/fsm_workload_helpers/drop_utils.js');
var $config = (function() {
var data = {
prefix: 'system_views_write'
};
var states = (function() {
function init(db, collName) {
this.threadViewName = this.prefix + '_' + this.tid;
this.threadViewNS = db.getName() + '.' + this.threadViewName;
this.collNS1 = db[collName].getFullName();
this.collNS2 = db[collName].getFullName() + "_2";
}
function insert(db, collName) {
const pipeline = [];
assertAlways.writeOK(db.system.views.insert({_id: this.threadViewNS, viewOn: this.collNS1, pipeline: pipeline}));
}
function update(db, collName) {
assertAlways.writeOK(db.system.views.update({_id: this.threadViewNS}, {$set: {viewOn: this.collNS2}}));
}
function remove(db, collName) {
assertAlways.writeOK(db.system.views.remove({_id: this.threadViewNS}));
}
function read(db, collName) {
assertAlways.commandWorked(db.runCommand({find: collName}));
}
return {init: init, insert: insert, update: update, read: read, remove: remove};
})();
var transitions = {
init: {insert: 1},
insert: {update: 0.5, read: 0.5},
update: {remove: 0.5, read: 0.5},
read: {remove: 0.5, read: 0.5},
remove: {insert: 1}
};
function setup(db, collName, cluster) {
const coll = db[collName];
const viewsColl = db["system.views"];
coll.drop();
viewsColl.drop();
}
function teardown(db, collName, cluster) {
var pattern = new RegExp('^system.views$');
dropCollections(db, pattern);
}
return {
threadCount: 10,
iterations: 10000,
data: data,
states: states,
transitions: transitions,
setup: setup,
teardown: teardown
};
})();