Skip to content

Commit 3311d7c

Browse files
janetioMongoDB Bot
authored and
MongoDB Bot
committed
SERVER-98632 Use unique database each time unshard_collection_with_zones.js is called and blacklist from stepdown suites (#30492)
GitOrigin-RevId: a8802e9764de76e31fc2a4399f98cbb7990fbc8b
1 parent 17514a0 commit 3311d7c

File tree

1 file changed

+23
-16
lines changed

1 file changed

+23
-16
lines changed

jstests/core_sharding/unshard_collection/unshard_collection_with_zones.js

+23-16
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
/**
22
* Tests that a collection with zone definitions has its zones dropped when it is unsharded.
3-
* @tags: [assumes_balancer_off]
3+
* @tags: [
4+
* assumes_balancer_off,
5+
* does_not_support_stepdowns
6+
* ]
47
*/
58

69
import {Thread} from "jstests/libs/parallelTester.js";
@@ -13,53 +16,57 @@ if (shards.length < 2) {
1316
}
1417

1518
Random.setRandomSeed();
16-
const dbName = db.getName();
19+
20+
const testDb = db.getSiblingDB(jsTestName());
21+
testDb.dropDatabase();
22+
23+
const dbName = testDb.getName();
1724

1825
let shard0 = shards[0];
1926
let shard1 = shards[1];
2027

21-
assert.commandWorked(db.adminCommand({enableSharding: dbName, primaryShard: shard0._id}));
28+
assert.commandWorked(testDb.adminCommand({enableSharding: dbName, primaryShard: shard0._id}));
2229

23-
assert.commandWorked(db.adminCommand({addShardToZone: shard0._id, zone: "zone1"}));
24-
assert.commandWorked(db.adminCommand({addShardToZone: shard1._id, zone: "zone2"}));
30+
assert.commandWorked(testDb.adminCommand({addShardToZone: shard0._id, zone: "zone1"}));
31+
assert.commandWorked(testDb.adminCommand({addShardToZone: shard1._id, zone: "zone2"}));
2532

2633
const collName = jsTestName();
2734
const ns = dbName + '.' + collName;
2835

29-
assert.commandWorked(db.createCollection(collName));
30-
assert.commandWorked(db.adminCommand({shardCollection: ns, key: {x: 1}}));
31-
assert.commandWorked(db.adminCommand({split: ns, middle: {x: 0}}));
36+
assert.commandWorked(testDb.createCollection(collName));
37+
assert.commandWorked(testDb.adminCommand({shardCollection: ns, key: {x: 1}}));
38+
assert.commandWorked(testDb.adminCommand({split: ns, middle: {x: 0}}));
3239

33-
assert.commandWorked(db.adminCommand({moveChunk: ns, find: {x: 0}, to: shard1._id}));
40+
assert.commandWorked(testDb.adminCommand({moveChunk: ns, find: {x: 0}, to: shard1._id}));
3441

3542
// Define zones for test collection.
3643
assert.commandWorked(
37-
db.adminCommand({updateZoneKeyRange: ns, min: {x: MinKey}, max: {x: 0}, zone: "zone1"}));
44+
testDb.adminCommand({updateZoneKeyRange: ns, min: {x: MinKey}, max: {x: 0}, zone: "zone1"}));
3845
assert.commandWorked(
39-
db.adminCommand({updateZoneKeyRange: ns, min: {x: 0}, max: {x: MaxKey}, zone: "zone2"}));
46+
testDb.adminCommand({updateZoneKeyRange: ns, min: {x: 0}, max: {x: MaxKey}, zone: "zone2"}));
4047

4148
for (let i = 0; i < 5000; i++) {
42-
db.getCollection(ns).insert({x: i});
49+
testDb.getCollection(ns).insert({x: i});
4350
}
4451

4552
const unshardCollectionThread = function(host, ns) {
4653
const mongos = new Mongo(host);
4754
mongos.adminCommand({unshardCollection: ns});
4855
};
4956

50-
let threadForTest = new Thread(unshardCollectionThread, db.getMongo().host, ns);
57+
let threadForTest = new Thread(unshardCollectionThread, testDb.getMongo().host, ns);
5158
threadForTest.start();
5259

5360
// Since we sleep for a random interval, there is a chance the unsharding will succeed
5461
// before the abort can happen.
5562
sleep(Random.randInt(10 * 1000));
5663

57-
db.adminCommand({abortUnshardCollection: ns});
64+
testDb.adminCommand({abortUnshardCollection: ns});
5865

5966
threadForTest.join();
6067

61-
let configCollectionDoc = db.getSiblingDB('config').collections.findOne({_id: ns}).key;
62-
const tags = db.getSiblingDB('config').tags.find({ns: ns}).toArray();
68+
let configCollectionDoc = testDb.getSiblingDB('config').collections.findOne({_id: ns}).key;
69+
const tags = testDb.getSiblingDB('config').tags.find({ns: ns}).toArray();
6370

6471
// If we successfully unsharded our collection, we should have 0 zones in config.tags.
6572
// If unsharding was unsuccessful, we should retain 2 tags since we specified 2 zones for

0 commit comments

Comments
 (0)