1
- /*jshint strict: false */
1
+ /*jshint strict: false, sub: true */
2
2
/*global require, exports */
3
3
4
4
////////////////////////////////////////////////////////////////////////////////
@@ -228,27 +228,27 @@ function findTopDir () {
228
228
function makeTestingArgs ( appDir ) {
229
229
var topDir = findTopDir ( ) ;
230
230
fs . makeDirectoryRecursive ( appDir , true ) ;
231
- return [ "-- configuration", "none" ,
232
- "-- server.keyfile" , fs . join ( topDir , "UnitTests" , "server.pem" ) ,
233
- "-- database.maximal-journal-size" , "1048576" ,
234
- "-- database.force-sync-properties" , "false" ,
235
- "-- javascript.app-path" , appDir ,
236
- "-- javascript.startup-directory" , fs . join ( topDir , "js" ) ,
237
- "-- ruby.modules-path" , fs . join ( topDir , "mr" , "common" , "modules" ) ,
238
- "-- server.threads" , "20" ,
239
- "-- javascript.v8-contexts" , "5" ,
240
- "-- server.disable-authentication" , "true" ,
241
- "-- server.allow-use-database" , "true" ] ;
231
+ return { " configuration": "none" ,
232
+ "server.keyfile" : fs . join ( topDir , "UnitTests" , "server.pem" ) ,
233
+ "database.maximal-journal-size" : "1048576" ,
234
+ "database.force-sync-properties" : "false" ,
235
+ "javascript.app-path" : appDir ,
236
+ "javascript.startup-directory" : fs . join ( topDir , "js" ) ,
237
+ "ruby.modules-path" : fs . join ( topDir , "mr" , "common" , "modules" ) ,
238
+ "server.threads" : "20" ,
239
+ "javascript.v8-contexts" : "5" ,
240
+ "server.disable-authentication" : "true" ,
241
+ "server.allow-use-database" : "true" } ;
242
242
}
243
243
244
244
function makeTestingArgsClient ( options ) {
245
245
var topDir = findTopDir ( ) ;
246
- return [ "-- configuration", "none" ,
247
- "-- javascript.startup-directory" , fs . join ( topDir , "js" ) ,
248
- "-- no-colors" ,
249
- "-- quiet" ,
250
- "-- server.username" , options . username ,
251
- "-- server.password" , options . password ] ;
246
+ return { " configuration": "none" ,
247
+ "javascript.startup-directory" : fs . join ( topDir , "js" ) ,
248
+ "no-colors" : "true ",
249
+ "quiet" : "true ",
250
+ "server.username" : options . username ,
251
+ "server.password" : options . password } ;
252
252
}
253
253
254
254
function makeAuthorisationHeaders ( options ) {
@@ -284,25 +284,25 @@ function startInstance (protocol, options, addArgs, testname) {
284
284
285
285
var endpoint ;
286
286
var pos ;
287
- var valgrindopts = [ ] ;
287
+ var valgrindopts = { } ;
288
288
if ( typeof ( options . valgrindargs ) === 'object' ) {
289
289
if ( _ . isArray ( options . valgrindargs ) ) {
290
290
valgrindopts = options . valgrindargs ;
291
291
}
292
292
else {
293
- valgrindopts = valgrindopts . concat ( toArgv ( options . valgrindargs , true ) ) ;
293
+ valgrindopts = _ . extend ( valgrindopts , options . valgrindargs ) ;
294
294
}
295
295
}
296
296
297
297
var dispatcher ;
298
298
if ( options . cluster ) {
299
299
var extraargs = makeTestingArgs ( appDir ) ;
300
- extraargs = extraargs . concat ( optionsExtraArgs ) ;
300
+ extraargs = _ . extend ( extraargs , optionsExtraArgs ) ;
301
301
if ( addArgs !== undefined ) {
302
- extraargs = extraargs . concat ( addArgs ) ;
302
+ extraargs = _ . extend ( extraargs , addArgs ) ;
303
303
}
304
304
dispatcher = { "endpoint" :"tcp://127.0.0.1:" ,
305
- "arangodExtraArgs" : extraargs ,
305
+ "arangodExtraArgs" : toArgv ( extraargs ) ,
306
306
"username" : "root" ,
307
307
"password" : "" } ;
308
308
print ( "Temporary cluster data and logs are in" , tmpDataDir ) ;
@@ -321,7 +321,7 @@ function startInstance (protocol, options, addArgs, testname) {
321
321
"logPath" : tmpDataDir ,
322
322
"useSSLonCoordinators" : protocol === "ssl" ,
323
323
"valgrind" : runInValgrind ,
324
- "valgrindopts" : valgrindopts ,
324
+ "valgrindopts" : toArgv ( valgrindopts , true ) ,
325
325
"valgrindXmlFileBase" : valgrindXmlFileBase ,
326
326
"valgrindTestname" : testname
327
327
} ) ;
@@ -356,35 +356,38 @@ function startInstance (protocol, options, addArgs, testname) {
356
356
var pf = new PortFinder ( [ 8529 + options . portOffset ] , dispatcher ) ;
357
357
var port = pf . next ( ) ;
358
358
instanceInfo . port = port ;
359
- var args = makeTestingArgs ( appDir ) ;
360
- args . push ( "--server.endpoint" ) ;
361
359
endpoint = protocol + "://127.0.0.1:" + port ;
362
- args . push ( endpoint ) ;
363
- args . push ( "--database.directory" ) ;
364
- args . push ( fs . join ( tmpDataDir , "data" ) ) ;
360
+
361
+ var args = makeTestingArgs ( appDir ) ;
362
+ args [ "server.endpoint" ] = endpoint ;
363
+ args [ "database.directory" ] = fs . join ( tmpDataDir , "data" ) ;
365
364
fs . makeDirectoryRecursive ( fs . join ( tmpDataDir , "data" ) ) ;
366
- args . push ( "--log.file" ) ;
367
- args . push ( fs . join ( tmpDataDir , "log" ) ) ;
365
+ args [ "log.file" ] = fs . join ( tmpDataDir , "log" ) ;
368
366
if ( protocol === "ssl" ) {
369
- args . push ( "--server.keyfile" ) ;
370
- args . push ( fs . join ( "UnitTests" , "server.pem" ) ) ;
367
+ args [ "server.keyfile" ] = fs . join ( "UnitTests" , "server.pem" ) ;
371
368
}
372
- args = args . concat ( optionsExtraArgs ) ;
369
+ args = _ . extend ( args , optionsExtraArgs ) ;
373
370
374
371
if ( addArgs !== undefined ) {
375
- args = args . concat ( addArgs ) ;
372
+ args = _ . extend ( args , addArgs ) ;
376
373
}
377
374
if ( typeof ( options . valgrind ) === 'string' ) {
378
375
var run = fs . join ( "bin" , "arangod" ) ;
379
- valgrindopts = valgrindopts . concat (
380
- [ "--xml-file=" + options . valgrindXmlFileBase + '_' + testname + '.%p.xml' ,
381
- "--log-file=" + options . valgrindXmlFileBase + '_' + testname + '.%p.valgrind.log' ] ) ;
382
- var newargs = valgrindopts . concat ( [ run ] ) . concat ( args ) ;
376
+ var testfn = options . valgrindXmlFileBase ;
377
+ if ( testfn . length > 0 ) {
378
+ testfn += '_' ;
379
+ }
380
+ testfn += testname ;
381
+
382
+ valgrindopts [ "xml-file" ] = testfn + '.%p.xml' ;
383
+ valgrindopts [ "log-file" ] = testfn + '.%p.valgrind.log' ;
384
+ // Sequence: Valgrind arguments; binary to run; options to binary:
385
+ var newargs = toArgv ( valgrindopts , true ) . concat ( [ run ] ) . concat ( toArgv ( args ) ) ;
EED3
383
386
var cmdline = options . valgrind ;
384
387
instanceInfo . pid = executeExternal ( cmdline , newargs ) ;
385
388
}
386
389
else {
387
- instanceInfo . pid = executeExternal ( fs . join ( "bin" , "arangod" ) , args ) ;
390
+ instanceInfo . pid = executeExternal ( fs . join ( "bin" , "arangod" ) , toArgv ( args ) ) ;
388
391
}
389
392
}
390
393
@@ -831,16 +834,14 @@ function executeAndWait (cmd, args) {
831
834
function runInArangosh ( options , instanceInfo , file , addArgs ) {
832
835
var args = makeTestingArgsClient ( options ) ;
833
836
var topDir = findTopDir ( ) ;
834
- args . push ( "--server.endpoint" ) ;
835
- args . push ( instanceInfo . endpoint ) ;
836
- args . push ( "--javascript.unit-tests" ) ;
837
- args . push ( fs . join ( topDir , file ) ) ;
837
+ args [ "server.endpoint" ] = instanceInfo . endpoint ;
838
+ args [ "javascript.unit-tests" ] = fs . join ( topDir , file ) ;
838
839
if ( addArgs !== undefined ) {
839
- args = args . concat ( addArgs ) ;
840
+ args = _ . extend ( args , addArgs ) ;
840
841
}
841
842
var arangosh = fs . join ( "bin" , "arangosh" ) ;
842
843
var result ;
843
- var rc = executeAndWait ( arangosh , args ) ;
844
+ var rc = executeAndWait ( arangosh , toArgv ( args ) ) ;
844
845
try {
845
846
result = JSON . parse ( fs . read ( "testresult.json" ) ) ;
846
847
}
@@ -859,11 +860,10 @@ function runInArangosh (options, instanceInfo, file, addArgs) {
859
860
860
861
function runArangoshCmd ( options , instanceInfo , cmds ) {
861
862
var args = makeTestingArgsClient ( options ) ;
862
- args . push ( "--server.endpoint" ) ;
863
- args . push ( instanceInfo . endpoint ) ;
864
- args = args . concat ( cmds ) ;
863
+ args [ "server.endpoint" ] = instanceInfo . endpoint ;
864
+ var argv = toArgv ( args ) . concat ( cmds ) ;
865
865
var arangosh = fs . join ( "bin" , "arangosh" ) ;
866
- return executeAndWait ( arangosh , args ) ;
866
+ return executeAndWait ( arangosh , argv ) ;
867
867
}
868
868
869
869
function performTests ( options , testList , testname , remote ) {
@@ -1325,46 +1325,45 @@ testFuncs.ssl_server = function (options) {
1325
1325
1326
1326
function runArangoImp ( options , instanceInfo , what ) {
1327
1327
var topDir = findTopDir ( ) ;
1328
- var args = [ "--server.username" , options . username ,
1329
- "--server.password" , options . password ,
1330
- "--server.endpoint" , instanceInfo . endpoint ,
1331
- "--file" , fs . join ( topDir , what . data ) ,
1332
- "--collection" , what . coll ,
1333
- "--type" , what . type ] ;
1328
+ var args = {
1329
+ "server.username" : options . username ,
1330
+ "server.password" : options . password ,
1331
+ "server.endpoint" : instanceInfo . endpoint ,
1332
+ "file" : fs . join ( topDir , what . data ) ,
1333
+ "collection" : what . coll ,
1334
+ "type" : what . type
1335
+ } ;
1334
1336
if ( what . create !== undefined ) {
1335
- args . push ( "--create-collection" ) ;
1336
- args . push ( what . create ) ;
1337
+ args [ "create-collection" ] = what . create ;
1337
1338
}
1338
1339
if ( what . backslash !== undefined ) {
1339
- args . push ( "--backslash-escape" ) ;
1340
- args . push ( what . backslash ) ;
1340
+ args [ "backslash-escape" ] = what . backslash ;
1341
1341
}
1342
1342
if ( what . separator !== undefined ) {
1343
- args . push ( "--separator" ) ;
1344
- args . push ( what . separator ) ;
1343
+ args [ "separator" ] = what . separator ;
1345
1344
}
1346
1345
var arangoimp = fs . join ( "bin" , "arangoimp" ) ;
1347
- return executeAndWait ( arangoimp , args ) ;
1346
+ return executeAndWait ( arangoimp , toArgv ( args ) ) ;
1348
1347
}
1349
10000
1348
1350
1349
function runArangoDumpRestore ( options , instanceInfo , which , database ) {
1351
- var args = [ "--configuration" , "none" ,
1352
- "--server.username" , options . username ,
1353
- "--server.password" , options . password ,
1354
- "--server.endpoint" , instanceInfo . endpoint ,
1355
- "--server.database" , database ] ;
1350
+ var args = {
1351
+ "configuration" : "none" ,
1352
+ "server.username" : options . username ,
1353
+ "server.password" : options . password ,
1354
+ "server.endpoint" : instanceInfo . endpoint ,
1355
+ "server.database" : database
1356
+ } ;
1356
1357
var exe ;
1357
1358
if ( which === "dump" ) {
1358
- args . push ( "--output-directory" ) ;
1359
- args . push ( fs . join ( instanceInfo . tmpDataDir , "dump" ) ) ;
1359
+ args [ "output-directory" ] = fs . join ( instanceInfo . tmpDataDir , "dump" ) ;
1360
1360
exe = fs . join ( "bin" , "arangodump" ) ;
1361
1361
}
1362
1362
else {
1363
- args . push ( "--input-directory" ) ;
1364
- args . push ( fs . join ( instanceInfo . tmpDataDir , "dump" ) ) ;
1363
+ args [ "input-directory" ] = fs . join ( instanceInfo . tmpDataDir , "dump" ) ;
1365
1364
exe = fs . join ( "bin" , "arangorestore" ) ;
1366
1365
}
1367
- return executeAndWait ( exe , args ) ;
1366
+ return executeAndWait ( exe , toArgv ( args ) ) ;
1368
1367
}
1369
1368
1370
1369
function runArangoBenchmark ( options , instanceInfo , cmds ) {
@@ -1485,20 +1484,18 @@ testFuncs.upgrade = function (options) {
1485
1484
var pf = new PortFinder ( [ 8529 ] , dispatcher ) ;
1486
1485
var port = pf . next ( ) ;
1487
1486
var args = makeTestingArgs ( appDir ) ;
1488
- args . push ( "--server.endpoint" ) ;
1489
1487
var endpoint = "tcp://127.0.0.1:" + port ;
1490
- args . push ( endpoint ) ;
1491
- args . push ( "--database.directory" ) ;
1492
- args . push ( fs . join ( tmpDataDir , "data" ) ) ;
1488
+ args [ "server.endpoint" ] = endpoint ;
1489
+ args [ "database.directory" ] = fs . join ( tmpDataDir , "data" ) ;
1493
1490
fs . makeDirectoryRecursive ( fs . join ( tmpDataDir , "data" ) ) ;
1494
- args . push ( "--upgrade" ) ;
1495
- result . first = executeAndWait ( fs . join ( "bin" , "arangod" ) , args ) ;
1491
+ var argv = toArgv ( args ) . concat ( [ "--upgrade" ] ) ;
1492
+ result . first = executeAndWait ( fs . join ( "bin" , "arangod" ) , argv ) ;
1496
1493
1497
1494
if ( result . first !== 0 && ! options . force ) {
1498
1495
print ( "not removing " + tmpDataDir ) ;
1499
1496
return result ;
1500
1497
}
1501
- result . second = executeAndWait ( fs . join ( "bin" , "arangod" ) , args ) ;
1498
+ result . second = executeAndWait ( fs . join ( "bin" , "arangod" ) , argv ) ;
1502
1499
1503
1500
cleanupDirectories . push ( tmpDataDir ) ;
1504
1501
@@ -1566,7 +1563,7 @@ testFuncs.dump = function (options) {
1566
1563
print ( Date ( ) + ": Dump and Restore - dump 2" ) ;
1567
1564
results . test = runInArangosh ( options , instanceInfo ,
1568
1565
makePathUnix ( "js/server/tests/dump" + cluster + ".js" ) ,
1569
- [ "-- server.database", "UnitTestsDumpDst" ] ) ;
1566
+ { " server.database": "UnitTestsDumpDst" } ) ;
1570
1567
if ( checkInstanceAlive ( instanceInfo , options ) ) {
1571
1568
print ( Date ( ) + ": Dump and Restore - teardown" ) ;
1572
1569
results . tearDown = runInArangosh ( options , instanceInfo ,
@@ -1656,7 +1653,7 @@ testFuncs.arangob = function (options) {
1656
1653
testFuncs . authentication = function ( options ) {
1657
1654
print ( "Authentication tests..." ) ;
1658
1655
var instanceInfo = startInstance ( "tcp" , options ,
1659
- [ "-- server.disable-authentication", "false" ] ,
1656
+ { " server.disable-authentication": "false" } ,
1660
1657
"authentication" ) ;
1661
1658
if ( instanceInfo === false ) {
1662
1659
return { status : false , message : "failed to start server!" } ;
@@ -1686,12 +1683,12 @@ var urlsTodo = [
1686
1683
] ;
1687
1684
1688
1685
var authTestServerParams = [
1689
- [ "-- server.disable-authentication", "false" ,
C886
1690
- "-- server.authenticate-system-only" , "false" ] ,
1691
- [ "-- server.disable-authentication", "false" ,
1692
- "-- server.authenticate-system-only" , "true" ] ,
1693
- [ "-- server.disable-authentication", "true" ,
1694
- "-- server.authenticate-system-only" , "true" ]
1686
+ { " server.disable-authentication": "false" ,
1687
+ "server.authenticate-system-only" : "false" } ,
1688
+ { " server.disable-authentication": "false" ,
1689
+ "server.authenticate-system-only" : "true" } ,
1690
+ { " server.disable-authentication": "true" ,
1691
+ "server.authenticate-system-only" : "true" }
1695
1692
] ;
1696
1693
var authTestNames = [ "Full" ,
1697
1694
"SystemAuth" ,
@@ -1721,7 +1718,7 @@ testFuncs.authentication_parameters = function (options) {
1721
1718
var all_ok = true ;
1722
1719
var instanceInfo = startInstance ( "tcp" , options ,
1723
1720
authTestServerParams [ test ] ,
1724
- "authentication_parameters_" + test ) ;
1721
+ "authentication_parameters_" + authTestNames [ test ] ) ;
1725
1722
if ( instanceInfo === false ) {
1726
1723
return { status : false , message : authTestNames [ test ] + ": failed to start server!" } ;
1727
1724
}
0 commit comments