Skip to content

Commit db75344

Browse files
committed
PSMDB-1786: fix formatting
Fix formatting using: - `buildscripts/clang_format.py format` - `buildscripts/pylinters.py fix` - `buildscripts/pylinters.py fix-scons` - `buildscripts/eslint.py fix`
1 parent 235c344 commit db75344

File tree

207 files changed

+5483
-5523
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

207 files changed

+5483
-5523
lines changed

SConstruct

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ def has_option(name):
9292
# if the value is falsish (empty string, None, etc.), coerce to False.
9393
return True if optval == () else bool(optval)
9494

95+
9596
def use_system_version_of_library(name):
9697
return has_option('use-system-all') or has_option('use-system-' + name)
9798

@@ -2657,7 +2658,6 @@ def link_guard_libdeps_tag_expand(source, target, env, for_signature):
26572658

26582659
env['LIBDEPS_TAG_EXPANSIONS'].append(link_guard_libdeps_tag_expand)
26592660

2660-
26612661
env.Tool('forceincludes')
26622662

26632663
# ---- other build setup -----

buildscripts/setup_multiversion_mongodb.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,9 @@ def download_links(self):
153153
"""Return the download and generic download links."""
154154
temp_file = tempfile.mktemp()
155155
# the upstream file was at: https://downloads.mongodb.org/full.json
156-
download_file("https://raw.githubusercontent.com/Percona-QA/psmdb-misc-scripts/master/psmdb_download_links.json", temp_file)
156+
download_file(
157+
"https://raw.githubusercontent.com/Percona-QA/psmdb-misc-scripts/master/psmdb_download_links.json",
158+
temp_file)
157159
with open(temp_file) as file_handle:
158160
full_json = json.load(file_handle)
159161
os.remove(temp_file)

jstests/audit/_audit_helpers.js

Lines changed: 102 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
var getDBPath = function() {
2-
return MongoRunner.dataDir !== undefined ?
3-
MongoRunner.dataDir : '/data/db';
1+
var getDBPath =
2+
function() {
3+
return MongoRunner.dataDir !== undefined ? MongoRunner.dataDir : '/data/db';
44
}
55

6-
var auditTest = function(name, fn, serverParams) {
7-
var loudTestEcho = function(msg) {
8-
s = '----------------------------- AUDIT UNIT TEST: ' + msg + '-----------------------------';
6+
var auditTest =
7+
function(name, fn, serverParams) {
8+
var loudTestEcho =
9+
function(msg) {
10+
s = '----------------------------- AUDIT UNIT TEST: ' + msg +
11+
'-----------------------------';
912
print(Array(s.length + 1).join('-'));
1013
print(s);
1114
}
@@ -20,101 +23,110 @@ var auditTest = function(name, fn, serverParams) {
2023
var startServer = function(extraParams) {
2124
params = Object.merge(mongodOptions(serverParams), extraParams);
2225
if (serverParams === undefined || serverParams.config === undefined) {
23-
params = Object.merge({
24-
auditDestination: 'file',
25-
auditPath: auditPath,
26-
auditFormat: 'JSON'
27-
}, params);
26+
params = Object.merge(
27+
{auditDestination: 'file', auditPath: auditPath, auditFormat: 'JSON'}, params);
2828
}
29-
conn = MongoRunner.runMongod(
30-
Object.merge({
31-
port: port,
32-
dbpath: dbpath,
33-
}, params)
34-
);
29+
conn = MongoRunner.runMongod(Object.merge({
30+
port: port,
31+
dbpath: dbpath,
32+
},
33+
params));
3534
return conn;
36-
}
37-
var stopServer = function() {
35+
} var stopServer = function() {
3836
MongoRunner.stopMongod(conn);
39-
}
40-
var restartServer = function() {
37+
} var restartServer = function() {
4138
stopServer();
42-
return startServer({ noCleanData: true });
43-
}
44-
try {
39+
return startServer({noCleanData: true});
40+
} try {
4541
fn(startServer(), restartServer);
4642
} finally {
4743
MongoRunner.stopMongod(conn);
4844
}
4945
loudTestEcho(name + ' PASSED ');
5046
}
5147

52-
var auditTestRepl = function(name, fn, serverParams) {
53-
var loudTestEcho = function(msg) {
54-
s = '----------------------------- AUDIT REPL UNIT TEST: ' + msg + '-----------------------------';
48+
var auditTestRepl =
49+
function(name, fn, serverParams) {
50+
var loudTestEcho =
51+
function(msg) {
52+
s = '----------------------------- AUDIT REPL UNIT TEST: ' + msg +
53+
'-----------------------------';
5554
print(Array(s.length + 1).join('-'));
5655
print(s);
5756
}
5857

5958
loudTestEcho(name + ' STARTING ');
60-
var replTest = new ReplSetTest({ name: 'auditTestReplSet', cleanData: true, nodes: 2, nodeOptions: mongodOptions(serverParams) });
61-
replTest.startSet({ auditDestination: 'file' });
59+
var replTest = new ReplSetTest({
60+
name: 'auditTestReplSet',
61+
cleanData: true,
62+
nodes: 2,
63+
nodeOptions: mongodOptions(serverParams)
64+
});
65+
replTest.startSet({auditDestination: 'file'});
6266
var config = {
6367
_id: 'auditTestReplSet',
6468
members: [
65-
{ _id: 0, host: getHostName() + ":" + replTest.ports[0], priority: 2 },
66-
{ _id: 1, host: getHostName() + ":" + replTest.ports[1], priority: 1 },
69+
{_id: 0, host: getHostName() + ":" + replTest.ports[0], priority: 2},
70+
{_id: 1, host: getHostName() + ":" + replTest.ports[1], priority: 1},
6771
]
6872
};
6973
replTest.initiate(config);
7074
fn(replTest);
7175
loudTestEcho(name + ' PASSED ');
7276
}
7377

74-
var auditTestShard = function(name, fn, serverParams) {
75-
var loudTestEcho = function(msg) {
76-
s = '----------------------------- AUDIT SHARDED UNIT TEST: ' + msg + '-----------------------------';
78+
var auditTestShard =
79+
function(name, fn, serverParams) {
80+
var loudTestEcho =
81+
function(msg) {
82+
s = '----------------------------- AUDIT SHARDED UNIT TEST: ' + msg +
83+
'-----------------------------';
7784
print(Array(s.length + 1).join('-'));
7885
print(s);
7986
}
8087

8188
loudTestEcho(name + ' STARTING ');
8289

8390
var dbpath = getDBPath();
84-
var st = new ShardingTest({ name: 'auditTestSharding',
85-
verbose: 1,
86-
mongos: [
87-
Object.merge({
88-
auditPath: dbpath + '/auditLog-s0.json',
89-
auditDestination: 'file',
90-
auditFormat: 'JSON'
91-
}, serverParams),
92-
Object.merge({
93-
auditPath: dbpath + '/auditLog-s1.json',
94-
auditDestination: 'file',
95-
auditFormat: 'JSON'
96-
}, serverParams),
97-
],
98-
shards: [
99-
Object.merge({
100-
auditPath: dbpath + '/auditLog-d0.json',
101-
auditDestination: 'file',
102-
auditFormat: 'JSON'
103-
}, mongodOptions(serverParams)),
104-
Object.merge({
105-
auditPath: dbpath + '/auditLog-d1.json',
106-
auditDestination: 'file',
107-
auditFormat: 'JSON'
108-
}, mongodOptions(serverParams))
109-
],
110-
config: {
111-
configOptions: {
112-
auditPath: dbpath + '/auditLog-c0.json',
113-
auditDestination: 'file',
114-
auditFormat: 'JSON'
115-
},
116-
},
117-
});
91+
var st = new ShardingTest({
92+
name: 'auditTestSharding',
93+
verbose: 1,
94+
mongos: [
95+
Object.merge({
96+
auditPath: dbpath + '/auditLog-s0.json',
97+
auditDestination: 'file',
98+
auditFormat: 'JSON'
99+
},
100+
serverParams),
101+
Object.merge({
102+
auditPath: dbpath + '/auditLog-s1.json',
103+
auditDestination: 'file',
104+
auditFormat: 'JSON'
105+
},
106+
serverParams),
107+
],
108+
shards: [
109+
Object.merge({
110+
auditPath: dbpath + '/auditLog-d0.json',
111+
auditDestination: 'file',
112+
auditFormat: 'JSON'
113+
},
114+
mongodOptions(serverParams)),
115+
Object.merge({
116+
auditPath: dbpath + '/auditLog-d1.json',
117+
auditDestination: 'file',
118+
auditFormat: 'JSON'
119+
},
120+
mongodOptions(serverParams))
121+
],
122+
config: {
123+
configOptions: {
124+
auditPath: dbpath + '/auditLog-c0.json',
125+
auditDestination: 'file',
126+
auditFormat: 'JSON'
127+
},
128+
},
129+
});
118130
try {
119131
fn(st);
120132
} finally {
@@ -130,15 +142,16 @@ var getAuditEventsCollection =
130142
var adminDB = m.getDB('admin');
131143
var auth = ((useAuth !== undefined) && (useAuth != false)) ? true : false;
132144
if (auth) {
133-
assert(adminDB.auth('admin','admin'), "could not auth as admin (pwd admin)");
145+
assert(adminDB.auth('admin', 'admin'), "could not auth as admin (pwd admin)");
134146
}
135147

136148
// the audit log is specifically parsable by mongoimport,
137149
// so we use that to conveniently read its contents.
138150
var auditOptions = adminDB.runCommand('auditGetOptions');
139151
var auditPath = auditOptions.path;
140152
var auditCollectionName = 'auditCollection';
141-
return loadAuditEventsIntoCollection(m, auditPath, dbname, auditCollectionName, primary, auth, loadRotated);
153+
return loadAuditEventsIntoCollection(
154+
m, auditPath, dbname, auditCollectionName, primary, auth, loadRotated);
142155
}
143156

144157
function dirname(path) {
@@ -208,7 +221,7 @@ var loadAuditEventsIntoCollection =
208221
// Those extra events won't affect our tests because all tests search
209222
// events only in strict time range (beforeCmd, beforeLoad).
210223
var fooColl = db.getCollection('foo' + Date.now());
211-
fooColl.insert({a:1});
224+
fooColl.insert({a: 1});
212225
fooColl.drop();
213226
sleep(110);
214227

@@ -231,42 +244,44 @@ var loadAuditEventsIntoCollection =
231244
// because during some runs of audit_<something>_sharding.js tests
232245
// we observed "logout" records with identical timestamps
233246
assert.commandWorked(auditCollection.createIndex(
234-
{ atype: 1, ts: 1, local: 1, remote: 1, users: 1, param: 1, result: 1 },
235-
{ unique: false }
236-
));
247+
{atype: 1, ts: 1, local: 1, remote: 1, users: 1, param: 1, result: 1}, {unique: false}));
237248

238249
return auditCollection;
239250
}
240251

241252
// Get a query that matches any timestamp generated in the interval
242253
// of (t - n) <= t <= now for some time t.
243-
var withinFewSecondsBefore = function(t, n) {
254+
var withinFewSecondsBefore =
255+
function(t, n) {
244256
fewSecondsAgo = t - ((n !== undefined ? n : 3) * 1000);
245-
return { '$gte' : new Date(fewSecondsAgo), '$lte': new Date() };
257+
return {'$gte': new Date(fewSecondsAgo), '$lte': new Date()};
246258
}
247259

248260
// Get a query that matches any timestamp generated in the interval
249261
// of t <= x <= e for some timestamps t and e.
250-
var withinInterval = function(t, e = Date.now()) {
251-
return { '$gte': new Date(t), '$lte': new Date(e) };
262+
var withinInterval =
263+
function(t, e = Date.now()) {
264+
return {'$gte': new Date(t), '$lte': new Date(e)};
252265
}
253266

254267
// Create Admin user. Used for authz tests.
255-
var createAdminUserForAudit = function (m) {
268+
var createAdminUserForAudit =
269+
function(m) {
256270
var adminDB = m.getDB('admin');
257-
adminDB.createUser( {'user':'admin',
258-
'pwd':'admin',
259-
'roles' : ['readWriteAnyDatabase',
260-
'userAdminAnyDatabase',
261-
'clusterAdmin']} );
271+
adminDB.createUser({
272+
'user': 'admin',
273+
'pwd': 'admin',
274+
'roles': ['readWriteAnyDatabase', 'userAdminAnyDatabase', 'clusterAdmin']
275+
});
262276
}
263277

264278
// Creates a User with limited permissions. Used for authz tests.
265-
var createNoPermissionUserForAudit = function (m, db) {
279+
var createNoPermissionUserForAudit =
280+
function(m, db) {
266281
var passwordUserNameUnion = 'tom';
267282
var adminDB = m.getDB('admin');
268-
adminDB.auth('admin','admin');
269-
db.createUser( {'user':'tom', 'pwd':'tom', 'roles':[]} );
283+
adminDB.auth('admin', 'admin');
284+
db.createUser({'user': 'tom', 'pwd': 'tom', 'roles': []});
270285
adminDB.logout();
271286
return passwordUserNameUnion;
272287
}

jstests/audit/audit_add_shard.js

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,34 +6,34 @@ if (TestData.testData !== undefined) {
66
load('jstests/audit/_audit_helpers.js');
77
}
88

9-
auditTestShard(
10-
'addShard',
11-
function(st) {
12-
let rsname = "testreplset";
13-
var port = allocatePorts(10)[9];
14-
var conn1 = MongoRunner.runMongod({dbpath: getDBPath() + '/' + jsTestName() + '-extraShard-' + port, port: port, shardsvr: "", replSet: rsname});
15-
var hostandport = conn1.host;
16-
assert.commandWorked(conn1.adminCommand({
17-
replSetInitiate: {
18-
"_id": rsname,
19-
"members": [{"_id": 0, "host": hostandport}]
20-
}
21-
}));
9+
auditTestShard('addShard', function(st) {
10+
let rsname = "testreplset";
11+
var port = allocatePorts(10)[9];
12+
var conn1 = MongoRunner.runMongod({
13+
dbpath: getDBPath() + '/' + jsTestName() + '-extraShard-' + port,
14+
port: port,
15+
shardsvr: "",
16+
replSet: rsname
17+
});
18+
var hostandport = conn1.host;
19+
assert.commandWorked(conn1.adminCommand(
20+
{replSetInitiate: {"_id": rsname, "members": [{"_id": 0, "host": hostandport}]}}));
2221

23-
let connstr = rsname + "/" + hostandport;
24-
const beforeCmd = Date.now();
25-
assert.commandWorked(st.s0.adminCommand({addshard: connstr}));
22+
let connstr = rsname + "/" + hostandport;
23+
const beforeCmd = Date.now();
24+
assert.commandWorked(st.s0.adminCommand({addshard: connstr}));
2625

27-
const beforeLoad = Date.now();
28-
auditColl = loadAuditEventsIntoCollection(st.s0, getDBPath() + '/auditLog-s0.json', jsTestName(), 'auditEvents');
29-
assert.eq(1, auditColl.count({
30-
atype: "addShard",
31-
ts: withinInterval(beforeCmd, beforeLoad),
32-
'param.connectionString': connstr,
33-
result: 0,
34-
}), "FAILED, audit log: " + tojson(auditColl.find().toArray()));
26+
const beforeLoad = Date.now();
27+
auditColl = loadAuditEventsIntoCollection(
28+
st.s0, getDBPath() + '/auditLog-s0.json', jsTestName(), 'auditEvents');
29+
assert.eq(1,
30+
auditColl.count({
31+
atype: "addShard",
32+
ts: withinInterval(beforeCmd, beforeLoad),
33+
'param.connectionString': connstr,
34+
result: 0,
35+
}),
36+
"FAILED, audit log: " + tojson(auditColl.find().toArray()));
3537

36-
MongoRunner.stopMongod(conn1);
37-
},
38-
{ /* no special mongod options */ }
39-
);
38+
MongoRunner.stopMongod(conn1);
39+
}, {/* no special mongod options */});

0 commit comments

Comments
 (0)