summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamran Khan <kamran.khan@mongodb.com>2015-11-13 12:32:15 -0500
committerKamran Khan <kamran.khan@mongodb.com>2015-11-13 12:32:15 -0500
commit15376bdb5345ed321baa7c456237e9439f8e7549 (patch)
treebeddf25ac979c7d0cb59eff9a25c7148e3c0bee1
parentcd766108b26e7e272f3c367f9de8767399feeadd (diff)
downloadmongo-15376bdb5345ed321baa7c456237e9439f8e7549.tar.gz
SERVER-20941 Update v8-specific code and comments in JS tests
The switch to SpiderMonkey invalidated some of the code and comments.
-rw-r--r--jstests/concurrency/fsm_libs/worker_thread.js4
-rw-r--r--jstests/core/constructors.js38
-rw-r--r--jstests/core/dbadmin.js2
-rw-r--r--jstests/core/evald.js3
-rw-r--r--jstests/core/mr_bigobject.js1
-rw-r--r--jstests/core/numberint.js2
-rw-r--r--jstests/core/or4.js7
-rw-r--r--jstests/core/rename.js2
-rw-r--r--jstests/core/sorta.js43
-rw-r--r--jstests/libs/parallelTester.js3
-rw-r--r--jstests/parallel/manyclients.js1
-rw-r--r--jstests/sharding/major_version_check.js22
-rw-r--r--jstests/sharding/mr_shard_version.js2
-rw-r--r--jstests/slow2/mr_during_migrate.js4
14 files changed, 57 insertions, 77 deletions
diff --git a/jstests/concurrency/fsm_libs/worker_thread.js b/jstests/concurrency/fsm_libs/worker_thread.js
index 5d256677075..0e785195b5e 100644
--- a/jstests/concurrency/fsm_libs/worker_thread.js
+++ b/jstests/concurrency/fsm_libs/worker_thread.js
@@ -53,8 +53,8 @@ var workerThread = (function() {
// workload A. The $config.data of workload B can define a
// function that closes over the $config object of workload A
// (known as $super to workload B). This reference is lost when
- // the config object is serialized through BSON into the V8 isolate,
- // which results in undefined variables in the derived workload.
+ // the config object is serialized to BSON, which results in
+ // undefined variables in the derived workload.
var data = Object.extend({}, args.data[workload], true);
data = Object.extend(data, config.data, true);
diff --git a/jstests/core/constructors.js b/jstests/core/constructors.js
index d42b5638926..2f75a1fad18 100644
--- a/jstests/core/constructors.js
+++ b/jstests/core/constructors.js
@@ -284,28 +284,22 @@ dbEvalConstructorTest(md5Constructors);
dbEvalConstructorTest(hexdataConstructors);
dbEvalConstructorTest(dateConstructors);
-// SERVER-8963
-if (db.runCommand({buildinfo:1}).javascriptEngine == "V8") {
- mapReduceConstructorTest(dbrefConstructors);
- mapReduceConstructorTest(dbpointerConstructors);
- mapReduceConstructorTest(objectidConstructors);
- mapReduceConstructorTest(timestampConstructors);
- mapReduceConstructorTest(bindataConstructors);
- mapReduceConstructorTest(uuidConstructors);
- mapReduceConstructorTest(md5Constructors);
- mapReduceConstructorTest(hexdataConstructors);
-}
+mapReduceConstructorTest(dbrefConstructors);
+mapReduceConstructorTest(dbpointerConstructors);
+mapReduceConstructorTest(objectidConstructors);
+mapReduceConstructorTest(timestampConstructors);
+mapReduceConstructorTest(bindataConstructors);
+mapReduceConstructorTest(uuidConstructors);
+mapReduceConstructorTest(md5Constructors);
+mapReduceConstructorTest(hexdataConstructors);
mapReduceConstructorTest(dateConstructors);
-// SERVER-8963
-if (db.runCommand({buildinfo:1}).javascriptEngine == "V8") {
- whereConstructorTest(dbrefConstructors);
- whereConstructorTest(dbpointerConstructors);
- whereConstructorTest(objectidConstructors);
- whereConstructorTest(timestampConstructors);
- whereConstructorTest(bindataConstructors);
- whereConstructorTest(uuidConstructors);
- whereConstructorTest(md5Constructors);
- whereConstructorTest(hexdataConstructors);
-}
+whereConstructorTest(dbrefConstructors);
+whereConstructorTest(dbpointerConstructors);
+whereConstructorTest(objectidConstructors);
+whereConstructorTest(timestampConstructors);
+whereConstructorTest(bindataConstructors);
+whereConstructorTest(uuidConstructors);
+whereConstructorTest(md5Constructors);
+whereConstructorTest(hexdataConstructors);
whereConstructorTest(dateConstructors);
diff --git a/jstests/core/dbadmin.js b/jstests/core/dbadmin.js
index d1711e88b0f..02644a054fe 100644
--- a/jstests/core/dbadmin.js
+++ b/jstests/core/dbadmin.js
@@ -92,5 +92,5 @@ for (var i = 0; i < (versionArray.length - 1); i++) if (versionArray[i] >= 0) {
assert.eq(serverStatus.version, latestStartUpLog.buildinfo.version, "Mongo version doesn't match that from ServerStatus");
assert.eq(version, versionArrayCleaned.join('.'), "version doesn't match that from the versionArray");
var jsEngine = latestStartUpLog.buildinfo.javascriptEngine;
-assert((jsEngine.startsWith("v8") || jsEngine == "none" || jsEngine.startsWith("mozjs")));
+assert((jsEngine == "none") || jsEngine.startsWith("mozjs"));
assert.eq(isMaster.maxBsonObjectSize, latestStartUpLog.buildinfo.maxBsonObjectSize, "maxBsonObjectSize doesn't match one from ismaster");
diff --git a/jstests/core/evald.js b/jstests/core/evald.js
index 031c0f802ef..02b7beb3e43 100644
--- a/jstests/core/evald.js
+++ b/jstests/core/evald.js
@@ -72,8 +72,7 @@ doIt("while(1) { for( var i = 0; i < 10000; ++i ) {;} db.jstests_evald.count({i:
doIt("while(1) { for( var i = 0; i < 10000; ++i ) {;} db.jstests_evald.count(); }", true);
doIt("while(1) { for( var i = 0; i < 10000; ++i ) {;} db.jstests_evald.count(); }", false);
-// try/catch with tight-loop kill tests. Catch testing is important
-// due to v8::TerminateExecution internals.
+// try/catch with tight-loop kill tests.
// native callback with nested invoke(), drop JS exceptions
doIt("while(1) { " +
" for(var i = 0; i < 10000; ++i) {;} " +
diff --git a/jstests/core/mr_bigobject.js b/jstests/core/mr_bigobject.js
index 97195e2542e..00ef8af2b9b 100644
--- a/jstests/core/mr_bigobject.js
+++ b/jstests/core/mr_bigobject.js
@@ -2,7 +2,6 @@
t = db.mr_bigobject
t.drop()
-// v8 requires large start string, otherwise UTF16
var large = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
var s = large;
while ( s.length < ( 6 * 1024 * 1024 ) ){
diff --git a/jstests/core/numberint.js b/jstests/core/numberint.js
index 258450f8e82..86550f06214 100644
--- a/jstests/core/numberint.js
+++ b/jstests/core/numberint.js
@@ -46,7 +46,7 @@ a.a = n;
p = tojson( a );
assert.eq.automsg( "'{ \"a\" : NumberInt(-11111) }'", "p" );
-// parsing: v8 evaluates not numbers to 0 which is not bad
+// parsing: SpiderMonkey evaluates non-numeric strings as 0, which is not bad
//assert.throws.automsg( function() { new NumberInt( "" ); } );
//assert.throws.automsg( function() { new NumberInt( "y" ); } );
diff --git a/jstests/core/or4.js b/jstests/core/or4.js
index 8d624759c34..02242b379fe 100644
--- a/jstests/core/or4.js
+++ b/jstests/core/or4.js
@@ -1,13 +1,6 @@
t = db.jstests_or4;
t.drop();
-// v8 does not have a builtin Array.sort
-if (!Array.sort) {
- Array.sort = function(arr) {
- return arr.sort();
- };
-}
-
checkArrs = function( a, b ) {
m = "[" + a + "] != [" + b + "]";
a = eval( a );
diff --git a/jstests/core/rename.js b/jstests/core/rename.js
index 9c3ce2c18b2..b2695d95e0f 100644
--- a/jstests/core/rename.js
+++ b/jstests/core/rename.js
@@ -33,7 +33,7 @@ c.drop();
// TODO: too many numbers hard coded here
// this test depends precisely on record size and hence may not be very reliable
-// note we use floats to make sure numbers are represented as doubles for both SM and v8, since test relies on record size
+// note we use floats to make sure numbers are represented as doubles for SpiderMonkey, since test relies on record size
db.createCollection( "jstests_rename_a", {capped:true,size:10000} );
for( i = 0.1; i < 10; ++i ) {
a.save( { i: i } );
diff --git a/jstests/core/sorta.js b/jstests/core/sorta.js
index 7c82778a186..2b78b8493e4 100644
--- a/jstests/core/sorta.js
+++ b/jstests/core/sorta.js
@@ -1,26 +1,29 @@
// SERVER-2905 sorting with missing fields
-t = db.jstests_sorta;
-t.drop();
+(function() {
+ 'use strict';
-// Enable _allow_dot to try and bypass v8 field name checking.
-t.insert( {_id:0,a:MinKey}, true );
-t.save( {_id:3,a:null} );
-t.save( {_id:1,a:[]} );
-t.save( {_id:7,a:[2]} );
-t.save( {_id:4} );
-t.save( {_id:5,a:null} );
-t.save( {_id:2,a:[]} );
-t.save( {_id:6,a:1} );
-t.insert( {_id:8,a:MaxKey}, true );
+ var t = db.jstests_sorta;
+ t.drop();
-function sorted( arr ) {
- assert.eq( 9, arr.length );
- for( i = 1; i < arr.length; ++i ) {
- assert.lte( arr[ i-1 ]._id, arr[ i ]._id );
+ assert.writeOK(t.insert({_id: 0, a: MinKey}));
+ assert.writeOK(t.save({_id: 3, a: null}));
+ assert.writeOK(t.save({_id: 1, a: []}));
+ assert.writeOK(t.save({_id: 7, a: [2]}));
+ assert.writeOK(t.save({_id: 4}));
+ assert.writeOK(t.save({_id: 5, a: null}));
+ assert.writeOK(t.save({_id: 2, a: []}));
+ assert.writeOK(t.save({_id: 6, a: 1}));
+ assert.writeOK(t.insert({_id: 8, a: MaxKey}));
+
+ function sorted(arr) {
+ assert.eq(9, arr.length, tojson(arr));
+ for (var i = 1; i < arr.length; ++i) {
+ assert.lte(arr[i - 1]._id, arr[i]._id);
+ }
}
-}
-sorted( t.find().sort( {a:1} ).toArray() );
-t.ensureIndex( {a:1} );
-sorted( t.find().sort( {a:1} ).hint( {a:1} ).toArray() );
+ sorted(t.find().sort({a: 1}).toArray());
+ assert.commandWorked(t.ensureIndex({a: 1}));
+ sorted(t.find().sort({a: 1}).hint({a: 1}).toArray());
+})();
diff --git a/jstests/libs/parallelTester.js b/jstests/libs/parallelTester.js
index c0d6b74b2d5..8b42fc0c7c7 100644
--- a/jstests/libs/parallelTester.js
+++ b/jstests/libs/parallelTester.js
@@ -268,7 +268,8 @@ if ( typeof _threadInject != "undefined" ){
runners.forEach( function( x ) { x.start(); } );
var nFailed = 0;
- // v8 doesn't like it if we exit before all threads are joined (SERVER-529)
+ // SpiderMonkey doesn't like it if we exit before all threads are joined
+ // (see SERVER-19615 for a similar issue).
runners.forEach( function( x ) { if( !x.returnData() ) { ++nFailed; } } );
assert.eq( 0, nFailed, msg );
}
diff --git a/jstests/parallel/manyclients.js b/jstests/parallel/manyclients.js
index 62c0e7f0d1b..cd67e8c3f0f 100644
--- a/jstests/parallel/manyclients.js
+++ b/jstests/parallel/manyclients.js
@@ -9,7 +9,6 @@ Random.setRandomSeed();
t = new ParallelTester();
-// v8 uses about 30M (res) per thread, so can't do many more on an 8GB system
// Reducing the number of threads to 100 because of WT-1989
numThreads = 100;
buildInfo = db.adminCommand( "buildInfo" ).buildEnvironment
diff --git a/jstests/sharding/major_version_check.js b/jstests/sharding/major_version_check.js
index f0a0431cb42..a580be909e2 100644
--- a/jstests/sharding/major_version_check.js
+++ b/jstests/sharding/major_version_check.js
@@ -11,12 +11,6 @@ var admin = mongos.getDB( "admin" )
var config = mongos.getDB( "config" )
var coll = mongos.getCollection( "foo.bar" )
-// This converter is needed as spidermonkey and v8 treat Timestamps slightly differently
-// TODO: Is this a problem? SERVER-6079
-var tsToObj = function( obj ){
- return { t : obj.t, i : obj.i }
-}
-
// Shard collection
printjson( admin.runCommand({ enableSharding : coll.getDB() + "" }) )
printjson( admin.runCommand({ shardCollection : coll + "", key : { _id : 1 } }) )
@@ -32,18 +26,18 @@ printjson( admin.runCommand({ getShardVersion : coll + "" }) )
printjson( staleMongos.getDB( "admin" ).runCommand({ getShardVersion : coll + "" }) )
// Compare strings b/c timestamp comparison is a bit weird
-assert.eq( tsToObj( Timestamp( 1, 2 ) ),
- tsToObj( admin.runCommand({ getShardVersion : coll + "" }).version ) )
-assert.eq( tsToObj( Timestamp( 1, 0 ) ),
- tsToObj( staleMongos.getDB( "admin" ).runCommand({ getShardVersion : coll + "" }).version ) )
+assert.eq( Timestamp( 1, 2 ),
+ admin.runCommand({ getShardVersion : coll + "" }).version );
+assert.eq( Timestamp( 1, 0 ),
+ staleMongos.getDB( "admin" ).runCommand({ getShardVersion : coll + "" }).version );
// See if our stale mongos is required to catch up to run a findOne on an existing connection
staleMongos.getCollection( coll + "" ).findOne()
printjson( staleMongos.getDB( "admin" ).runCommand({ getShardVersion : coll + "" }) )
-assert.eq( tsToObj( Timestamp( 1, 0 ) ),
- tsToObj( staleMongos.getDB( "admin" ).runCommand({ getShardVersion : coll + "" }).version ) )
+assert.eq( Timestamp( 1, 0 ),
+ staleMongos.getDB( "admin" ).runCommand({ getShardVersion : coll + "" }).version );
// See if our stale mongos is required to catch up to run a findOne on a new connection
staleMongos = new Mongo( staleMongos.host )
@@ -51,7 +45,7 @@ staleMongos.getCollection( coll + "" ).findOne()
printjson( staleMongos.getDB( "admin" ).runCommand({ getShardVersion : coll + "" }) )
-assert.eq( tsToObj( Timestamp( 1, 0 ) ),
- tsToObj( staleMongos.getDB( "admin" ).runCommand({ getShardVersion : coll + "" }).version ) )
+assert.eq( Timestamp( 1, 0 ),
+ staleMongos.getDB( "admin" ).runCommand({ getShardVersion : coll + "" }).version );
st.stop() \ No newline at end of file
diff --git a/jstests/sharding/mr_shard_version.js b/jstests/sharding/mr_shard_version.js
index 2cf519d5c7f..35f8d5a165b 100644
--- a/jstests/sharding/mr_shard_version.js
+++ b/jstests/sharding/mr_shard_version.js
@@ -42,7 +42,7 @@ for( var i = 0; i < st._shardServers.length; i++ ){
command : { moveChunk : "" + coll,
find : { _id : ( j == 0 ? 0 : halfId ) },
to : st._shardServers[i].shardName } } // , check : checkMigrate }
- // TODO: Deadlock due to global V8Lock between scopes if we stop with a js check
+ // TODO: Re-enable the checkMigrate check when SERVER-21359 is fixed.
}
}
diff --git a/jstests/slow2/mr_during_migrate.js b/jstests/slow2/mr_during_migrate.js
index f478ce5e7a8..78e48eb9db8 100644
--- a/jstests/slow2/mr_during_migrate.js
+++ b/jstests/slow2/mr_during_migrate.js
@@ -52,7 +52,6 @@ for(var i = 0; i < st._shardServers.length; i++) {
},
showResult: true
});
- // TODO: Deadlock due to global V8Lock between scopes if we stop with a js check
}
// TODO: Also migrate output collection
@@ -93,8 +92,7 @@ for( var t = 0; t < numTests; t++ ){
coll.getMongo().getDB("admin").runCommand({ setParameter : 1, traceExceptions : true })
- // TODO: If we pass in a weird value here, we can crash v8 obj parsing
- printjson( coll.mapReduce( map, reduce, { out : { replace : outputColl.getName(), db : outputColl.getDB() + "" } }) )
+ printjson( coll.mapReduce( map, reduce, { out : { replace : outputColl.getName(), db : outputColl.getDB() + "" } }) );
jsTest.log( "MapReduce run #" + t + " finished." )