summaryrefslogtreecommitdiff
path: root/jstests/noPassthrough/unix_socket.js
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/noPassthrough/unix_socket.js
parent1e46b5049003f427047e723ea5fab15b5a9253ca (diff)
downloadmongo-134a4083953270e8a11430395357fb70a29047ad.tar.gz
SERVER-41772 Apply clang-format 7.0.1 to the codebase
Diffstat (limited to 'jstests/noPassthrough/unix_socket.js')
-rw-r--r--jstests/noPassthrough/unix_socket.js200
1 files changed, 100 insertions, 100 deletions
diff --git a/jstests/noPassthrough/unix_socket.js b/jstests/noPassthrough/unix_socket.js
index ff1a18afadf..fc1ad2abf58 100644
--- a/jstests/noPassthrough/unix_socket.js
+++ b/jstests/noPassthrough/unix_socket.js
@@ -10,112 +10,112 @@
*/
//@tags: [requires_sharding]
(function() {
- 'use strict';
- // This test will only work on POSIX machines.
- if (_isWindows()) {
- return;
- }
-
- // Do not fail if this test leaves unterminated processes because testSockOptions
- // is expected to throw before it calls stopMongod.
- TestData.failIfUnterminatedProcesses = false;
-
- var doesLogMatchRegex = function(logArray, regex) {
- for (let i = (logArray.length - 1); i >= 0; i--) {
- var regexInLine = regex.exec(logArray[i]);
- if (regexInLine != null) {
- return true;
- }
- }
- return false;
- };
-
- var checkSocket = function(path) {
- assert.eq(fileExists(path), true);
- var conn = new Mongo(path);
- assert.commandWorked(conn.getDB("admin").runCommand("ping"),
- `Expected ping command to succeed for ${path}`);
- };
-
- var testSockOptions = function(bindPath, expectSockPath, optDict, bindSep = ',', optMongos) {
- var optDict = optDict || {};
- if (bindPath) {
- optDict["bind_ip"] = `${MongoRunner.dataDir}/${bindPath}${bindSep}127.0.0.1`;
+'use strict';
+// This test will only work on POSIX machines.
+if (_isWindows()) {
+ return;
+}
+
+// Do not fail if this test leaves unterminated processes because testSockOptions
+// is expected to throw before it calls stopMongod.
+TestData.failIfUnterminatedProcesses = false;
+
+var doesLogMatchRegex = function(logArray, regex) {
+ for (let i = (logArray.length - 1); i >= 0; i--) {
+ var regexInLine = regex.exec(logArray[i]);
+ if (regexInLine != null) {
+ return true;
}
+ }
+ return false;
+};
+
+var checkSocket = function(path) {
+ assert.eq(fileExists(path), true);
+ var conn = new Mongo(path);
+ assert.commandWorked(conn.getDB("admin").runCommand("ping"),
+ `Expected ping command to succeed for ${path}`);
+};
+
+var testSockOptions = function(bindPath, expectSockPath, optDict, bindSep = ',', optMongos) {
+ var optDict = optDict || {};
+ if (bindPath) {
+ optDict["bind_ip"] = `${MongoRunner.dataDir}/${bindPath}${bindSep}127.0.0.1`;
+ }
- var conn, shards;
- if (optMongos) {
- shards = new ShardingTest({shards: 1, mongos: 1, other: {mongosOptions: optDict}});
- assert.neq(shards, null, "Expected cluster to start okay");
- conn = shards.s0;
- } else {
- conn = MongoRunner.runMongod(optDict);
- }
+ var conn, shards;
+ if (optMongos) {
+ shards = new ShardingTest({shards: 1, mongos: 1, other: {mongosOptions: optDict}});
+ assert.neq(shards, null, "Expected cluster to start okay");
+ conn = shards.s0;
+ } else {
+ conn = MongoRunner.runMongod(optDict);
+ }
- assert.neq(conn, null, `Expected ${optMongos ? "mongos" : "mongod"} to start okay`);
+ assert.neq(conn, null, `Expected ${optMongos ? "mongos" : "mongod"} to start okay`);
- const defaultUNIXSocket = `/tmp/mongodb-${conn.port}.sock`;
- var checkPath = defaultUNIXSocket;
- if (expectSockPath) {
- checkPath = `${MongoRunner.dataDir}/${expectSockPath}`;
- }
+ const defaultUNIXSocket = `/tmp/mongodb-${conn.port}.sock`;
+ var checkPath = defaultUNIXSocket;
+ if (expectSockPath) {
+ checkPath = `${MongoRunner.dataDir}/${expectSockPath}`;
+ }
- checkSocket(checkPath);
+ checkSocket(checkPath);
- // Test the naming of the unix socket
- var log = conn.adminCommand({getLog: 'global'});
- assert.commandWorked(log, "Expected getting the log to work");
- var ll = log.log;
- var re = new RegExp("anonymous unix socket");
- assert(doesLogMatchRegex(ll, re), "Log message did not contain 'anonymous unix socket'");
+ // Test the naming of the unix socket
+ var log = conn.adminCommand({getLog: 'global'});
+ assert.commandWorked(log, "Expected getting the log to work");
+ var ll = log.log;
+ var re = new RegExp("anonymous unix socket");
+ assert(doesLogMatchRegex(ll, re), "Log message did not contain 'anonymous unix socket'");
- if (optMongos) {
- shards.stop();
- } else {
- MongoRunner.stopMongod(conn);
- }
+ if (optMongos) {
+ shards.stop();
+ } else {
+ MongoRunner.stopMongod(conn);
+ }
- assert.eq(fileExists(checkPath), false);
- };
-
- // Check that the default unix sockets work
- testSockOptions();
- testSockOptions(undefined, undefined, undefined, ',', true);
-
- // Check that a custom unix socket path works
- testSockOptions("testsock.socket", "testsock.socket");
- testSockOptions("testsock.socket", "testsock.socket", undefined, ',', true);
-
- // Check that a custom unix socket path works with spaces
- testSockOptions("test sock.socket", "test sock.socket");
- testSockOptions("test sock.socket", "test sock.socket", undefined, ',', true);
-
- // Check that a custom unix socket path works with spaces before the comma and after
- testSockOptions("testsock.socket ", "testsock.socket", undefined, ', ');
- testSockOptions("testsock.socket ", "testsock.socket", undefined, ', ', true);
-
- // Check that a bad UNIX path breaks
- assert.throws(function() {
- var badname = "a".repeat(200) + ".socket";
- testSockOptions(badname, badname);
- });
-
- // Check that if UNIX sockets are disabled that we aren't able to connect over UNIX sockets
- assert.throws(function() {
- testSockOptions(undefined, undefined, {nounixsocket: ""});
- });
-
- // Check the unixSocketPrefix option
- var socketPrefix = `${MongoRunner.dataDir}/socketdir`;
- mkdir(socketPrefix);
- var port = allocatePort();
- testSockOptions(
- undefined, `socketdir/mongodb-${port}.sock`, {unixSocketPrefix: socketPrefix, port: port});
-
- port = allocatePort();
- testSockOptions(undefined,
- `socketdir/mongodb-${port}.sock`,
- {unixSocketPrefix: socketPrefix, port: port},
- ',',
- true);
+ assert.eq(fileExists(checkPath), false);
+};
+
+// Check that the default unix sockets work
+testSockOptions();
+testSockOptions(undefined, undefined, undefined, ',', true);
+
+// Check that a custom unix socket path works
+testSockOptions("testsock.socket", "testsock.socket");
+testSockOptions("testsock.socket", "testsock.socket", undefined, ',', true);
+
+// Check that a custom unix socket path works with spaces
+testSockOptions("test sock.socket", "test sock.socket");
+testSockOptions("test sock.socket", "test sock.socket", undefined, ',', true);
+
+// Check that a custom unix socket path works with spaces before the comma and after
+testSockOptions("testsock.socket ", "testsock.socket", undefined, ', ');
+testSockOptions("testsock.socket ", "testsock.socket", undefined, ', ', true);
+
+// Check that a bad UNIX path breaks
+assert.throws(function() {
+ var badname = "a".repeat(200) + ".socket";
+ testSockOptions(badname, badname);
+});
+
+// Check that if UNIX sockets are disabled that we aren't able to connect over UNIX sockets
+assert.throws(function() {
+ testSockOptions(undefined, undefined, {nounixsocket: ""});
+});
+
+// Check the unixSocketPrefix option
+var socketPrefix = `${MongoRunner.dataDir}/socketdir`;
+mkdir(socketPrefix);
+var port = allocatePort();
+testSockOptions(
+ undefined, `socketdir/mongodb-${port}.sock`, {unixSocketPrefix: socketPrefix, port: port});
+
+port = allocatePort();
+testSockOptions(undefined,
+ `socketdir/mongodb-${port}.sock`,
+ {unixSocketPrefix: socketPrefix, port: port},
+ ',',
+ true);
})();