0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-21 20:49:10 +01:00
mongodb/jstests/core/storefunc.js
Adam Farkas c5dfc52a57 SERVER-90895 Do not run tests using system.js in suite that performs random moveCollection (#23190)
GitOrigin-RevId: d60c5dbdb732db43738c24ff4f50ebec192e75ea
2024-06-11 15:22:15 +00:00

45 lines
1.7 KiB
JavaScript

// @tags: [
// requires_fcv_61,
// requires_non_retryable_commands,
// requires_non_retryable_writes,
// # system.js stored functions only work for collections that live on the db-primary shard so
// # we have to make sure it wont be moved anywhere by the balancer
// assumes_balancer_off,
// ]
// Use a private sister database to avoid conflicts with other tests that use system.js
const testdb = db.getSiblingDB("storefunc");
let res;
const s = testdb.getCollection("system.js");
assert.commandWorked(s.remove({}));
assert.eq(0, s.countDocuments({}));
assert.commandWorked(s.insert({_id: "x", value: "3"}));
assert.eq(1, s.countDocuments({}));
assert.commandWorked(s.remove({_id: "x"}));
assert.eq(0, s.countDocuments({}));
assert.commandWorked(s.insert({_id: "x", value: "4"}));
assert.eq(1, s.countDocuments({}));
assert.eq(4, s.findOne({_id: "x"}).value, "E2 ");
assert.eq(4, s.findOne().value, "setup - F");
assert.commandWorked(s.update({_id: "x"}, {$set: {value: 5}}));
assert.eq(1, s.countDocuments({}));
assert.eq(5, s.findOne().value, "setup - H");
assert.commandWorked(s.update({_id: "x"}, {$set: {value: 6}}));
assert.eq(1, s.countDocuments({}));
assert.eq(6, s.findOne().value, "setup - B");
assert(s.getIndexKeys().length > 0, "no indexes");
assert(s.getIndexKeys()[0]._id, "no _id index");
// Renaming from system.js to another system namespace is an existing
// check handled by both the access control system and command namespace checking.
assert.commandFailedWithCode(s.renameCollection('system.js_old'),
[ErrorCodes.IllegalOperation, ErrorCodes.Unauthorized]);
assert.commandFailedWithCode(s.renameCollection('old_system_js'), ErrorCodes.IllegalOperation);