summaryrefslogtreecommitdiff
path: root/jstests/concurrency
diff options
context:
space:
mode:
authorKaloian Manassiev <kaloian.manassiev@mongodb.com>2017-10-09 20:37:41 -0400
committerKaloian Manassiev <kaloian.manassiev@mongodb.com>2017-10-10 14:50:19 -0400
commitc5eb2dc9b5e7d7e3232f0da658c8eef24cbd9e42 (patch)
treef01f85b4b5ac855a73e0ade969c17976eb93e7bd /jstests/concurrency
parent2463c3abda86bceae80775d05f5925064cf01874 (diff)
downloadmongo-c5eb2dc9b5e7d7e3232f0da658c8eef24cbd9e42.tar.gz
SERVER-31184 Make FSM concurrency suites filter chunks based on the namespace
Diffstat (limited to 'jstests/concurrency')
-rw-r--r--jstests/concurrency/fsm_workload_helpers/chunks.js13
-rw-r--r--jstests/concurrency/fsm_workloads/sharded_base_partitioned.js6
-rw-r--r--jstests/concurrency/fsm_workloads/sharded_mergeChunks_partitioned.js20
-rw-r--r--jstests/concurrency/fsm_workloads/sharded_moveChunk_partitioned.js6
-rw-r--r--jstests/concurrency/fsm_workloads/sharded_splitChunk_partitioned.js12
5 files changed, 32 insertions, 25 deletions
diff --git a/jstests/concurrency/fsm_workload_helpers/chunks.js b/jstests/concurrency/fsm_workload_helpers/chunks.js
index 2cdbdcc6e7b..4f7fb604b78 100644
--- a/jstests/concurrency/fsm_workload_helpers/chunks.js
+++ b/jstests/concurrency/fsm_workload_helpers/chunks.js
@@ -145,21 +145,24 @@ var ChunkHelper = (function() {
// Intended for use on config or mongos connections only.
// Get number of chunks containing values in [lower, upper). The upper bound on a chunk is
// exclusive, but to capture the chunk we must provide it with less than or equal to 'upper'.
- function getNumChunks(conn, lower, upper) {
+ function getNumChunks(conn, ns, lower, upper) {
assert(isMongos(conn.getDB('admin')) || isMongodConfigsvr(conn.getDB('admin')),
tojson(conn) + ' is not to a mongos or a mongod config server');
- var query = {'min._id': {$gte: lower}, 'max._id': {$lte: upper}};
-
+ assert(isString(ns) && ns.indexOf('.') !== -1 && !ns.startsWith('.') && !ns.endsWith('.'),
+ ns + ' is not a valid namespace');
+ var query = {'ns': ns, 'min._id': {$gte: lower}, 'max._id': {$lte: upper}};
return conn.getDB('config').chunks.find(query).itcount();
}
// Intended for use on config or mongos connections only.
// For getting chunks containing values in [lower, upper). The upper bound on a chunk is
// exclusive, but to capture the chunk we must provide it with less than or equal to 'upper'.
- function getChunks(conn, lower, upper) {
+ function getChunks(conn, ns, lower, upper) {
assert(isMongos(conn.getDB('admin')) || isMongodConfigsvr(conn.getDB('admin')),
tojson(conn) + ' is not to a mongos or a mongod config server');
- var query = {'min._id': {$gte: lower}, 'max._id': {$lte: upper}};
+ assert(isString(ns) && ns.indexOf('.') !== -1 && !ns.startsWith('.') && !ns.endsWith('.'),
+ ns + ' is not a valid namespace');
+ var query = {'ns': ns, 'min._id': {$gte: lower}, 'max._id': {$lte: upper}};
return conn.getDB('config').chunks.find(query).sort({'min._id': 1}).toArray();
}
diff --git a/jstests/concurrency/fsm_workloads/sharded_base_partitioned.js b/jstests/concurrency/fsm_workloads/sharded_base_partitioned.js
index 9ef02e7267d..a476eb43860 100644
--- a/jstests/concurrency/fsm_workloads/sharded_base_partitioned.js
+++ b/jstests/concurrency/fsm_workloads/sharded_base_partitioned.js
@@ -110,11 +110,13 @@ var $config = (function() {
this.partition = this.makePartition(this.tid, this.partitionSize);
Object.freeze(this.partition);
+ var ns = db[collName].getFullName();
+
// Verify that there is exactly 1 chunk in our partition.
var config = ChunkHelper.getPrimary(connCache.config);
var numChunks = ChunkHelper.getNumChunks(
- config, this.partition.chunkLower, this.partition.chunkUpper);
- var chunks = ChunkHelper.getChunks(config, MinKey, MaxKey);
+ config, ns, this.partition.chunkLower, this.partition.chunkUpper);
+ var chunks = ChunkHelper.getChunks(config, ns, MinKey, MaxKey);
var msg = tojson({tid: this.tid, data: this.data, chunks: chunks});
assertWhenOwnColl.eq(numChunks, 1, msg);
}
diff --git a/jstests/concurrency/fsm_workloads/sharded_mergeChunks_partitioned.js b/jstests/concurrency/fsm_workloads/sharded_mergeChunks_partitioned.js
index 08545c962bf..b7ab427c434 100644
--- a/jstests/concurrency/fsm_workloads/sharded_mergeChunks_partitioned.js
+++ b/jstests/concurrency/fsm_workloads/sharded_mergeChunks_partitioned.js
@@ -63,8 +63,10 @@ var $config = extendWorkload($config, function($config, $super) {
var config = ChunkHelper.getPrimary(connCache.config);
- var numChunksInPartition =
- ChunkHelper.getNumChunks(config, this.partition.chunkLower, this.partition.chunkUpper);
+ var numChunksInPartition = ChunkHelper.getNumChunks(config,
+ db[collName].getFullName(),
+ this.partition.chunkLower,
+ this.partition.chunkUpper);
// Verify that there is at least one chunk in our partition and that
// there are at least as many chunks in our partition as iterations.
@@ -126,15 +128,15 @@ var $config = extendWorkload($config, function($config, $super) {
// Save the number of chunks before the mergeChunks operation. This will be used
// to verify that the number of chunks after a successful mergeChunks decreases
// by one, or after a failed mergeChunks stays the same.
- var numChunksBefore =
- ChunkHelper.getNumChunks(config, this.partition.chunkLower, this.partition.chunkUpper);
+ var numChunksBefore = ChunkHelper.getNumChunks(
+ config, ns, this.partition.chunkLower, this.partition.chunkUpper);
// Use chunk_helper.js's mergeChunks wrapper to tolerate acceptable failures
// and to use a limited number of retries with exponential backoff.
var bounds = [{_id: chunk1.min._id}, {_id: chunk2.max._id}];
var mergeChunksRes = ChunkHelper.mergeChunks(db, collName, bounds);
var chunks =
- ChunkHelper.getChunks(config, this.partition.chunkLower, this.partition.chunkUpper);
+ ChunkHelper.getChunks(config, ns, this.partition.chunkLower, this.partition.chunkUpper);
var msgBase = tojson({
mergeChunksResult: mergeChunksRes,
chunksInPartition: chunks,
@@ -161,7 +163,7 @@ var $config = extendWorkload($config, function($config, $super) {
// verify that there are still two chunks between the original chunks' lower and
// upper bounds.
var numChunksBetweenOldChunksBounds =
- ChunkHelper.getNumChunks(conn, chunk1.min._id, chunk2.max._id);
+ ChunkHelper.getNumChunks(conn, ns, chunk1.min._id, chunk2.max._id);
if (mergeChunksRes.ok) {
msg = 'mergeChunks succeeded but config does not see exactly 1 chunk between ' +
'the chunk bounds.\n' + msgBase;
@@ -176,7 +178,7 @@ var $config = extendWorkload($config, function($config, $super) {
// of chunks in our partition has decreased by 1. If it failed, verify
// that it has stayed the same.
var numChunksAfter = ChunkHelper.getNumChunks(
- config, this.partition.chunkLower, this.partition.chunkUpper);
+ config, ns, this.partition.chunkLower, this.partition.chunkUpper);
if (mergeChunksRes.ok) {
msg = 'mergeChunks succeeded but config does not see exactly 1 fewer chunks ' +
'between the chunk bounds than before.\n' + msgBase;
@@ -218,7 +220,7 @@ var $config = extendWorkload($config, function($config, $super) {
// the original chunks' lower and upper bounds. If the operation failed, verify that the
// mongos still sees two chunks between the original chunks' lower and upper bounds.
var numChunksBetweenOldChunksBounds =
- ChunkHelper.getNumChunks(mongos, chunk1.min._id, chunk2.max._id);
+ ChunkHelper.getNumChunks(mongos, ns, chunk1.min._id, chunk2.max._id);
if (mergeChunksRes.ok) {
msg = 'mergeChunks succeeded but mongos does not see exactly 1 chunk between ' +
'the chunk bounds.\n' + msgBase;
@@ -233,7 +235,7 @@ var $config = extendWorkload($config, function($config, $super) {
// number of chunks in our partition has decreased by 1. If it failed, verify that it
// has stayed the same.
var numChunksAfter = ChunkHelper.getNumChunks(
- mongos, this.partition.chunkLower, this.partition.chunkUpper);
+ mongos, ns, this.partition.chunkLower, this.partition.chunkUpper);
if (mergeChunksRes.ok) {
msg = 'mergeChunks succeeded but mongos does not see exactly 1 fewer chunks ' +
'between the chunk bounds.\n' + msgBase;
diff --git a/jstests/concurrency/fsm_workloads/sharded_moveChunk_partitioned.js b/jstests/concurrency/fsm_workloads/sharded_moveChunk_partitioned.js
index 662822a84e4..0b908fe8106 100644
--- a/jstests/concurrency/fsm_workloads/sharded_moveChunk_partitioned.js
+++ b/jstests/concurrency/fsm_workloads/sharded_moveChunk_partitioned.js
@@ -57,8 +57,8 @@ var $config = extendWorkload($config, function($config, $super) {
// Save the number of chunks before the moveChunk operation. This will be used
// to verify that the number of chunks after the moveChunk operation remains the same.
- var numChunksBefore =
- ChunkHelper.getNumChunks(config, this.partition.chunkLower, this.partition.chunkUpper);
+ var numChunksBefore = ChunkHelper.getNumChunks(
+ config, ns, this.partition.chunkLower, this.partition.chunkUpper);
// Randomly choose whether to wait for all documents on the fromShard
// to be deleted before the moveChunk operation returns.
@@ -126,7 +126,7 @@ var $config = extendWorkload($config, function($config, $super) {
// Regardless of whether the operation succeeded or failed,
// verify that the number of chunks in our partition stayed the same.
var numChunksAfter = ChunkHelper.getNumChunks(
- conn, this.partition.chunkLower, this.partition.chunkUpper);
+ conn, ns, this.partition.chunkLower, this.partition.chunkUpper);
msg = 'Number of chunks in partition seen by config changed with moveChunk.\n' +
msgBase;
assertWhenOwnColl.eq(numChunksBefore, numChunksAfter, msg);
diff --git a/jstests/concurrency/fsm_workloads/sharded_splitChunk_partitioned.js b/jstests/concurrency/fsm_workloads/sharded_splitChunk_partitioned.js
index 20e90a72d22..c094040c9b3 100644
--- a/jstests/concurrency/fsm_workloads/sharded_splitChunk_partitioned.js
+++ b/jstests/concurrency/fsm_workloads/sharded_splitChunk_partitioned.js
@@ -39,8 +39,8 @@ var $config = extendWorkload($config, function($config, $super) {
// Save the number of chunks before the splitChunk operation. This will be used
// to verify that the number of chunks after a successful splitChunk increases
// by one, or after a failed splitChunk stays the same.
- var numChunksBefore =
- ChunkHelper.getNumChunks(config, this.partition.chunkLower, this.partition.chunkUpper);
+ var numChunksBefore = ChunkHelper.getNumChunks(
+ config, ns, this.partition.chunkLower, this.partition.chunkUpper);
// Use chunk_helper.js's splitChunk wrapper to tolerate acceptable failures
// and to use a limited number of retries with exponential backoff.
@@ -67,7 +67,7 @@ var $config = extendWorkload($config, function($config, $super) {
// If the operation failed, verify that there is still only one chunk
// between the old chunk's lower and upper bounds.
var numChunksBetweenOldChunksBounds =
- ChunkHelper.getNumChunks(conn, chunk.min._id, chunk.max._id);
+ ChunkHelper.getNumChunks(conn, ns, chunk.min._id, chunk.max._id);
if (splitChunkRes.ok) {
msg = 'splitChunk succeeded but the config does not see exactly 2 chunks ' +
'between the chunk bounds.\n' + msgBase;
@@ -82,7 +82,7 @@ var $config = extendWorkload($config, function($config, $super) {
// of chunks in our partition has increased by 1. If it failed, verify
// that it has stayed the same.
var numChunksAfter = ChunkHelper.getNumChunks(
- config, this.partition.chunkLower, this.partition.chunkUpper);
+ config, ns, this.partition.chunkLower, this.partition.chunkUpper);
if (splitChunkRes.ok) {
msg = 'splitChunk succeeded but the config does nnot see exactly 1 more ' +
'chunk between the chunk bounds.\n' + msgBase;
@@ -125,7 +125,7 @@ var $config = extendWorkload($config, function($config, $super) {
// the old chunk's lower and upper bounds. If the operation failed, verify that the
// mongos still only sees one chunk between the old chunk's lower and upper bounds.
var numChunksBetweenOldChunksBounds =
- ChunkHelper.getNumChunks(mongos, chunk.min._id, chunk.max._id);
+ ChunkHelper.getNumChunks(mongos, ns, chunk.min._id, chunk.max._id);
if (splitChunkRes.ok) {
msg = 'splitChunk succeeded but the mongos does not see exactly 2 chunks ' +
'between the chunk bounds.\n' + msgBase;
@@ -139,7 +139,7 @@ var $config = extendWorkload($config, function($config, $super) {
// If the splitChunk operation succeeded, verify that the total number of chunks in our
// partition has increased by 1. If it failed, verify that it has stayed the same.
var numChunksAfter = ChunkHelper.getNumChunks(
- mongos, this.partition.chunkLower, this.partition.chunkUpper);
+ mongos, ns, this.partition.chunkLower, this.partition.chunkUpper);
if (splitChunkRes.ok) {
msg = 'splitChunk succeeded but the mongos does nnot see exactly 1 more ' +
'chunk between the chunk bounds.\n' + msgBase;