summaryrefslogtreecommitdiff
path: root/jstests/noPassthrough/shard_fixture_selftest.js
diff options
context:
space:
mode:
authorRobert Guo <robert.guo@10gen.com>2018-03-25 22:15:26 -0400
committerRobert Guo <robert.guo@10gen.com>2018-04-12 09:19:28 -0400
commitf15c9b53211757c2aa007d7bb60852bd36bf08be (patch)
treedf2d0d5155ead41e68aab40829b701986b3c6fa0 /jstests/noPassthrough/shard_fixture_selftest.js
parent2896a5c5f79702e22205e2c46020b23fc1d0421f (diff)
downloadmongo-f15c9b53211757c2aa007d7bb60852bd36bf08be.tar.gz
SERVER-34289 add new sharded cluster wrapper for connecting to an existing cluster
Diffstat (limited to 'jstests/noPassthrough/shard_fixture_selftest.js')
-rw-r--r--jstests/noPassthrough/shard_fixture_selftest.js52
1 files changed, 52 insertions, 0 deletions
diff --git a/jstests/noPassthrough/shard_fixture_selftest.js b/jstests/noPassthrough/shard_fixture_selftest.js
new file mode 100644
index 00000000000..7bbaeeb8874
--- /dev/null
+++ b/jstests/noPassthrough/shard_fixture_selftest.js
@@ -0,0 +1,52 @@
+// A test to ensure that shard_fixture.js is consistent with shardingtest.js
+// @tags: [requires_sharding]
+
+(function() {
+ 'use strict';
+
+ load('jstests/concurrency/fsm_libs/shard_fixture.js');
+
+ const rsTestOriginal = new ShardingTest({
+ shards: 2,
+ mongos: 2,
+ config: 2,
+ shardAsReplicaSet: true,
+ });
+
+ const rsTestWrapper =
+ new FSMShardingTest(`mongodb://${rsTestOriginal.s0.host},${rsTestOriginal.s1.host}`);
+
+ assert.eq(rsTestWrapper.s(0).host, rsTestOriginal.s0.host);
+ assert.eq(rsTestWrapper.s(1).host, rsTestOriginal.s1.host);
+ assert.eq(rsTestWrapper.s(2), rsTestOriginal.s2); // Both should be undefined.
+
+ assert.eq(rsTestWrapper.shard(0).host, rsTestOriginal.shard0.host);
+ assert.eq(rsTestWrapper.shard(1).host, rsTestOriginal.shard1.host);
+ assert.eq(rsTestWrapper.shard(2), rsTestOriginal.shard2); // Both should be undefined.
+
+ assert.eq(rsTestWrapper.rs(0).getURL(), rsTestOriginal.rs0.getURL());
+ assert.eq(rsTestWrapper.rs(1).getURL(), rsTestOriginal.rs1.getURL());
+ assert.eq(rsTestWrapper.rs(2), rsTestOriginal.rs2); // Both should be undefined.
+
+ assert.eq(rsTestWrapper.c(0).host, rsTestOriginal.c0.host);
+ assert.eq(rsTestWrapper.c(1).host, rsTestOriginal.c1.host);
+ assert.eq(rsTestWrapper.c(2), rsTestOriginal.c2); // Both should be undefined.
+
+ rsTestOriginal.stop();
+
+ const dTestOriginal = new ShardingTest({
+ shards: 1,
+ mongos: 1,
+ config: 1,
+ shardAsReplicaSet: false,
+ });
+
+ const dTestWrapper = new FSMShardingTest(dTestOriginal.s.host);
+
+ assert.eq(dTestWrapper.shard(0).host, dTestOriginal.shard0.host);
+ assert.eq(dTestWrapper.s(0).host, dTestOriginal.s0.host);
+ assert.eq(dTestWrapper.d(0).host, dTestOriginal.d0.host);
+ assert.eq(rsTestWrapper.c(0).host, rsTestOriginal.c0.host);
+
+ dTestOriginal.stop();
+})(); \ No newline at end of file