summaryrefslogtreecommitdiff
path: root/jstests
diff options
context:
space:
mode:
authorTess Avitabile <tess.avitabile@mongodb.com>2018-06-06 15:22:44 -0400
committerTess Avitabile <tess.avitabile@mongodb.com>2018-06-06 16:32:00 -0400
commit92c61392d3a0a31c39b0ed0712d964503e6c0e27 (patch)
tree6525dcb444f32736d9b89bc8d83755161fef1f73 /jstests
parent964605ca7bdc9a85cbeffe6af16dd6e86b9bf61b (diff)
downloadmongo-92c61392d3a0a31c39b0ed0712d964503e6c0e27.tar.gz
SERVER-35451 Rename database used in transactions_block_ddl.js
Diffstat (limited to 'jstests')
-rw-r--r--jstests/core/txns/transactions_block_ddl.js42
1 files changed, 23 insertions, 19 deletions
diff --git a/jstests/core/txns/transactions_block_ddl.js b/jstests/core/txns/transactions_block_ddl.js
index 66ed15494d6..0d6c4d1aa56 100644
--- a/jstests/core/txns/transactions_block_ddl.js
+++ b/jstests/core/txns/transactions_block_ddl.js
@@ -5,17 +5,20 @@
load("jstests/libs/parallelTester.js"); // for ScopedThread.
+ const dbName = "transactions_block_ddl";
const collName = "transactions_block_ddl";
- const testDB = db.getSiblingDB("test");
+ const otherDBName = "transactions_block_ddl_other";
+ const otherCollName = "transactions_block_ddl_other";
+ const testDB = db.getSiblingDB(dbName);
const session = testDB.getMongo().startSession({causalConsistency: false});
- const sessionDB = session.getDatabase("test");
+ const sessionDB = session.getDatabase(dbName);
const sessionColl = sessionDB[collName];
/**
* Tests that DDL operations block on transactions and fail when their maxTimeMS expires.
*/
- function testTimeout(dbName, ddlCmd) {
+ function testTimeout(cmdDBName, ddlCmd) {
// Setup.
sessionDB.runCommand({drop: collName, writeConcern: {w: "majority"}});
assert.commandWorked(sessionColl.createIndex({b: 1}, {name: "b_1"}));
@@ -23,7 +26,7 @@
session.startTransaction();
assert.commandWorked(sessionColl.insert({a: 5, b: 6}));
assert.commandFailedWithCode(
- testDB.getSiblingDB(dbName).runCommand(Object.assign({}, ddlCmd, {maxTimeMS: 500})),
+ testDB.getSiblingDB(cmdDBName).runCommand(Object.assign({}, ddlCmd, {maxTimeMS: 500})),
ErrorCodes.ExceededTimeLimit);
assert.commandWorked(session.commitTransaction_forTesting());
}
@@ -31,17 +34,17 @@
/**
* Tests that DDL operations block on transactions but can succeed once the transaction commits.
*/
- function testSuccessOnTxnCommit(dbName, ddlCmd, currentOpFilter) {
+ function testSuccessOnTxnCommit(cmdDBName, ddlCmd, currentOpFilter) {
// Setup.
sessionDB.runCommand({drop: collName, writeConcern: {w: "majority"}});
assert.commandWorked(sessionColl.createIndex({b: 1}, {name: "b_1"}));
session.startTransaction();
assert.commandWorked(sessionColl.insert({a: 5, b: 6}));
- let thread = new ScopedThread(function(testData, dbName, ddlCmd) {
+ let thread = new ScopedThread(function(testData, cmdDBName, ddlCmd) {
TestData = testData;
- return db.getSiblingDB(dbName).runCommand(ddlCmd);
- }, TestData, dbName, ddlCmd);
+ return db.getSiblingDB(cmdDBName).runCommand(ddlCmd);
+ }, TestData, cmdDBName, ddlCmd);
thread.start();
// Wait for the DDL operation to have pending locks.
assert.soon(
@@ -62,20 +65,20 @@
// Test 'drop'.
const dropCmd = {drop: collName, writeConcern: {w: "majority"}};
- testTimeout("test", dropCmd);
- testSuccessOnTxnCommit("test", dropCmd, {"command.drop": collName});
+ testTimeout(dbName, dropCmd);
+ testSuccessOnTxnCommit(dbName, dropCmd, {"command.drop": collName});
// Test 'dropDatabase'.
// We cannot run testTimeout() for dropDatabase, since dropDatabase does not respect maxTimeMS
// TODO SERVER-35290: Run testTimeout() for dropDatabase.
const dropDatabaseCmd = {dropDatabase: 1, writeConcern: {w: "majority"}};
- testSuccessOnTxnCommit("test", dropDatabaseCmd, {"command.dropDatabase": 1});
+ testSuccessOnTxnCommit(dbName, dropDatabaseCmd, {"command.dropDatabase": 1});
// Test 'renameCollection' in the same database.
- testDB.runCommand({drop: "otherColl", writeConcern: {w: "majority"}});
+ testDB.runCommand({drop: otherCollName, writeConcern: {w: "majority"}});
const renameCollectionCmdSameDB = {
renameCollection: sessionColl.getFullName(),
- to: "test.otherColl",
+ to: dbName + "." + otherCollName,
writeConcern: {w: "majority"}
};
testTimeout("admin", renameCollectionCmdSameDB);
@@ -84,10 +87,11 @@
{"command.renameCollection": sessionColl.getFullName()});
// Test 'renameCollection' across databases.
- testDB.getSiblingDB("otherDB").runCommand({drop: "otherColl", writeConcern: {w: "majority"}});
+ testDB.getSiblingDB(otherDBName)
+ .runCommand({drop: otherCollName, writeConcern: {w: "majority"}});
const renameCollectionCmdDifferentDB = {
renameCollection: sessionColl.getFullName(),
- to: "otherDB.otherColl",
+ to: otherDBName + "." + otherCollName,
writeConcern: {w: "majority"}
};
testTimeout("admin", renameCollectionCmdDifferentDB);
@@ -101,13 +105,13 @@
indexes: [{key: {a: 1}, name: "a_1"}],
writeConcern: {w: "majority"}
};
- testTimeout("test", createIndexesCmd);
- testSuccessOnTxnCommit("test", createIndexesCmd, {"command.createIndexes": collName});
+ testTimeout(dbName, createIndexesCmd);
+ testSuccessOnTxnCommit(dbName, createIndexesCmd, {"command.createIndexes": collName});
// Test 'dropIndexes'. The setup creates an index on {b: 1} called 'b_1'. The transaction will
// insert a document that has a field 'b'.
const dropIndexesCmd = {dropIndexes: collName, index: "b_1", writeConcern: {w: "majority"}};
- testTimeout("test", dropIndexesCmd);
- testSuccessOnTxnCommit("test", dropIndexesCmd, {"command.dropIndexes": collName});
+ testTimeout(dbName, dropIndexesCmd);
+ testSuccessOnTxnCommit(dbName, dropIndexesCmd, {"command.dropIndexes": collName});
session.endSession();
}());