summaryrefslogtreecommitdiff
path: root/jstests/core/collation.js
diff options
context:
space:
mode:
authorMatthew Russotto <matthew.russotto@10gen.com>2018-02-20 11:56:59 -0500
committerMatthew Russotto <matthew.russotto@10gen.com>2018-03-01 08:27:54 -0500
commitae6827297917916173c4d522cabce8fe8fecbf27 (patch)
tree2b8a9b55dd35b70f010a03b90288a1c95d722760 /jstests/core/collation.js
parentc713377e4b99475563f26de19f88c45ece8a0546 (diff)
downloadmongo-ae6827297917916173c4d522cabce8fe8fecbf27.tar.gz
SERVER-32320 Push doTxn oplog entry generation into logOp on transaction commit.
Diffstat (limited to 'jstests/core/collation.js')
-rw-r--r--jstests/core/collation.js32
1 files changed, 21 insertions, 11 deletions
diff --git a/jstests/core/collation.js b/jstests/core/collation.js
index 3a089dde4ee..2b3996ccc96 100644
--- a/jstests/core/collation.js
+++ b/jstests/core/collation.js
@@ -11,6 +11,8 @@
load("jstests/libs/get_index_helpers.js");
// For isMMAPv1.
load("jstests/concurrency/fsm_workload_helpers/server_types.js");
+ // For isReplSet
+ load("jstests/libs/fixture_helpers.js");
var coll = db.collation;
coll.drop();
@@ -1973,39 +1975,47 @@
}
// doTxn
- if (!isMongos && !isMMAPv1(db)) {
+ if (FixtureHelpers.isReplSet(db) && !isMongos && !isMMAPv1(db)) {
+ const session = db.getMongo().startSession();
+ const sessionDb = session.getDatabase(db.getName());
coll.drop();
assert.commandWorked(
db.createCollection("collation", {collation: {locale: "en_US", strength: 2}}));
assert.writeOK(coll.insert({_id: "foo", x: 5, str: "bar"}));
// preCondition.q respects collection default collation.
- assert.commandFailed(db.runCommand({
+ assert.commandFailed(sessionDb.runCommand({
doTxn: [{op: "u", ns: coll.getFullName(), o2: {_id: "foo"}, o: {$set: {x: 6}}}],
- preCondition: [{ns: coll.getFullName(), q: {_id: "not foo"}, res: {str: "bar"}}]
+ preCondition: [{ns: coll.getFullName(), q: {_id: "not foo"}, res: {str: "bar"}}],
+ txnNumber: NumberLong("0")
}));
assert.eq(5, coll.findOne({_id: "foo"}).x);
- assert.commandWorked(db.runCommand({
+ assert.commandWorked(sessionDb.runCommand({
doTxn: [{op: "u", ns: coll.getFullName(), o2: {_id: "foo"}, o: {$set: {x: 6}}}],
- preCondition: [{ns: coll.getFullName(), q: {_id: "FOO"}, res: {str: "bar"}}]
+ preCondition: [{ns: coll.getFullName(), q: {_id: "FOO"}, res: {str: "bar"}}],
+ txnNumber: NumberLong("1")
}));
assert.eq(6, coll.findOne({_id: "foo"}).x);
// preCondition.res respects collection default collation.
- assert.commandFailed(db.runCommand({
+ assert.commandFailed(sessionDb.runCommand({
doTxn: [{op: "u", ns: coll.getFullName(), o2: {_id: "foo"}, o: {$set: {x: 7}}}],
- preCondition: [{ns: coll.getFullName(), q: {_id: "foo"}, res: {str: "not bar"}}]
+ preCondition: [{ns: coll.getFullName(), q: {_id: "foo"}, res: {str: "not bar"}}],
+ txnNumber: NumberLong("2")
}));
assert.eq(6, coll.findOne({_id: "foo"}).x);
- assert.commandWorked(db.runCommand({
+ assert.commandWorked(sessionDb.runCommand({
doTxn: [{op: "u", ns: coll.getFullName(), o2: {_id: "foo"}, o: {$set: {x: 7}}}],
- preCondition: [{ns: coll.getFullName(), q: {_id: "foo"}, res: {str: "BAR"}}]
+ preCondition: [{ns: coll.getFullName(), q: {_id: "foo"}, res: {str: "BAR"}}],
+ txnNumber: NumberLong("3")
}));
assert.eq(7, coll.findOne({_id: "foo"}).x);
// <operation>.o2 respects collection default collation.
- assert.commandWorked(db.runCommand(
- {doTxn: [{op: "u", ns: coll.getFullName(), o2: {_id: "FOO"}, o: {$set: {x: 8}}}]}));
+ assert.commandWorked(sessionDb.runCommand({
+ doTxn: [{op: "u", ns: coll.getFullName(), o2: {_id: "FOO"}, o: {$set: {x: 8}}}],
+ txnNumber: NumberLong("4")
+ }));
assert.eq(8, coll.findOne({_id: "foo"}).x);
}