summaryrefslogtreecommitdiff
path: root/jstests/readonly
diff options
context:
space:
mode:
authorclang-format-7.0.1 <adam.martin@10gen.com>2019-07-26 18:20:35 -0400
committerADAM David Alan Martin <adam.martin@10gen.com>2019-07-27 11:02:23 -0400
commit134a4083953270e8a11430395357fb70a29047ad (patch)
treedd428e1230e31d92b20b393dfdc17ffe7fa79cb6 /jstests/readonly
parent1e46b5049003f427047e723ea5fab15b5a9253ca (diff)
downloadmongo-134a4083953270e8a11430395357fb70a29047ad.tar.gz
SERVER-41772 Apply clang-format 7.0.1 to the codebase
Diffstat (limited to 'jstests/readonly')
-rw-r--r--jstests/readonly/aggregate.js87
-rw-r--r--jstests/readonly/catalog_ops.js2
-rw-r--r--jstests/readonly/geo.js37
-rw-r--r--jstests/readonly/lib/read_only_test.js286
-rw-r--r--jstests/readonly/temp_collection.js8
5 files changed, 208 insertions, 212 deletions
diff --git a/jstests/readonly/aggregate.js b/jstests/readonly/aggregate.js
index 9640c231900..a79e7ed19d2 100644
--- a/jstests/readonly/aggregate.js
+++ b/jstests/readonly/aggregate.js
@@ -9,63 +9,62 @@ runReadOnlyTest(function() {
assert.doesNotThrow(() => {
writableCollection.insertMany([
{
- award: "Best Picture",
- nominations: [
- {title: "The Big Short"},
- {title: "Bridge of Spies"},
- {title: "Brooklyn"},
- {title: "Max Max: Fury Road"},
- {title: "The Martian"},
- {title: "The Revenant"},
- {title: "Room"},
- {title: "Spotlight"}
- ]
+ award: "Best Picture",
+ nominations: [
+ {title: "The Big Short"},
+ {title: "Bridge of Spies"},
+ {title: "Brooklyn"},
+ {title: "Max Max: Fury Road"},
+ {title: "The Martian"},
+ {title: "The Revenant"},
+ {title: "Room"},
+ {title: "Spotlight"}
+ ]
},
{
- award: "Best Actor",
- nominations: [
- {title: "Trumbo", person: "Bryan Cranston"},
- {title: "The Martian", person: "Matt Damon"},
- {title: "The Revenant", person: "Leonardo DiCaprio"},
- {title: "Steve Jobs", person: "Michael Fassbender"},
- {title: "The Danish Girl", person: "Eddie Redmayne"}
- ]
+ award: "Best Actor",
+ nominations: [
+ {title: "Trumbo", person: "Bryan Cranston"},
+ {title: "The Martian", person: "Matt Damon"},
+ {title: "The Revenant", person: "Leonardo DiCaprio"},
+ {title: "Steve Jobs", person: "Michael Fassbender"},
+ {title: "The Danish Girl", person: "Eddie Redmayne"}
+ ]
},
{
- award: "Best Actress",
- nominations: [
- {title: "Carol", person: "Cate Blanchett"},
- {title: "Room", person: "Brie Larson"},
- {title: "Joy", person: "Jennifer Lawrence"},
- {title: "45 Years", person: "Charlotte Rampling"},
- {title: "Brooklyn", person: "Saoirse Ronan"}
- ]
+ award: "Best Actress",
+ nominations: [
+ {title: "Carol", person: "Cate Blanchett"},
+ {title: "Room", person: "Brie Larson"},
+ {title: "Joy", person: "Jennifer Lawrence"},
+ {title: "45 Years", person: "Charlotte Rampling"},
+ {title: "Brooklyn", person: "Saoirse Ronan"}
+ ]
},
{
- award: "Best Supporting Actor",
- nominations: [
- {title: "The Big Short", person: "Christian Bale"},
- {title: "The Revenant", person: "Tom Hardy"},
- {title: "Spotlight", person: "Mark Ruffalo"},
- {title: "Bridge Of Spies", person: "Mark Rylance"},
- {title: "Creed", person: "Sylvester Stallone"}
- ]
+ award: "Best Supporting Actor",
+ nominations: [
+ {title: "The Big Short", person: "Christian Bale"},
+ {title: "The Revenant", person: "Tom Hardy"},
+ {title: "Spotlight", person: "Mark Ruffalo"},
+ {title: "Bridge Of Spies", person: "Mark Rylance"},
+ {title: "Creed", person: "Sylvester Stallone"}
+ ]
},
{
- award: "Best Supporting Actress",
- nominations: [
- {title: "The Hateful Eight", person: "Jennifer Jason Leigh"},
- {title: "Carol", person: "Rooney Mara"},
- {title: "Spotlight", person: "Rachel McAdams"},
- {title: "The Danish Girl", person: "Alicia Vikander"},
- {title: "Steve Jobs", person: "Kate Winslet"}
- ]
+ award: "Best Supporting Actress",
+ nominations: [
+ {title: "The Hateful Eight", person: "Jennifer Jason Leigh"},
+ {title: "Carol", person: "Rooney Mara"},
+ {title: "Spotlight", person: "Rachel McAdams"},
+ {title: "The Danish Girl", person: "Alicia Vikander"},
+ {title: "Steve Jobs", person: "Kate Winslet"}
+ ]
}
]);
});
},
exec: function(readableCollection) {
-
// Find titles nominated for the most awards.
var mostAwardsPipeline = [
{$unwind: "$nominations"},
diff --git a/jstests/readonly/catalog_ops.js b/jstests/readonly/catalog_ops.js
index e219e2eb0c1..9f8353ee61c 100644
--- a/jstests/readonly/catalog_ops.js
+++ b/jstests/readonly/catalog_ops.js
@@ -9,7 +9,6 @@ runReadOnlyTest(function() {
indexSpecs: [{a: 1}, {a: 1, b: -1}, {a: 1, b: 1, c: -1}],
load: function(writableCollection) {
-
// Catalog guarantees are neccessarily weaker in sharded systems since mongos is not
// read-only aware.
if (TestData.fixture === "sharded")
@@ -29,7 +28,6 @@ runReadOnlyTest(function() {
}
},
exec: function(readableCollection) {
-
// Catalog guarantees are neccessarily weaker in sharded systems since mongos is not
// read-only aware.
if (TestData.fixture === "sharded")
diff --git a/jstests/readonly/geo.js b/jstests/readonly/geo.js
index 2ba43f597b4..ea13761248a 100644
--- a/jstests/readonly/geo.js
+++ b/jstests/readonly/geo.js
@@ -12,17 +12,17 @@ runReadOnlyTest(function() {
var locDocs = [
{name: "Berry Park", loc: {type: "Point", coordinates: [40.722396, -73.9573645]}},
{
- name: "Northern Territory",
- loc: {type: "Point", coordinates: [40.7252334, -73.9595218]}
+ name: "Northern Territory",
+ loc: {type: "Point", coordinates: [40.7252334, -73.9595218]}
},
{
- name: "Kent Ale House",
- loc: {type: "Point", coordinates: [40.7223364, -73.9614495]}
+ name: "Kent Ale House",
+ loc: {type: "Point", coordinates: [40.7223364, -73.9614495]}
},
{name: "The Shanty", loc: {type: "Point", coordinates: [40.7185752, -73.9510538]}},
{
- name: "The Counting Room",
- loc: {type: "Point", coordinates: [40.7209601, -73.9588041]}
+ name: "The Counting Room",
+ loc: {type: "Point", coordinates: [40.7209601, -73.9588041]}
},
{name: "Kinfolk 94", loc: {type: "Point", coordinates: [40.7217058, -73.9605489]}}
];
@@ -30,18 +30,19 @@ runReadOnlyTest(function() {
writableCollection.insertMany(locDocs);
},
exec: function(readableCollection) {
- const res = readableCollection
- .aggregate([
- {
- $geoNear: {
- near: {type: "Point", coordinates: [40.7211404, -73.9591494]},
- distanceField: "dist",
- spherical: true,
- }
- },
- {$limit: 1}
- ])
- .toArray();
+ const res =
+ readableCollection
+ .aggregate([
+ {
+ $geoNear: {
+ near: {type: "Point", coordinates: [40.7211404, -73.9591494]},
+ distanceField: "dist",
+ spherical: true,
+ }
+ },
+ {$limit: 1}
+ ])
+ .toArray();
assert.eq(res[0].name, "The Counting Room", printjson(res));
}
};
diff --git a/jstests/readonly/lib/read_only_test.js b/jstests/readonly/lib/read_only_test.js
index ef04350d5e0..04e1e2186ba 100644
--- a/jstests/readonly/lib/read_only_test.js
+++ b/jstests/readonly/lib/read_only_test.js
@@ -1,175 +1,175 @@
var StandaloneFixture, ShardedFixture, runReadOnlyTest, zip2, cycleN;
(function() {
- "use strict";
+"use strict";
- function makeDirectoryReadOnly(dir) {
- if (_isWindows()) {
- run("attrib", "+r", dir + "\\*.*", "/s");
- } else {
- run("chmod", "-R", "a-w", dir);
- }
+function makeDirectoryReadOnly(dir) {
+ if (_isWindows()) {
+ run("attrib", "+r", dir + "\\*.*", "/s");
+ } else {
+ run("chmod", "-R", "a-w", dir);
}
+}
- function makeDirectoryWritable(dir) {
- if (_isWindows()) {
- run("attrib", "-r", dir + "\\*.*", "/s");
- } else {
- run("chmod", "-R", "a+w", dir);
- }
+function makeDirectoryWritable(dir) {
+ if (_isWindows()) {
+ run("attrib", "-r", dir + "\\*.*", "/s");
+ } else {
+ run("chmod", "-R", "a+w", dir);
}
+}
- StandaloneFixture = function() {};
+StandaloneFixture = function() {};
- StandaloneFixture.prototype.runLoadPhase = function runLoadPhase(test) {
- this.mongod = MongoRunner.runMongod({});
- this.dbpath = this.mongod.dbpath;
+StandaloneFixture.prototype.runLoadPhase = function runLoadPhase(test) {
+ this.mongod = MongoRunner.runMongod({});
+ this.dbpath = this.mongod.dbpath;
- test.load(this.mongod.getDB("test")[test.name]);
- assert.commandWorked(this.mongod.getDB("local").dropDatabase());
- MongoRunner.stopMongod(this.mongod);
- };
+ test.load(this.mongod.getDB("test")[test.name]);
+ assert.commandWorked(this.mongod.getDB("local").dropDatabase());
+ MongoRunner.stopMongod(this.mongod);
+};
- StandaloneFixture.prototype.runExecPhase = function runExecPhase(test) {
- try {
- makeDirectoryReadOnly(this.dbpath);
+StandaloneFixture.prototype.runExecPhase = function runExecPhase(test) {
+ try {
+ makeDirectoryReadOnly(this.dbpath);
- var options = {queryableBackupMode: "", noCleanData: true, dbpath: this.dbpath};
+ var options = {queryableBackupMode: "", noCleanData: true, dbpath: this.dbpath};
- this.mongod = MongoRunner.runMongod(options);
- assert.neq(this.mongod, null);
+ this.mongod = MongoRunner.runMongod(options);
+ assert.neq(this.mongod, null);
- test.exec(this.mongod.getDB("test")[test.name]);
+ test.exec(this.mongod.getDB("test")[test.name]);
- MongoRunner.stopMongod(this.mongod);
- } finally {
- makeDirectoryWritable(this.dbpath);
- }
- };
-
- ShardedFixture = function() {
- this.nShards = 3;
- };
-
- ShardedFixture.prototype.runLoadPhase = function runLoadPhase(test) {
- // TODO: SERVER-33830 remove shardAsReplicaSet: false
- this.shardingTest =
- new ShardingTest({mongos: 1, shards: this.nShards, other: {shardAsReplicaSet: false}});
-
- this.paths = this.shardingTest.getDBPaths();
-
- jsTest.log("sharding test collection...");
-
- // Use a hashed shard key so we actually hit multiple shards.
- this.shardingTest.shardColl(test.name, {_id: "hashed"}, false);
-
- test.load(this.shardingTest.getDB("test")[test.name]);
- };
-
- ShardedFixture.prototype.runExecPhase = function runExecPhase(test) {
- jsTest.log("restarting shards...");
- try {
- for (var i = 0; i < this.nShards; ++i) {
- // Write the shard's shardIdentity to a config file under
- // sharding._overrideShardIdentity, since the shardIdentity must be provided through
- // overrideShardIdentity when running in queryableBackupMode, and is only allowed to
- // be set via config file.
-
- var shardIdentity = this.shardingTest["d" + i]
- .getDB("admin")
- .getCollection("system.version")
- .findOne({_id: "shardIdentity"});
- assert.neq(null, shardIdentity);
-
- // Construct a string representation of the config file (replace all instances of
- // multiple consecutive whitespace characters in the string representation of the
- // shardIdentity JSON document, including newlines, with single white spaces).
- var configFileStr = "sharding:\n _overrideShardIdentity: '" +
- tojson(shardIdentity).replace(/\s+/g, ' ') + "'";
-
- // Use the os-specific path delimiter.
- var delim = _isWindows() ? '\\' : '/';
- var configFilePath = this.paths[i] + delim + "config-for-shard-" + i + ".yml";
-
- writeFile(configFilePath, configFileStr);
-
- var opts = {
- config: configFilePath,
- queryableBackupMode: "",
- shardsvr: "",
- dbpath: this.paths[i]
- };
-
- assert.commandWorked(this.shardingTest["d" + i].getDB("local").dropDatabase());
- this.shardingTest.restartMongod(i, opts, () => {
- makeDirectoryReadOnly(this.paths[i]);
- });
- }
+ MongoRunner.stopMongod(this.mongod);
+ } finally {
+ makeDirectoryWritable(this.dbpath);
+ }
+};
- jsTest.log("restarting mongos...");
+ShardedFixture = function() {
+ this.nShards = 3;
+};
- this.shardingTest.restartMongos(0);
+ShardedFixture.prototype.runLoadPhase = function runLoadPhase(test) {
+ // TODO: SERVER-33830 remove shardAsReplicaSet: false
+ this.shardingTest =
+ new ShardingTest({mongos: 1, shards: this.nShards, other: {shardAsReplicaSet: false}});
- test.exec(this.shardingTest.getDB("test")[test.name]);
+ this.paths = this.shardingTest.getDBPaths();
- this.paths.forEach((path) => {
- makeDirectoryWritable(path);
- });
+ jsTest.log("sharding test collection...");
+
+ // Use a hashed shard key so we actually hit multiple shards.
+ this.shardingTest.shardColl(test.name, {_id: "hashed"}, false);
- this.shardingTest.stop();
- } finally {
- this.paths.forEach((path) => {
- makeDirectoryWritable(path);
+ test.load(this.shardingTest.getDB("test")[test.name]);
+};
+
+ShardedFixture.prototype.runExecPhase = function runExecPhase(test) {
+ jsTest.log("restarting shards...");
+ try {
+ for (var i = 0; i < this.nShards; ++i) {
+ // Write the shard's shardIdentity to a config file under
+ // sharding._overrideShardIdentity, since the shardIdentity must be provided through
+ // overrideShardIdentity when running in queryableBackupMode, and is only allowed to
+ // be set via config file.
+
+ var shardIdentity =
+ this.shardingTest["d" + i].getDB("admin").getCollection("system.version").findOne({
+ _id: "shardIdentity"
+ });
+ assert.neq(null, shardIdentity);
+
+ // Construct a string representation of the config file (replace all instances of
+ // multiple consecutive whitespace characters in the string representation of the
+ // shardIdentity JSON document, including newlines, with single white spaces).
+ var configFileStr = "sharding:\n _overrideShardIdentity: '" +
+ tojson(shardIdentity).replace(/\s+/g, ' ') + "'";
+
+ // Use the os-specific path delimiter.
+ var delim = _isWindows() ? '\\' : '/';
+ var configFilePath = this.paths[i] + delim + "config-for-shard-" + i + ".yml";
+
+ writeFile(configFilePath, configFileStr);
+
+ var opts = {
+ config: configFilePath,
+ queryableBackupMode: "",
+ shardsvr: "",
+ dbpath: this.paths[i]
+ };
+
+ assert.commandWorked(this.shardingTest["d" + i].getDB("local").dropDatabase());
+ this.shardingTest.restartMongod(i, opts, () => {
+ makeDirectoryReadOnly(this.paths[i]);
});
}
- };
- runReadOnlyTest = function(test) {
- printjson(test);
+ jsTest.log("restarting mongos...");
- assert.eq(typeof(test.exec), "function");
- assert.eq(typeof(test.load), "function");
- assert.eq(typeof(test.name), "string");
+ this.shardingTest.restartMongos(0);
- var fixtureType = TestData.fixture || "standalone";
+ test.exec(this.shardingTest.getDB("test")[test.name]);
- var fixture = null;
- if (fixtureType === "standalone") {
- fixture = new StandaloneFixture();
- } else if (fixtureType === "sharded") {
- fixture = new ShardedFixture();
- } else {
- throw new Error("fixtureType must be one of either 'standalone' or 'sharded'");
- }
+ this.paths.forEach((path) => {
+ makeDirectoryWritable(path);
+ });
+
+ this.shardingTest.stop();
+ } finally {
+ this.paths.forEach((path) => {
+ makeDirectoryWritable(path);
+ });
+ }
+};
- jsTest.log("starting load phase for test: " + test.name);
- fixture.runLoadPhase(test);
+runReadOnlyTest = function(test) {
+ printjson(test);
- jsTest.log("starting execution phase for test: " + test.name);
- fixture.runExecPhase(test);
- };
+ assert.eq(typeof (test.exec), "function");
+ assert.eq(typeof (test.load), "function");
+ assert.eq(typeof (test.name), "string");
+
+ var fixtureType = TestData.fixture || "standalone";
+
+ var fixture = null;
+ if (fixtureType === "standalone") {
+ fixture = new StandaloneFixture();
+ } else if (fixtureType === "sharded") {
+ fixture = new ShardedFixture();
+ } else {
+ throw new Error("fixtureType must be one of either 'standalone' or 'sharded'");
+ }
- cycleN = function * (arr, N) {
- for (var i = 0; i < N; ++i) {
- yield arr[i % arr.length];
+ jsTest.log("starting load phase for test: " + test.name);
+ fixture.runLoadPhase(test);
+
+ jsTest.log("starting execution phase for test: " + test.name);
+ fixture.runExecPhase(test);
+};
+
+cycleN = function*(arr, N) {
+ for (var i = 0; i < N; ++i) {
+ yield arr[i % arr.length];
+ }
+};
+
+zip2 = function*(iter1, iter2) {
+ var n1 = iter1.next();
+ var n2 = iter2.next();
+ while (!n1.done || !n2.done) {
+ var res = [];
+ if (!n1.done) {
+ res.push(n1.value);
+ n1 = iter1.next();
}
- };
-
- zip2 = function * (iter1, iter2) {
- var n1 = iter1.next();
- var n2 = iter2.next();
- while (!n1.done || !n2.done) {
- var res = [];
- if (!n1.done) {
- res.push(n1.value);
- n1 = iter1.next();
- }
- if (!n2.done) {
- res.push(n2.value);
- n2 = iter2.next();
- }
-
- yield res;
+ if (!n2.done) {
+ res.push(n2.value);
+ n2 = iter2.next();
}
- };
+
+ yield res;
+ }
+};
}());
diff --git a/jstests/readonly/temp_collection.js b/jstests/readonly/temp_collection.js
index 5f32d723b71..adb10506d19 100644
--- a/jstests/readonly/temp_collection.js
+++ b/jstests/readonly/temp_collection.js
@@ -15,11 +15,9 @@ runReadOnlyTest((function() {
writableDB[collName].drop();
assert.commandWorked(writableDB.runCommand({
- applyOps: [{
- op: "c",
- ns: writableDB.getName() + ".$cmd",
- o: {create: collName, temp: true}
- }]
+ applyOps: [
+ {op: "c", ns: writableDB.getName() + ".$cmd", o: {create: collName, temp: true}}
+ ]
}));
var collectionInfos = writableDB.getCollectionInfos();