diff options
Diffstat (limited to 'src/mongo/gotools/test/legacy24/jstests')
34 files changed, 0 insertions, 1587 deletions
diff --git a/src/mongo/gotools/test/legacy24/jstests/libs/use_extended_timeout.js b/src/mongo/gotools/test/legacy24/jstests/libs/use_extended_timeout.js deleted file mode 100644 index 7f770249214..00000000000 --- a/src/mongo/gotools/test/legacy24/jstests/libs/use_extended_timeout.js +++ /dev/null @@ -1,12 +0,0 @@ -var _orig_runMongoProgram = runMongoProgram; -runMongoProgram = function() { - var args = []; - for (var i in arguments) { - args[i] = arguments[i]; - } - var progName = args[0]; - if (progName !== "bsondump" && args.indexOf("--dialTimeout") === -1) { - args.push("--dialTimeout", "30"); - } - return _orig_runMongoProgram.apply(null, args); -}; diff --git a/src/mongo/gotools/test/legacy24/jstests/replsets/rslib.js b/src/mongo/gotools/test/legacy24/jstests/replsets/rslib.js deleted file mode 100644 index fb561cc90e1..00000000000 --- a/src/mongo/gotools/test/legacy24/jstests/replsets/rslib.js +++ /dev/null @@ -1,115 +0,0 @@ - -var count = 0; -var w = 0; - -var wait = function(f,msg) { - w++; - var n = 0; - while (!f()) { - if( n % 4 == 0 ) - print("waiting " + w); - if (++n == 4) { - print("" + f); - } - assert(n < 200, 'tried 200 times, giving up on ' + msg ); - sleep(1000); - } -}; - -/** - * Use this to do something once every 4 iterations. - * - * <pre> - * for (i=0; i<1000; i++) { - * occasionally(function() { print("4 more iterations"); }); - * } - * </pre> - */ -var occasionally = function(f, n) { - var interval = n || 4; - if (count % interval == 0) { - f(); - } - count++; -}; - -var reconnect = function(a) { - wait(function() { - try { - // make this work with either dbs or connections - if (typeof(a.getDB) == "function") { - db = a.getDB('foo'); - } - else { - db = a; - } - db.bar.stats(); - if (jsTest.options().keyFile) { // SERVER-4241: Shell connections don't re-authenticate on reconnect - return jsTest.authenticate(db.getMongo()); - } - return true; - } catch(e) { - print(e); - return false; - } - }); -}; - - -var getLatestOp = function(server) { - server.getDB("admin").getMongo().setSlaveOk(); - var log = server.getDB("local")['oplog.rs']; - var cursor = log.find({}).sort({'$natural': -1}).limit(1); - if (cursor.hasNext()) { - return cursor.next(); - } - return null; -}; - - -var waitForAllMembers = function(master, timeout) { - var failCount = 0; - - assert.soon( function() { - var state = null - try { - state = master.getSisterDB("admin").runCommand({replSetGetStatus:1}); - failCount = 0; - } catch ( e ) { - // Connection can get reset on replica set failover causing a socket exception - print( "Calling replSetGetStatus failed" ); - print( e ); - return false; - } - occasionally(function() { printjson(state); }, 10); - - for (var m in state.members) { - if (state.members[m].state != 1 && // PRIMARY - state.members[m].state != 2 && // SECONDARY - state.members[m].state != 7) { // ARBITER - return false; - } - } - printjson( state ); - return true; - }, "not all members ready", timeout || 60000); - - print( "All members are now in state PRIMARY, SECONDARY, or ARBITER" ); -}; - -var reconfig = function(rs, config) { - var admin = rs.getPrimary().getDB("admin"); - - try { - var ok = admin.runCommand({replSetReconfig : config}); - assert.eq(ok.ok,1); - } - catch(e) { - print(e); - } - - master = rs.getPrimary().getDB("admin"); - waitForAllMembers(master); - - return master; -}; diff --git a/src/mongo/gotools/test/legacy24/jstests/tool/csv1.js b/src/mongo/gotools/test/legacy24/jstests/tool/csv1.js deleted file mode 100644 index 5eb7ab0249a..00000000000 --- a/src/mongo/gotools/test/legacy24/jstests/tool/csv1.js +++ /dev/null @@ -1,42 +0,0 @@ -// csv1.js - -t = new ToolTest( "csv1" ) - -c = t.startDB( "foo" ); - -base = { a : 1 , b : "foo,bar\"baz,qux" , c: 5, 'd d': -6 , e: '-', f : "."}; - -assert.eq( 0 , c.count() , "setup1" ); -c.insert( base ); -delete base._id -assert.eq( 1 , c.count() , "setup2" ); - -t.runTool( "export" , "--out" , t.extFile , "-d" , t.baseName , "-c" , "foo" , "--csv" , "-f" , "a,b,c,d d,e,f" ) - -c.drop() -assert.eq( 0 , c.count() , "after drop" ) - -t.runTool( "import" , "--file" , t.extFile , "-d" , t.baseName , "-c" , "foo" , "--type" , "csv" , "-f" , "a,b,c,d d,e,f" ); -assert.soon( "2 == c.count()" , "restore 2" ); - -a = c.find().sort( { a : 1 } ).toArray(); -delete a[0]._id -delete a[1]._id -assert.eq( tojson( { a : "a" , b : "b" , c : "c" , 'd d': "d d", e: 'e', f : "f"} ) , tojson( a[1] ) , "csv parse 1" ); -assert.eq( tojson( base ) , tojson(a[0]) , "csv parse 0" ) - -c.drop() -assert.eq( 0 , c.count() , "after drop 2" ) - -t.runTool( "import" , "--file" , t.extFile , "-d" , t.baseName , "-c" , "foo" , "--type" , "csv" , "--headerline" ) -assert.soon( "c.findOne()" , "no data after sleep" ); -assert.eq( 1 , c.count() , "after restore 2" ); - -x = c.findOne() -delete x._id; -assert.eq( tojson( base ) , tojson(x) , "csv parse 2" ) - - - - -t.stop() diff --git a/src/mongo/gotools/test/legacy24/jstests/tool/csvexport1.js b/src/mongo/gotools/test/legacy24/jstests/tool/csvexport1.js deleted file mode 100644 index 2ae85e37401..00000000000 --- a/src/mongo/gotools/test/legacy24/jstests/tool/csvexport1.js +++ /dev/null @@ -1,47 +0,0 @@ -// csvexport1.js - -t = new ToolTest( "csvexport1" ) - -c = t.startDB( "foo" ); - -assert.eq( 0 , c.count() , "setup1" ); - -objId = ObjectId() - -c.insert({ a : new NumberInt(1) , b : objId , c: [1.0, 2.0, 3.0], d : {a : "hello", b : "world"} , e: '-'}) -c.insert({ a : -2.0, c : MinKey, d : "Then he said, \"Hello World!\"", e : new NumberLong(3)}) -c.insert({ a : new BinData(0, "1234"), b : ISODate("2009-08-27"), c : new Timestamp(1234, 9876), d : /foo*\"bar\"/i, e : function foo() { print("Hello World!"); }}) - -assert.eq( 3 , c.count() , "setup2" ); - -t.runTool( "export" , "--out" , t.extFile , "-d" , t.baseName , "-c" , "foo" , "--csv", "-f", "a,b,c,d,e") - - -c.drop() - -assert.eq( 0 , c.count() , "after drop" ) - -t.runTool("import", "--file", t.extFile, "-d", t.baseName, "-c", "foo", "--type", "csv", "--headerline"); - -assert.soon ( 3 + " == c.count()", "after import"); - -// Note: Exporting and Importing to/from CSV is not designed to be round-trippable -expected = [] -expected.push({ a : 1, b : "ObjectId(" + objId.valueOf() + ")", c : "[1.0,2.0,3.0]", d : "{\"a\":\"hello\",\"b\":\"world\"}", e : "-"}) -expected.push({ a : -2.0, b : "", c : "$MinKey", d : "Then he said, \"Hello World!\"", e : 3}) -// "t" should be 1234, but the shell interprets the first field of timestamps as milliseconds while -// they are stored as seconds. See SERVER-7718. -expected.push({ a : "D76DF8", b : "2009-08-27T00:00:00.000Z", c : "{ \"$timestamp\": { \"t\": 1234, \"i\": 9876 } }", d : "/foo*\\\"bar\\\"/i", e : tojson(function foo() { print("Hello World!"); })}) - -actual = [] -actual.push(c.find({a : 1}).toArray()[0]); -actual.push(c.find({a : -2.0}).toArray()[0]); -actual.push(c.find({a : "D76DF8"}).toArray()[0]); - -for (i = 0; i < expected.length; i++) { - delete actual[i]._id - assert.eq( expected[i], actual[i], "CSV export " + i); -} - - -t.stop() diff --git a/src/mongo/gotools/test/legacy24/jstests/tool/csvexport2.js b/src/mongo/gotools/test/legacy24/jstests/tool/csvexport2.js deleted file mode 100644 index 3e0dd2c6829..00000000000 --- a/src/mongo/gotools/test/legacy24/jstests/tool/csvexport2.js +++ /dev/null @@ -1,31 +0,0 @@ -// csvexport2.js - -t = new ToolTest( "csvexport2" ) - -c = t.startDB( "foo" ); - -// This test is designed to test exporting of a CodeWithScope object. -// However, due to SERVER-3391, it is not possible to create a CodeWithScope object in the mongo shell, -// therefore this test does not work. Once SERVER-3391 is resolved, this test should be un-commented out - -//assert.eq( 0 , c.count() , "setup1" ); - -//c.insert({ a : 1 , b : Code("print(\"Hello \" + x);", {"x" : "World!"})}) -//assert.eq( 1 , c.count() , "setup2" ); -//t.runTool( "export" , "--out" , t.extFile , "-d" , t.baseName , "-c" , "foo" , "--csv", "-f", "a,b") - - -//c.drop() - -//assert.eq( 0 , c.count() , "after drop" ) -//t.runTool("import", "--file", t.extFile, "-d", t.baseName, "-c", "foo", "--type", "csv", "--headerline"); -//assert.soon ( 1 + " == c.count()", "after import"); - -//expected = { a : 1, b : "\"{ \"$code\" : print(\"Hello \" + x); , \"$scope\" : { \"x\" : \"World!\" } }"}; -//actual = c.findOne() - -//delete actual._id; -//assert.eq( expected, actual ); - - -t.stop()
\ No newline at end of file diff --git a/src/mongo/gotools/test/legacy24/jstests/tool/csvimport1.js b/src/mongo/gotools/test/legacy24/jstests/tool/csvimport1.js deleted file mode 100644 index 3bff1110cbe..00000000000 --- a/src/mongo/gotools/test/legacy24/jstests/tool/csvimport1.js +++ /dev/null @@ -1,40 +0,0 @@ -// csvimport1.js - -t = new ToolTest( "csvimport1" ) - -c = t.startDB( "foo" ); - -base = [] -base.push({ a : 1, b : "this is some text.\nThis text spans multiple lines, and just for fun\ncontains a comma", "c" : "This has leading and trailing whitespace!" }) -base.push({a : 2, b : "When someone says something you \"put it in quotes\"", "c" : "I like embedded quotes/slashes\\backslashes" }) -base.push({a : 3, b : " This line contains the empty string and has leading and trailing whitespace inside the quotes! ", "c" : "" }) -base.push({a : 4, b : "", "c" : "How are empty entries handled?" }) -base.push({a : 5, b : "\"\"", c : "\"This string is in quotes and contains empty quotes (\"\")\""}) -base.push({ a : "a" , b : "b" , c : "c"}) - -assert.eq( 0 , c.count() , "setup" ); - -t.runTool( "import" , "--file" , "jstests/tool/data/csvimport1.csv" , "-d" , t.baseName , "-c" , "foo" , "--type" , "csv" , "-f" , "a,b,c" ); -assert.soon( base.length + " == c.count()" , "after import 1 " ); - -a = c.find().sort( { a : 1 } ).toArray(); -for (i = 0; i < base.length; i++ ) { - delete a[i]._id - assert.eq( tojson(base[i]), tojson(a[i]), "csv parse " + i) -} - -c.drop() -assert.eq( 0 , c.count() , "after drop" ) - -t.runTool( "import" , "--file" , "jstests/tool/data/csvimport1.csv" , "-d" , t.baseName , "-c" , "foo" , "--type" , "csv" , "--headerline" ) -assert.soon( "c.findOne()" , "no data after sleep" ); -assert.eq( base.length - 1 , c.count() , "after import 2" ); - -x = c.find().sort( { a : 1 } ).toArray(); -for (i = 0; i < base.length - 1; i++ ) { - delete x[i]._id - assert.eq( tojson(base[i]), tojson(x[i]), "csv parse with headerline " + i) -} - - -t.stop() diff --git a/src/mongo/gotools/test/legacy24/jstests/tool/data/a.tsv b/src/mongo/gotools/test/legacy24/jstests/tool/data/a.tsv deleted file mode 100644 index 1e094179a63..00000000000 --- a/src/mongo/gotools/test/legacy24/jstests/tool/data/a.tsv +++ /dev/null @@ -1,2 +0,0 @@ -a b c d e - 1 foobar 5 -6 diff --git a/src/mongo/gotools/test/legacy24/jstests/tool/data/csvimport1.csv b/src/mongo/gotools/test/legacy24/jstests/tool/data/csvimport1.csv deleted file mode 100644 index 256d40a9184..00000000000 --- a/src/mongo/gotools/test/legacy24/jstests/tool/data/csvimport1.csv +++ /dev/null @@ -1,8 +0,0 @@ -a,b,c -1,"this is some text. -This text spans multiple lines, and just for fun -contains a comma", "This has leading and trailing whitespace!" -2, "When someone says something you ""put it in quotes""", I like embedded quotes/slashes\backslashes - 3 , " This line contains the empty string and has leading and trailing whitespace inside the quotes! ", "" - "4" ,, How are empty entries handled? -"5","""""", """This string is in quotes and contains empty quotes ("""")""" diff --git a/src/mongo/gotools/test/legacy24/jstests/tool/data/dumprestore6/foo.bson b/src/mongo/gotools/test/legacy24/jstests/tool/data/dumprestore6/foo.bson Binary files differdeleted file mode 100644 index b8f8f99e6bf..00000000000 --- a/src/mongo/gotools/test/legacy24/jstests/tool/data/dumprestore6/foo.bson +++ /dev/null diff --git a/src/mongo/gotools/test/legacy24/jstests/tool/data/dumprestore6/system.indexes.bson b/src/mongo/gotools/test/legacy24/jstests/tool/data/dumprestore6/system.indexes.bson Binary files differdeleted file mode 100644 index dde25da302a..00000000000 --- a/src/mongo/gotools/test/legacy24/jstests/tool/data/dumprestore6/system.indexes.bson +++ /dev/null diff --git a/src/mongo/gotools/test/legacy24/jstests/tool/dumpauth.js b/src/mongo/gotools/test/legacy24/jstests/tool/dumpauth.js deleted file mode 100644 index 6050fc6b79b..00000000000 --- a/src/mongo/gotools/test/legacy24/jstests/tool/dumpauth.js +++ /dev/null @@ -1,29 +0,0 @@ -// dumpauth.js -// test mongodump with authentication -port = allocatePorts( 1 )[ 0 ]; -baseName = "tool_dumpauth"; - -m = startMongod( "--auth", "--port", port, "--dbpath", "/data/db/" + baseName, "--nohttpinterface", "--bind_ip", "127.0.0.1" ); -db = m.getDB( "admin" ); - -t = db[ baseName ]; -t.drop(); - -for(var i = 0; i < 100; i++) { - t["testcol"].save({ "x": i }); -} - -users = db.getCollection( "system.users" ); - -db.addUser( "testuser" , "testuser" ); - -assert( db.auth( "testuser" , "testuser" ) , "auth failed" ); - -x = runMongoProgram( "mongodump", - "--db", baseName, - "--authenticationDatabase=admin", - "-u", "testuser", - "-p", "testuser", - "-h", "127.0.0.1:"+port, - "--collection", "testcol" ); -assert.eq(x, 0, "mongodump should succeed with authentication"); diff --git a/src/mongo/gotools/test/legacy24/jstests/tool/dumpfilename1.js b/src/mongo/gotools/test/legacy24/jstests/tool/dumpfilename1.js deleted file mode 100644 index cb0255afefc..00000000000 --- a/src/mongo/gotools/test/legacy24/jstests/tool/dumpfilename1.js +++ /dev/null @@ -1,13 +0,0 @@ -//dumpfilename1.js - -//Test designed to make sure error that dumping a collection with "/" fails - -t = new ToolTest( "dumpfilename1" ); - -t.startDB( "foo" ); - -c = t.db; -c.getCollection("df/").insert({ a: 3 }); -assert(t.runTool( "dump" , "--out" , t.ext ) != 0, "dump should fail with non-zero return code") -t.stop(); - diff --git a/src/mongo/gotools/test/legacy24/jstests/tool/dumprestore1.js b/src/mongo/gotools/test/legacy24/jstests/tool/dumprestore1.js deleted file mode 100644 index fd1e8789ea6..00000000000 --- a/src/mongo/gotools/test/legacy24/jstests/tool/dumprestore1.js +++ /dev/null @@ -1,23 +0,0 @@ -// dumprestore1.js - -t = new ToolTest( "dumprestore1" ); - -c = t.startDB( "foo" ); -assert.eq( 0 , c.count() , "setup1" ); -c.save( { a : 22 } ); -assert.eq( 1 , c.count() , "setup2" ); - -t.runTool( "dump" , "--out" , t.ext ); - -c.drop(); -assert.eq( 0 , c.count() , "after drop" ); - -t.runTool( "restore" , "--dir" , t.ext ); -assert.soon( "c.findOne()" , "no data after sleep" ); -assert.eq( 1 , c.count() , "after restore 2" ); -assert.eq( 22 , c.findOne().a , "after restore 2" ); - -// ensure that --collection is used with --db. See SERVER-7721 -var ret = t.runTool( "dump" , "--collection" , "col" ); -assert.neq( ret, 0, "mongodump should return failure code" ); -t.stop(); diff --git a/src/mongo/gotools/test/legacy24/jstests/tool/dumprestore10.js b/src/mongo/gotools/test/legacy24/jstests/tool/dumprestore10.js deleted file mode 100644 index 49f008ea591..00000000000 --- a/src/mongo/gotools/test/legacy24/jstests/tool/dumprestore10.js +++ /dev/null @@ -1,63 +0,0 @@ -// simple test to ensure write concern functions as expected - -var name = "dumprestore10"; - -function step(msg) { - msg = msg || ""; - this.x = (this.x || 0) + 1; - print('\n' + name + ".js step " + this.x + ' ' + msg); -} - -step(); - -var replTest = new ReplSetTest( {name: name, nodes: 2} ); -var nodes = replTest.startSet(); -replTest.initiate(); -var master = replTest.getPrimary(); -var total = 1000; - -{ - step("store data"); - var foo = master.getDB("foo"); - for (i = 0; i < total; i++) { - foo.bar.insert({ x: i, y: "abc" }); - } -} - -{ - step("wait"); - replTest.awaitReplication(); -} - -step("mongodump from replset"); - -var data = MongoRunner.dataDir + "/dumprestore10-dump1/"; - -runMongoProgram( "mongodump", "--host", "127.0.0.1:"+replTest.ports[0], "--out", data ); - - -{ - step("remove data after dumping"); - master.getDB("foo").getCollection("bar").drop(); -} - -{ - step("wait"); - replTest.awaitReplication(); -} - -step("try mongorestore with write concern"); - -runMongoProgram( "mongorestore", "--writeConcern", "2", "--host", "127.0.0.1:"+replTest.ports[0], "--dir", data ); - -var x = 0; - -// no waiting for replication -x = master.getDB("foo").getCollection("bar").count(); - -assert.eq(x, total, "mongorestore should have successfully restored the collection"); - -step("stopSet"); -replTest.stopSet(); - -step("SUCCESS"); diff --git a/src/mongo/gotools/test/legacy24/jstests/tool/dumprestore3.js b/src/mongo/gotools/test/legacy24/jstests/tool/dumprestore3.js deleted file mode 100644 index fe9f54d704c..00000000000 --- a/src/mongo/gotools/test/legacy24/jstests/tool/dumprestore3.js +++ /dev/null @@ -1,60 +0,0 @@ -// dumprestore3.js - -var name = "dumprestore3"; - -function step(msg) { - msg = msg || ""; - this.x = (this.x || 0) + 1; - print('\n' + name + ".js step " + this.x + ' ' + msg); -} - -step(); - -var replTest = new ReplSetTest( {name: name, nodes: 2} ); -var nodes = replTest.startSet(); -replTest.initiate(); -var master = replTest.getPrimary(); - -{ - step("populate master"); - var foo = master.getDB("foo"); - for (i = 0; i < 20; i++) { - foo.bar.insert({ x: i, y: "abc" }); - } -} - -{ - step("wait for slaves"); - replTest.awaitReplication(); -} - -{ - step("dump & restore a db into a slave"); - var port = 30020; - var conn = startMongodTest(port, name + "-other"); - var c = conn.getDB("foo").bar; - c.save({ a: 22 }); - assert.eq(1, c.count(), "setup2"); -} - -step("try mongorestore to slave"); - -var data = MongoRunner.dataDir + "/dumprestore3-other1/"; -resetDbpath(data); -runMongoProgram( "mongodump", "--host", "127.0.0.1:"+port, "--out", data ); - -var x = runMongoProgram( "mongorestore", "--host", "127.0.0.1:"+replTest.ports[1], "--dir", data ); -assert.eq(x, 1, "mongorestore should exit w/ 1 on slave"); - -step("try mongoimport to slave"); - -dataFile = MongoRunner.dataDir + "/dumprestore3-other2.json"; -runMongoProgram( "mongoexport", "--host", "127.0.0.1:"+port, "--out", dataFile, "--db", "foo", "--collection", "bar" ); - -x = runMongoProgram( "mongoimport", "--host", "127.0.0.1:"+replTest.ports[1], "--file", dataFile ); -assert.eq(x, 1, "mongoreimport should exit w/ 1 on slave"); // windows return is signed - -step("stopSet"); -replTest.stopSet(); - -step("SUCCESS"); diff --git a/src/mongo/gotools/test/legacy24/jstests/tool/dumprestore4.js b/src/mongo/gotools/test/legacy24/jstests/tool/dumprestore4.js deleted file mode 100644 index 568e196061f..00000000000 --- a/src/mongo/gotools/test/legacy24/jstests/tool/dumprestore4.js +++ /dev/null @@ -1,42 +0,0 @@ -// dumprestore4.js -- see SERVER-2186 - -// The point of this test is to ensure that mongorestore successfully -// constructs indexes when the database being restored into has a -// different name than the database dumped from. There are 2 -// issues here: (1) if you dumped from database "A" and restore into -// database "B", B should have exactly the right indexes; (2) if for -// some reason you have another database called "A" at the time of the -// restore, mongorestore shouldn't touch it. - -t = new ToolTest( "dumprestore4" ); - -c = t.startDB( "dumprestore4" ); - -db=t.db - -dbname = db.getName(); -dbname2 = "NOT_"+dbname; - -db2=db.getSisterDB( dbname2 ); - -db.dropDatabase(); // make sure it's empty -db2.dropDatabase(); // make sure everybody's empty - -assert.eq( 0 , db.system.indexes.count() , "setup1" ); -c.ensureIndex({ x : 1} ); -assert.eq( 2 , db.system.indexes.count() , "setup2" ); // _id and x_1 - -assert.eq( 0, t.runTool( "dump" , "-d" , dbname, "--out", t.ext ), "dump") - -// to ensure issue (2), we have to clear out the first db. -// By inspection, db.dropIndexes() doesn't get rid of the _id index on c, -// so we have to drop the collection. -c.drop(); -assert.eq( 0, t.runTool( "restore" , "--dir" , t.ext + "/" + dbname, "-d", dbname2 ), "restore" ); - -// issue (1) -assert.eq( 2 , db2.system.indexes.count() , "after restore 1" ); -// issue (2) -assert.eq( 0 , db.system.indexes.count() , "after restore 2" ); - -t.stop(); diff --git a/src/mongo/gotools/test/legacy24/jstests/tool/dumprestore6.js b/src/mongo/gotools/test/legacy24/jstests/tool/dumprestore6.js deleted file mode 100644 index d8b349e9589..00000000000 --- a/src/mongo/gotools/test/legacy24/jstests/tool/dumprestore6.js +++ /dev/null @@ -1,27 +0,0 @@ -// dumprestore6.js -// Test restoring from a dump with an old index version - -t = new ToolTest( "dumprestore6" ); - -c = t.startDB( "foo" ); -db = t.db -assert.eq( 0 , c.count() , "setup1" ); - -t.runTool("restore", "--dir", "jstests/tool/data/dumprestore6", "--db", "jstests_tool_dumprestore6") - -assert.soon( "c.findOne()" , "no data after sleep" ); -assert.eq( 1 , c.count() , "after restore" ); -assert.eq( 1 , db.system.indexes.findOne({name:'a_1'}).v, "index version wasn't updated") -assert.eq( 1, c.count({v:0}), "dropped the 'v' field from a non-index collection") - -db.dropDatabase() -assert.eq( 0 , c.count() , "after drop" ); - -t.runTool("restore", "--dir", "jstests/tool/data/dumprestore6", "--db", "jstests_tool_dumprestore6", "--keepIndexVersion") - -assert.soon( "c.findOne()" , "no data after sleep2" ); -assert.eq( 1 , c.count() , "after restore2" ); -assert.eq( 0 , db.system.indexes.findOne({name:'a_1'}).v, "index version wasn't maintained") -assert.eq( 1, c.count({v:0}), "dropped the 'v' field from a non-index collection") - -t.stop(); diff --git a/src/mongo/gotools/test/legacy24/jstests/tool/dumprestore7.js b/src/mongo/gotools/test/legacy24/jstests/tool/dumprestore7.js deleted file mode 100644 index b28a056422d..00000000000 --- a/src/mongo/gotools/test/legacy24/jstests/tool/dumprestore7.js +++ /dev/null @@ -1,62 +0,0 @@ -var name = "dumprestore7"; - -function step(msg) { - msg = msg || ""; - this.x = (this.x || 0) + 1; - print('\n' + name + ".js step " + this.x + ' ' + msg); -} - -step(); - -var replTest = new ReplSetTest( {name: name, nodes: 1} ); -var nodes = replTest.startSet(); -replTest.initiate(); -var master = replTest.getPrimary(); - -{ - step("first chunk of data"); - var foo = master.getDB("foo"); - for (i = 0; i < 20; i++) { - foo.bar.insert({ x: i, y: "abc" }); - } -} - -{ - step("wait"); - replTest.awaitReplication(); - var time = replTest.getPrimary().getDB("local").getCollection("oplog.rs").find().limit(1).sort({$natural:-1}).next(); - step(time.ts.t); -} - -{ - step("second chunk of data"); - var foo = master.getDB("foo"); - for (i = 30; i < 50; i++) { - foo.bar.insert({ x: i, y: "abc" }); - } -} -{ - var port = 30020; - var conn = startMongodTest(port, name + "-other"); -} - -step("try mongodump with $timestamp"); - -var data = MongoRunner.dataDir + "/data/db/dumprestore7-dump1/"; -var query = "{\"ts\":{\"$gt\":{\"$timestamp\":{\"t\":"+ time.ts.t + ",\"i\":" + time.ts.i +"}}}}"; - -runMongoProgram( "mongodump", "--host", "127.0.0.1:"+replTest.ports[0], "--db", "local", "--collection", "oplog.rs", "--query", query, "--out", data ); - -step("try mongorestore from $timestamp"); - -runMongoProgram( "mongorestore", "--host", "127.0.0.1:"+port, "--dir", data ); -var x = 9; -x = conn.getDB("local").getCollection("oplog.rs").count(); - -assert.eq(x, 20, "mongorestore should only have the latter 20 entries"); - -step("stopSet"); -replTest.stopSet(); - -step("SUCCESS"); - diff --git a/src/mongo/gotools/test/legacy24/jstests/tool/dumprestore8.js b/src/mongo/gotools/test/legacy24/jstests/tool/dumprestore8.js deleted file mode 100644 index 4e6591738d6..00000000000 --- a/src/mongo/gotools/test/legacy24/jstests/tool/dumprestore8.js +++ /dev/null @@ -1,105 +0,0 @@ -// dumprestore8.js - -// This file tests that indexes and capped collection options get properly dumped and restored. -// It checks that this works both when doing a full database dump/restore and when doing it just for a single db or collection - -t = new ToolTest( "dumprestore8" ); - -t.startDB( "foo" ); -db = t.db; - -dbname = db.getName(); -dbname2 = "NOT_"+dbname; - -db.dropDatabase(); - -assert.eq( 0 , db.foo.count() , "setup1" ); -db.foo.save( { a : 1, b : 1 } ); -db.foo.ensureIndex({a:1}); -db.foo.ensureIndex({b:1, _id:-1}); -assert.eq( 1 , db.foo.count() , "setup2" ); - - -assert.eq( 0 , db.bar.count() , "setup3" ); -db.createCollection("bar", {capped:true, size:1000}); - -for (var i = 0; i < 1000; i++) { - db.bar.save( { x : i } ); -} -db.bar.ensureIndex({x:1}); - -barDocCount = db.bar.count(); -assert.gt( barDocCount, 0 , "No documents inserted" ); -assert.lt( db.bar.count(), 1000 , "Capped collection didn't evict documents" ); -assert.eq( 5 , db.system.indexes.count() , "Indexes weren't created right" ); - - -// Full dump/restore - -t.runTool( "dump" , "--out" , t.ext ); - -db.dropDatabase(); -assert.eq( 0 , db.foo.count() , "foo not dropped" ); -assert.eq( 0 , db.bar.count() , "bar not dropped" ); -assert.eq( 0 , db.system.indexes.count() , "indexes not dropped" ); - -t.runTool( "restore" , "--dir" , t.ext ); - -assert.soon( "db.foo.findOne()" , "no data after sleep" ); -assert.eq( 1 , db.foo.count() , "wrong number of docs restored to foo" ); -assert.eq( barDocCount, db.bar.count(), "wrong number of docs restored to bar" ); -for (var i = 0; i < 10; i++) { - db.bar.save({x:i}); -} -assert.eq( barDocCount, db.bar.count(), "Capped collection didn't evict documents after restore." ); -assert.eq( 5 , db.system.indexes.count() , "Indexes weren't created correctly by restore" ); - - -// Dump/restore single DB - -dumppath = t.ext + "singledbdump/"; -mkdir(dumppath); -t.runTool( "dump" , "-d", dbname, "--out" , dumppath ); - -db.dropDatabase(); -assert.eq( 0 , db.foo.count() , "foo not dropped2" ); -assert.eq( 0 , db.bar.count() , "bar not dropped2" ); -assert.eq( 0 , db.system.indexes.count() , "indexes not dropped2" ); - -t.runTool( "restore" , "-d", dbname2, "--dir" , dumppath + dbname ); - -db = db.getSiblingDB(dbname2); - -assert.soon( "db.foo.findOne()" , "no data after sleep 2" ); -assert.eq( 1 , db.foo.count() , "wrong number of docs restored to foo 2" ); -assert.eq( barDocCount, db.bar.count(), "wrong number of docs restored to bar 2" ); -for (var i = 0; i < 10; i++) { - db.bar.save({x:i}); -} -assert.eq( barDocCount, db.bar.count(), "Capped collection didn't evict documents after restore 2." ); -assert.eq( 5 , db.system.indexes.count() , "Indexes weren't created correctly by restore 2" ); - - -// Dump/restore single collection - -dumppath = t.ext + "singlecolldump/"; -mkdir(dumppath); -t.runTool( "dump" , "-d", dbname2, "-c", "bar", "--out" , dumppath ); - -db.dropDatabase(); -assert.eq( 0 , db.bar.count() , "bar not dropped3" ); -assert.eq( 0 , db.system.indexes.count() , "indexes not dropped3" ); - -t.runTool( "restore" , "-d", dbname, "-c", "baz", "--dir" , dumppath + dbname2 + "/bar.bson" ); - -db = db.getSiblingDB(dbname); - -assert.soon( "db.baz.findOne()" , "no data after sleep 2" ); -assert.eq( barDocCount, db.baz.count(), "wrong number of docs restored to bar 2" ); -for (var i = 0; i < 10; i++) { - db.baz.save({x:i}); -} -assert.eq( barDocCount, db.baz.count(), "Capped collection didn't evict documents after restore 3." ); -assert.eq( 2 , db.system.indexes.count() , "Indexes weren't created correctly by restore 3" ); - -t.stop(); diff --git a/src/mongo/gotools/test/legacy24/jstests/tool/dumprestore9.js b/src/mongo/gotools/test/legacy24/jstests/tool/dumprestore9.js deleted file mode 100644 index a4a98e8e430..00000000000 --- a/src/mongo/gotools/test/legacy24/jstests/tool/dumprestore9.js +++ /dev/null @@ -1,79 +0,0 @@ -if (0) { // Test disabled until SERVER-3853 is finished. -var name = "dumprestore9"; -function step(msg) { - msg = msg || ""; - this.x = (this.x || 0) + 1; - print('\n' + name + ".js step " + this.x + ' ' + msg); -} - -s = new ShardingTest( "dumprestore9a", 2, 0, 3, {chunksize:1} ); - -step("Shard collection"); - -s.adminCommand( { enablesharding : "aaa" } ); // Make this db alphabetically before 'config' so it gets restored first -s.adminCommand( { shardcollection : "aaa.foo" , key : { x : 1 } } ); - -db = s.getDB( "aaa" ); -coll = db.foo; - -step("insert data"); - -str = 'a'; -while (str.length < 1024*512) { - str += str; -} - -numDocs = 20; -for (var i = 0; i < numDocs; i++) { - coll.insert({x:i, str:str}); -} - -step("Wait for balancing"); - -assert.soon( function(){ var x = s.chunkDiff( "foo" , "aaa" ); print( "chunk diff: " + x ); return x < 2; } , "no balance happened" , 8 * 60 * 1000 , 2000 ); - -assert.eq(numDocs, coll.count(), "Documents weren't inserted correctly"); - -step("dump cluster"); - -dumpdir = "/data/db/dumprestore9-dump1/"; -resetDbpath(dumpdir); -runMongoProgram( "mongodump", "--host", s._mongos[0].host, "--out", dumpdir ); - -step("Shutting down cluster"); - -s.stop(); - -step("Starting up clean cluster"); -s = new ShardingTest( "dumprestore9b", 2, 0, 3, {chunksize:1} ); - -db = s.getDB( "aaa" ); -coll = db.foo; - -assert.eq(0, coll.count(), "Data wasn't cleaned up by restarting sharding test"); - -step("Restore data and config"); - -runMongoProgram( "mongorestore", dumpdir, "--host", s._mongos[1].host, "--restoreShardingConfig", "--forceConfigRestore"); - -config = s.getDB("config"); -assert(config.databases.findOne({_id:'aaa'}).partitioned, "Config data wasn't restored properly"); - -assert( s.chunkDiff( "foo" , "aaa" ) < 2, "Chunk data wasn't restored properly"); - -assert.eq(numDocs, coll.count(), "Didn't restore all documents properly2"); -assert.eq(numDocs, coll.find().itcount(), "Didn't restore all documents properly"); - -for (var i = 0; i < numDocs; i++) { - doc = coll.findOne({x:i}); - assert.eq(i, doc.x, "Doc missing from the shard it should be on"); -} - -for (var i = 0; i < s._connections.length; i++) { - assert(s._connections[i].getDB("aaa").foo.count() > 0, "No data on shard: " + s._connections[i].host); -} - -step("Stop cluster"); -s.stop(); -step("SUCCESS"); -}
\ No newline at end of file diff --git a/src/mongo/gotools/test/legacy24/jstests/tool/dumprestoreWithNoOptions.js b/src/mongo/gotools/test/legacy24/jstests/tool/dumprestoreWithNoOptions.js deleted file mode 100644 index dd3300ad4f9..00000000000 --- a/src/mongo/gotools/test/legacy24/jstests/tool/dumprestoreWithNoOptions.js +++ /dev/null @@ -1,117 +0,0 @@ -// SERVER-6366 -// relates to SERVER-808 -// -// This file tests that options are not restored upon -// mongorestore with --noOptionsRestore -// -// It checks that this works both when doing a full -// database dump/restore and when doing it just for a -// single db or collection. - -t = new ToolTest( "dumprestoreWithNoOptions" ); - -t.startDB( "foo" ); -db = t.db; - -dbname = db.getName(); -dbname2 = "NOT_"+dbname; - -db.dropDatabase(); - -var options = { capped: true, size: 1000, autoIndexId: true }; -db.createCollection('capped', options); -assert.eq( 1, db.system.indexes.count(), "auto index not created" ); -var cappedOptions = db.capped.exists().options; -for ( var opt in options ) { - assert.eq(options[opt], cappedOptions[opt], 'invalid option') -} -db.capped.insert({ x: 1 }); -db.getLastError() - -// Full dump/restore - -t.runTool( "dump" , "--out" , t.ext ); - -db.dropDatabase(); -assert.eq( 0, db.capped.count(), "capped not dropped"); -assert.eq( 0, db.system.indexes.count(), "indexes not dropped" ); - -t.runTool( "restore" , "--dir" , t.ext , "--noOptionsRestore", "-vvv"); - -assert.eq( 1, db.capped.count() , "wrong number of docs restored to capped" ); -assert(true !== db.capped.stats().capped, "restore options were not ignored"); - -// Note: The 2.4 server seems to have a bug where part of the "create" command -// itself ends up being set in the collection options object. So as a workaround, -// we will just delete that key and make sure there are no other keys set in -// the options object. -opts = db.capped.exists().options; -delete opts.create; -assert.eq(Object.keys(opts).length, 0, "restore options not ignored"); - -// Dump/restore single DB - -db.dropDatabase(); -var options = { capped: true, size: 1000, autoIndexId: true }; -db.createCollection('capped', options); -assert.eq( 1, db.system.indexes.count(), "auto index not created" ); -var cappedOptions = db.capped.exists().options; -for ( var opt in options ) { - assert.eq(options[opt], cappedOptions[opt], 'invalid option') -} -db.capped.insert({ x: 1 }); -db.getLastError() - -dumppath = t.ext + "noOptionsSingleDump/"; -mkdir(dumppath); -t.runTool( "dump" , "-d", dbname, "--out" , dumppath ); - -db.dropDatabase(); -assert.eq( 0, db.capped.count(), "capped not dropped"); -assert.eq( 0, db.system.indexes.count(), "indexes not dropped" ); - -t.runTool( "restore" , "-d", dbname2, "--dir" , dumppath + dbname, "--noOptionsRestore"); - -db = db.getSiblingDB(dbname2); - -assert.eq( 1, db.capped.count() , "wrong number of docs restored to capped" ); -assert(true !== db.capped.stats().capped, "restore options were not ignored"); - -opts = db.capped.exists().options; -delete opts.create; -assert.eq(Object.keys(opts).length, 0, "restore options not ignored"); - -// Dump/restore single collection - -db.dropDatabase(); -var options = { capped: true, size: 1000, autoIndexId: true }; -db.createCollection('capped', options); -assert.eq( 1, db.system.indexes.count(), "auto index not created" ); -var cappedOptions = db.capped.exists().options; -for ( var opt in options ) { - assert.eq(options[opt], cappedOptions[opt], 'invalid option') -} -db.capped.insert({ x: 1 }); -db.getLastError() - -dumppath = t.ext + "noOptionsSingleColDump/"; -mkdir(dumppath); -dbname = db.getName(); -t.runTool( "dump" , "-d", dbname, "-c", "capped", "--out" , dumppath ); - -db.dropDatabase(); - -assert.eq( 0, db.capped.count(), "capped not dropped"); -assert.eq( 0, db.system.indexes.count(), "indexes not dropped" ); - -t.runTool( "restore", "-d", dbname, "--drop", "--noOptionsRestore", "--dir", dumppath + dbname ); - -db = db.getSiblingDB(dbname); - -assert.eq( 1, db.capped.count() , "wrong number of docs restored to capped" ); -assert( true !== db.capped.stats().capped, "restore options were not ignored" ); -opts = db.capped.exists().options; -delete opts.create; -assert.eq(Object.keys(opts).length, 0, "restore options not ignored"); - -t.stop(); diff --git a/src/mongo/gotools/test/legacy24/jstests/tool/dumprestore_auth.js b/src/mongo/gotools/test/legacy24/jstests/tool/dumprestore_auth.js deleted file mode 100644 index 6f0e6c0a05c..00000000000 --- a/src/mongo/gotools/test/legacy24/jstests/tool/dumprestore_auth.js +++ /dev/null @@ -1,28 +0,0 @@ -// dumprestore_auth.js - -t = new ToolTest("dumprestore_auth", { auth : "" }); - -c = t.startDB("foo"); - -adminDB = c.getDB().getSiblingDB('admin'); -adminDB.addUser('admin', 'password'); -adminDB.auth('admin','password'); - -assert.eq(0 , c.count() , "setup1"); -c.save({ a : 22 }); -assert.eq(1 , c.count() , "setup2"); - -t.runTool("dump" , "--out" , t.ext, "--username", "admin", "--password", "password"); - -c.drop(); -assert.eq(0 , c.count() , "after drop"); - -t.runTool("restore" , "--dir" , t.ext); // Should fail -assert.eq(0 , c.count() , "after restore without auth"); - -t.runTool("restore" , "--dir" , t.ext, "--username", "admin", "--password", "password"); -assert.soon("c.findOne()" , "no data after sleep"); -assert.eq(1 , c.count() , "after restore 2"); -assert.eq(22 , c.findOne().a , "after restore 2"); - -t.stop(); diff --git a/src/mongo/gotools/test/legacy24/jstests/tool/dumpsecondary.js b/src/mongo/gotools/test/legacy24/jstests/tool/dumpsecondary.js deleted file mode 100644 index 7a641542498..00000000000 --- a/src/mongo/gotools/test/legacy24/jstests/tool/dumpsecondary.js +++ /dev/null @@ -1,38 +0,0 @@ -var replTest = new ReplSetTest( {name: 'testSet', nodes: 2} ); - -var nodes = replTest.startSet(); -replTest.initiate(); - -var master = replTest.getPrimary(); -db = master.getDB("foo") -db.foo.save({a: 1000}); -replTest.awaitReplication(); -replTest.awaitSecondaryNodes(); - -assert.eq( 1 , db.foo.count() , "setup" ); - -var slaves = replTest.liveNodes.slaves; -assert( slaves.length == 1, "Expected 1 slave but length was " + slaves.length ); -slave = slaves[0]; - -var args = ['mongodump', '-h', slave.host, '--out', MongoRunner.dataDir + '/jstests_tool_dumpsecondary_external/']; -var authargs = ['--username', jsTest.options().authUser, '--password', jsTest.options().authPassword]; -if (jsTest.options().keyFile) { - args = args.concat(authargs); -} -runMongoProgram.apply(null, args); -db.foo.drop() - -assert.eq( 0 , db.foo.count() , "after drop" ); -args = ['mongorestore', '-h', master.host, MongoRunner.dataDir + '/jstests_tool_dumpsecondary_external/']; -if (jsTest.options().keyFile) { - args = args.concat(authargs); -} -runMongoProgram.apply(null, args) -assert.soon( "db.foo.findOne()" , "no data after sleep" ); -assert.eq( 1 , db.foo.count() , "after restore" ); -assert.eq( 1000 , db.foo.findOne().a , "after restore 2" ); - -resetDbpath(MongoRunner.dataDir + '/jstests_tool_dumpsecondary_external') - -replTest.stopSet(15) diff --git a/src/mongo/gotools/test/legacy24/jstests/tool/exportimport1.js b/src/mongo/gotools/test/legacy24/jstests/tool/exportimport1.js deleted file mode 100644 index a7a7bcee90c..00000000000 --- a/src/mongo/gotools/test/legacy24/jstests/tool/exportimport1.js +++ /dev/null @@ -1,66 +0,0 @@ -// exportimport1.js - -t = new ToolTest( "exportimport1" ); - -c = t.startDB( "foo" ); -assert.eq( 0 , c.count() , "setup1" ); -var arr = ["x", undefined, "y", undefined]; -c.save( { a : 22 , b : arr} ); -assert.eq( 1 , c.count() , "setup2" ); - -t.runTool( "export" , "--out" , t.extFile , "-d" , t.baseName , "-c" , "foo" ); - -c.drop(); -assert.eq( 0 , c.count() , "after drop" , "-d" , t.baseName , "-c" , "foo" );; - -t.runTool( "import" , "--file" , t.extFile , "-d" , t.baseName , "-c" , "foo" ); -assert.soon( "c.findOne()" , "no data after sleep" ); -assert.eq( 1 , c.count() , "after restore 2" ); -var doc = c.findOne(); -assert.eq( 22 , doc.a , "after restore 2" ); -for (var i=0; i<arr.length; i++) { - if (typeof arr[i] == 'undefined') { - // null should be { "$undefined" : true }, but this is a workaround for SERVER-6102 - assert.eq( null, doc.b[i] , "after restore array: "+i ); - } else { - assert.eq( arr[i], doc.b[i] , "after restore array: "+i ); - } -} - -// now with --jsonArray - -t.runTool( "export" , "--jsonArray" , "--out" , t.extFile , "-d" , t.baseName , "-c" , "foo" ); - -c.drop(); -assert.eq( 0 , c.count() , "after drop" , "-d" , t.baseName , "-c" , "foo" );; - -t.runTool( "import" , "--jsonArray" , "--file" , t.extFile , "-d" , t.baseName , "-c" , "foo" ); -assert.soon( "c.findOne()" , "no data after sleep" ); -assert.eq( 1 , c.count() , "after restore 2" ); -assert.eq( 22 , c.findOne().a , "after restore 2" ); - -c.drop(); -assert.eq( 0 , c.count() , "after drop" , "-d" , t.baseName , "-c" , "foo" ); - -arr = ["a", undefined, "c"]; -c.save({a : arr}); -assert.eq( 1 , c.count() , "setup2" ); -t.runTool( "export" , "--out" , t.extFile , "-d" , t.baseName , "-c" , "foo" ); -c.drop(); -assert.eq( 0 , c.count() , "after drop" , "-d" , t.baseName , "-c" , "foo" );; - -t.runTool( "import" , "--file" , t.extFile , "-d" , t.baseName , "-c" , "foo" ); -assert.soon( "c.findOne()" , "no data after sleep" ); -assert.eq( 1 , c.count() , "after restore 2" ); -var doc = c.findOne(); -for (var i=0; i<arr.length; i++) { - if (typeof arr[i] == 'undefined') { - // null should be { "$undefined" : true }, but this is a workaround for SERVER-6102 - assert.eq( null, doc.a[i] , "after restore array: "+i ); - } else { - assert.eq( arr[i], doc.a[i] , "after restore array: "+i ); - } -} - - -t.stop(); diff --git a/src/mongo/gotools/test/legacy24/jstests/tool/exportimport3.js b/src/mongo/gotools/test/legacy24/jstests/tool/exportimport3.js deleted file mode 100644 index f18ba6cbd4b..00000000000 --- a/src/mongo/gotools/test/legacy24/jstests/tool/exportimport3.js +++ /dev/null @@ -1,27 +0,0 @@ -// exportimport3.js - -t = new ToolTest( "exportimport3" ); - -c = t.startDB( "foo" ); -assert.eq( 0 , c.count() , "setup1" ); -c.save({a:1}) -c.save({a:2}) -c.save({a:3}) -c.save({a:4}) -c.save({a:5}) - -assert.eq( 5 , c.count() , "setup2" ); - - -t.runTool( "export" , "--jsonArray" , "--out" , t.extFile , "-d" , t.baseName , "-c" , "foo" ); - -c.drop(); -assert.eq( 0 , c.count() , "after drop" , "-d" , t.baseName , "-c" , "foo" );; - -t.runTool( "import" , "--jsonArray" , "--file" , t.extFile , "-d" , t.baseName , "-c" , "foo" ); - -assert.soon( "c.findOne()" , "no data after sleep" ); -assert.eq( 5 , c.count() , "after restore 2" ); - - -t.stop(); diff --git a/src/mongo/gotools/test/legacy24/jstests/tool/exportimport4.js b/src/mongo/gotools/test/legacy24/jstests/tool/exportimport4.js deleted file mode 100644 index 605e21b7337..00000000000 --- a/src/mongo/gotools/test/legacy24/jstests/tool/exportimport4.js +++ /dev/null @@ -1,56 +0,0 @@ -// exportimport4.js - -t = new ToolTest( "exportimport4" ); -c = t.startDB( "foo" ); - -install_test_data = function() { - c.drop(); - - assert.eq( 0 , c.count() , "setup1" ); - - c.save( { a : [1, 2, 3, NaN, 4, null, 5] } ); - c.save( { a : [1, 2, 3, 4, 5] } ); - c.save( { a : [ NaN ] } ); - c.save( { a : [1, 2, 3, 4, NaN, NaN, 5, NaN] } ); - c.save( { a : [1, 2, 3, 4, null, null, 5, null] } ); - - assert.eq( 5 , c.count() , "setup2" ); -}; - -// attempt to export fields without NaN -install_test_data(); - -t.runTool( "export" , "--out" , t.extFile , "-d" , t.baseName , "-c" , "foo", "-q", "{a:{\"$nin\":[NaN]}}" ); - -c.drop(); -assert.eq( 0 , c.count() , "after drop" , "-d" , t.baseName , "-c" , "foo" ); - -t.runTool( "import" , "--file" , t.extFile , "-d" , t.baseName , "-c" , "foo", "--drop" ); - -assert.eq( 2 , c.count() , "after restore 1" ); - -// attempt to export fields with NaN -install_test_data(); - -t.runTool( "export" , "--out" , t.extFile , "-d" , t.baseName , "-c" , "foo", "-q", "{a:NaN}" ); - -c.drop(); -assert.eq( 0 , c.count() , "after drop" , "-d" , t.baseName , "-c" , "foo" ); - -t.runTool( "import" , "--file" , t.extFile , "-d" , t.baseName , "-c" , "foo", "--drop" ); - -assert.eq( 3 , c.count() , "after restore 2" ); - -// attempt to export everything -install_test_data(); - -t.runTool( "export" , "--out" , t.extFile , "-d" , t.baseName , "-c" , "foo" ); - -c.drop(); -assert.eq( 0 , c.count() , "after drop" , "-d" , t.baseName , "-c" , "foo" ); - -t.runTool( "import" , "--file" , t.extFile , "-d" , t.baseName , "-c" , "foo", "--drop" ); - -assert.eq( 5 , c.count() , "after restore 3" ); - -t.stop(); diff --git a/src/mongo/gotools/test/legacy24/jstests/tool/exportimport5.js b/src/mongo/gotools/test/legacy24/jstests/tool/exportimport5.js deleted file mode 100644 index 427b03f0232..00000000000 --- a/src/mongo/gotools/test/legacy24/jstests/tool/exportimport5.js +++ /dev/null @@ -1,81 +0,0 @@ -// exportimport4.js - -t = new ToolTest( "exportimport5" ); -c = t.startDB( "foo" ); - -install_test_data = function() { - c.drop(); - - assert.eq( 0 , c.count() , "setup1" ); - - c.save( { a : [1, 2, 3, Infinity, 4, null, 5] } ); - c.save( { a : [1, 2, 3, 4, 5] } ); - c.save( { a : [ Infinity ] } ); - c.save( { a : [1, 2, 3, 4, Infinity, Infinity, 5, -Infinity] } ); - c.save( { a : [1, 2, 3, 4, null, null, 5, null] } ); - c.save( { a : [ -Infinity ] } ); - - assert.eq( 6 , c.count() , "setup2" ); -}; - -// attempt to export fields without Infinity -install_test_data(); - -t.runTool( "export" , "--out" , t.extFile , "-d" , t.baseName , "-c" , "foo", "-q", "{a:{\"$nin\":[Infinity]}}" ); - -c.drop(); -assert.eq( 0 , c.count() , "after drop" , "-d" , t.baseName , "-c" , "foo" ); - -t.runTool( "import" , "--file" , t.extFile , "-d" , t.baseName , "-c" , "foo", "--drop" ); - -assert.eq( 3 , c.count() , "after restore 1" ); - -// attempt to export fields with Infinity -install_test_data(); - -t.runTool( "export" , "--out" , t.extFile , "-d" , t.baseName , "-c" , "foo", "-q", "{a:Infinity}" ); - -c.drop(); -assert.eq( 0 , c.count() , "after drop" , "-d" , t.baseName , "-c" , "foo" ); - -t.runTool( "import" , "--file" , t.extFile , "-d" , t.baseName , "-c" , "foo", "--drop" ); - -assert.eq( 3 , c.count() , "after restore 2" ); - -// attempt to export fields without -Infinity -install_test_data(); - -t.runTool( "export" , "--out" , t.extFile , "-d" , t.baseName , "-c" , "foo", "-q", "{a:{\"$nin\":[-Infinity]}}" ); - -c.drop(); -assert.eq( 0 , c.count() , "after drop" , "-d" , t.baseName , "-c" , "foo" ); - -t.runTool( "import" , "--file" , t.extFile , "-d" , t.baseName , "-c" , "foo", "--drop" ); - -assert.eq( 4 , c.count() , "after restore 3" ); - -// attempt to export fields with -Infinity -install_test_data(); - -t.runTool( "export" , "--out" , t.extFile , "-d" , t.baseName , "-c" , "foo", "-q", "{a:-Infinity}" ); - -c.drop(); -assert.eq( 0 , c.count() , "after drop" , "-d" , t.baseName , "-c" , "foo" ); - -t.runTool( "import" , "--file" , t.extFile , "-d" , t.baseName , "-c" , "foo", "--drop" ); - -assert.eq( 2 , c.count() , "after restore 4" ); - -// attempt to export everything -install_test_data(); - -t.runTool( "export" , "--out" , t.extFile , "-d" , t.baseName , "-c" , "foo" ); - -c.drop(); -assert.eq( 0 , c.count() , "after drop" , "-d" , t.baseName , "-c" , "foo" ); - -t.runTool( "import" , "--file" , t.extFile , "-d" , t.baseName , "-c" , "foo", "--drop" ); - -assert.eq( 6 , c.count() , "after restore 5" ); - -t.stop(); diff --git a/src/mongo/gotools/test/legacy24/jstests/tool/files1.js b/src/mongo/gotools/test/legacy24/jstests/tool/files1.js deleted file mode 100644 index acfcc16dcc3..00000000000 --- a/src/mongo/gotools/test/legacy24/jstests/tool/files1.js +++ /dev/null @@ -1,27 +0,0 @@ -// files1.js - -t = new ToolTest( "files1" ) - -db = t.startDB(); - -filename = 'mongod' -if ( _isWindows() ) - filename += '.exe' - -t.runTool( "files" , "-d" , t.baseName , "put" , filename ); -md5 = md5sumFile(filename); - -file_obj = db.fs.files.findOne() -assert( file_obj , "A 0" ); -md5_stored = file_obj.md5; -md5_computed = db.runCommand({filemd5: file_obj._id}).md5; -assert.eq( md5 , md5_stored , "A 1" ); -assert.eq( md5 , md5_computed, "A 2" ); - -mkdir(t.ext); - -t.runTool( "files" , "-d" , t.baseName , "get" , filename , '-l' , t.extFile ); -md5 = md5sumFile(t.extFile); -assert.eq( md5 , md5_stored , "B" ); - -t.stop() diff --git a/src/mongo/gotools/test/legacy24/jstests/tool/oplog1.js b/src/mongo/gotools/test/legacy24/jstests/tool/oplog1.js deleted file mode 100644 index 0429e6e3416..00000000000 --- a/src/mongo/gotools/test/legacy24/jstests/tool/oplog1.js +++ /dev/null @@ -1,29 +0,0 @@ -// oplog1.js - -// very basic test for mongooplog -// need a lot more, but test that it functions at all - -t = new ToolTest( "oplog1" ); - -db = t.startDB(); - -output = db.output - -doc = { x : 17, _id: 5 }; - -db.oplog.insert( { ts : new Timestamp() , "op" : "i" , "ns" : output.getFullName() , "o" : doc } ); - -assert.eq( 0 , output.count() , "before" ) - -t.runTool( "oplog" , "--oplogns" , db.getName() + ".oplog" , "--from" , "127.0.0.1:" + t.port , "-vv" ); - -assert.eq( 1 , output.count() , "after" ); - -var res = output.findOne() -assert.eq( doc["x"], res["x"], "have same val for x after check" ) -assert.eq( doc["_id"], res["_id"], "have same val for _id after check" ) -assert.eq( Object.keys(doc).length, Object.keys(res).length, "have same amount of keys after check" ) - -t.stop(); - - diff --git a/src/mongo/gotools/test/legacy24/jstests/tool/oplog_all_ops.js b/src/mongo/gotools/test/legacy24/jstests/tool/oplog_all_ops.js deleted file mode 100644 index 8f231cb233d..00000000000 --- a/src/mongo/gotools/test/legacy24/jstests/tool/oplog_all_ops.js +++ /dev/null @@ -1,61 +0,0 @@ -/** - * Performs a simple test on mongooplog by doing different types of operations - * that will show up in the oplog then replaying it on another replica set. - * Correctness is verified using the dbhash command. - */ - -var repl1 = new ReplSetTest({ name: 'rs1', nodes: [{ nopreallocj: '' }, - { arbiter: true }, { arbiter: true }]}); - -repl1.startSet({ oplogSize: 10 }); -repl1.initiate(); -repl1.awaitSecondaryNodes(); - -var repl1Conn = new Mongo(repl1.getURL()); -var testDB = repl1Conn.getDB('test'); -var testColl = testDB.user; - -// op i -testColl.insert({ x: 1 }); -testColl.insert({ x: 2 }); - -// op c -testDB.dropDatabase(); - -testColl.insert({ y: 1 }); -testColl.insert({ y: 2 }); -testColl.insert({ y: 3 }); - -// op u -testColl.update({}, { $inc: { z: 1 }}, true, true); - -// op d -testColl.remove({ y: 2 }); - -// op n -var oplogColl = repl1Conn.getCollection('local.oplog.rs'); -oplogColl.insert({ ts: new Timestamp(), op: 'n', ns: testColl.getFullName(), 'o': { x: 'noop' }}); - -var repl2 = new ReplSetTest({ name: 'rs2', startPort: 31100, nodes: [{ nopreallocj: '' }, - { arbiter: true }, { arbiter: true }]}); - -repl2.startSet({ oplogSize: 10 }); -repl2.initiate(); -repl2.awaitSecondaryNodes(); - -var srcConn = repl1.getPrimary(); -runMongoProgram('mongooplog', '--from', repl1.getPrimary().host, - '--host', repl2.getPrimary().host); - -var repl1Hash = testDB.runCommand({ dbhash: 1 }); - -var repl2Conn = new Mongo(repl2.getURL()); -var testDB2 = repl2Conn.getDB(testDB.getName()); -var repl2Hash = testDB2.runCommand({ dbhash: 1 }); - -assert(repl1Hash.md5); -assert.eq(repl1Hash.md5, repl2Hash.md5); - -repl1.stopSet(); -repl2.stopSet(); - diff --git a/src/mongo/gotools/test/legacy24/jstests/tool/restorewithauth.js b/src/mongo/gotools/test/legacy24/jstests/tool/restorewithauth.js deleted file mode 100644 index a759ccf038c..00000000000 --- a/src/mongo/gotools/test/legacy24/jstests/tool/restorewithauth.js +++ /dev/null @@ -1,113 +0,0 @@ -/* SERVER-4972 - * Test for mongorestore on server with --auth allows restore without credentials of colls - * with no index - */ -/* - * 1) Start mongo without auth. - * 2) Write to collection - * 3) Take dump of the collection using mongodump. - * 4) Drop the collection. - * 5) Stop mongod from step 1. - * 6) Restart mongod with auth. - * 7) Add admin user to kick authentication - * 8) Try restore without auth credentials. The restore should fail - * 9) Try restore with correct auth credentials. The restore should succeed this time. - */ - -var port = allocatePorts(1)[0]; -baseName = "jstests_restorewithauth"; -var conn = startMongod( "--port", port, "--dbpath", MongoRunner.dataPath + baseName, "--nohttpinterface", - "--nojournal", "--bind_ip", "127.0.0.1" ); - -// write to ns foo.bar -var foo = conn.getDB( "foo" ); -for( var i = 0; i < 4; i++ ) { - foo["bar"].save( { "x": i } ); - foo["baz"].save({"x": i}); -} - -// make sure the collection exists -assert.eq( foo.system.namespaces.count({name: "foo.bar"}), 1 ) - -//make sure it has no index except _id -assert.eq(foo.system.indexes.count(), 2); - -foo.bar.createIndex({x:1}); -assert.eq(foo.system.indexes.count(), 3); - -// get data dump -var dumpdir = MongoRunner.dataDir + "/restorewithauth-dump1/"; -resetDbpath( dumpdir ); -x = runMongoProgram("mongodump", "--db", "foo", "-h", "127.0.0.1:"+port, "--out", dumpdir); - -// now drop the db -foo.dropDatabase(); - -// stop mongod -stopMongod( port ); - -// start mongod with --auth -conn = startMongod( "--auth", "--port", port, "--dbpath", MongoRunner.dataPath + baseName, "--nohttpinterface", - "--nojournal", "--bind_ip", "127.0.0.1" ); - -// admin user -var admin = conn.getDB( "admin" ) -admin.addUser( "admin" , "admin" ); -admin.auth( "admin" , "admin" ); - -var foo = conn.getDB( "foo" ) - -// make sure no collection with the same name exists -assert.eq(foo.system.namespaces.count( {name: "foo.bar"}), 0); -assert.eq(foo.system.namespaces.count( {name: "foo.baz"}), 0); - -// now try to restore dump -x = runMongoProgram( "mongorestore", "-h", "127.0.0.1:" + port, "--dir" , dumpdir, "-vvvvv" ); - -// make sure that the collection isn't restored -assert.eq(foo.system.namespaces.count({name: "foo.bar"}), 0); -assert.eq(foo.system.namespaces.count({name: "foo.baz"}), 0); - -// now try to restore dump with correct credentials -x = runMongoProgram( "mongorestore", - "-h", "127.0.0.1:" + port, - "-d", "foo", - "--authenticationDatabase=admin", - "-u", "admin", - "-p", "admin", - "--dir", dumpdir + "foo/", - "-vvvvv"); - -// make sure that the collection was restored -assert.eq(foo.system.namespaces.count({name: "foo.bar"}), 1); -assert.eq(foo.system.namespaces.count({name: "foo.baz"}), 1); - -// make sure the collection has 4 documents -assert.eq(foo.bar.count(), 4); -assert.eq(foo.baz.count(), 4); - -foo.dropDatabase(); - -// make sure that the collection is empty -assert.eq(foo.system.namespaces.count({name: "foo.bar"}), 0); -assert.eq(foo.system.namespaces.count({name: "foo.baz"}), 0); - -foo.addUser('user', 'password'); - -// now try to restore dump with foo database credentials -x = runMongoProgram("mongorestore", - "-h", "127.0.0.1:" + port, - "-d", "foo", - "-u", "user", - "-p", "password", - "--dir", dumpdir + "foo/", - "-vvvvv"); - -// make sure that the collection was restored -assert.eq(foo.system.namespaces.count({name: "foo.bar"}), 1); -assert.eq(foo.system.namespaces.count({name: "foo.baz"}), 1); -assert.eq(foo.bar.count(), 4); -assert.eq(foo.baz.count(), 4); -assert.eq(foo.system.indexes.count(), 5); // _id on foo, _id on bar, x on foo, _id + 1 on system.users - -stopMongod( port ); diff --git a/src/mongo/gotools/test/legacy24/jstests/tool/stat1.js b/src/mongo/gotools/test/legacy24/jstests/tool/stat1.js deleted file mode 100644 index d2e00756e75..00000000000 --- a/src/mongo/gotools/test/legacy24/jstests/tool/stat1.js +++ /dev/null @@ -1,23 +0,0 @@ -// stat1.js -// test mongostat with authentication SERVER-3875 -port = allocatePorts( 1 )[ 0 ]; -baseName = "tool_stat1"; - -m = startMongod( "--auth", "--port", port, "--dbpath", "/data/db/" + baseName, "--nohttpinterface", "--bind_ip", "127.0.0.1" ); -db = m.getDB( "admin" ); - -t = db[ baseName ]; -t.drop(); - -users = db.getCollection( "system.users" ); -users.remove( {} ); - -db.addUser( "eliot" , "eliot" ); - -assert( db.auth( "eliot" , "eliot" ) , "auth failed" ); - -x = runMongoProgram( "mongostat", "--host", "127.0.0.1:"+port, "--username", "eliot", "--password", "eliot", "--rowcount", "1", "--authenticationDatabase", "admin"); -assert.eq(x, 0, "mongostat should exit successfully with eliot:eliot"); - -x = runMongoProgram( "mongostat", "--host", "127.0.0.1:"+port, "--username", "eliot", "--password", "wrong", "--rowcount", "1", "--authenticationDatabase", "admin"); -assert.eq(x, 1, "mongostat should exit with -1 with eliot:wrong"); diff --git a/src/mongo/gotools/test/legacy24/jstests/tool/tool_replset.js b/src/mongo/gotools/test/legacy24/jstests/tool/tool_replset.js deleted file mode 100644 index bc50a0fd7d4..00000000000 --- a/src/mongo/gotools/test/legacy24/jstests/tool/tool_replset.js +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Test to ensure that (dump/restore/export/import/oplog) works with a replica set connection string - * 1. Start a replica set. - * 2. Add data to a collection. - * 3. Take a dump of the database. - * 4. Drop the db. - * 5. Restore the db. - * 6. Export a collection. - * 7. Drop the collection. - * 8. Import the collection. - * 9. Add data to the oplog.rs collection. - * 10. Ensure that the document doesn't exist yet. - * 11. Now play the mongooplog tool. - * 12. Make sure that the oplog was played -*/ - -// Load utility methods for replica set tests -load("jstests/replsets/rslib.js"); - -print("starting the replica set") - -var replTest = new ReplSetTest({ name: 'tool_replset', nodes: 2, oplogSize: 5 }); -var nodes = replTest.startSet(); -replTest.initiate(); -var master = replTest.getPrimary(); -for (var i = 0; i < 100; i++) { - master.getDB("foo").bar.insert({ a: i }); -} -replTest.awaitReplication(); - -var replSetConnString = "tool_replset/127.0.0.1:" + replTest.ports[0] + - ",127.0.0.1:" + replTest.ports[1]; - -// Test with mongodump/mongorestore -print("dump the db"); -var data = MongoRunner.dataDir + "/tool_replset-dump1/"; -runMongoProgram("mongodump", "--host", replSetConnString, "--out", data); - -print("db successfully dumped, dropping now"); -master.getDB("foo").dropDatabase(); -replTest.awaitReplication(); - -print("restore the db"); -runMongoProgram("mongorestore", "--host", replSetConnString, "--dir", data); - -print("db successfully restored, checking count") -var x = master.getDB("foo").getCollection("bar").count(); -assert.eq(x, 100, "mongorestore should have successfully restored the collection"); - -replTest.awaitReplication(); - -// Test with mongoexport/mongoimport -print("export the collection"); -var extFile = MongoRunner.dataDir + "/tool_replset/export"; -runMongoProgram("mongoexport", "--host", replSetConnString, "--out", extFile, - "-d", "foo", "-c", "bar"); - -print("collection successfully exported, dropping now"); -master.getDB("foo").getCollection("bar").drop(); -replTest.awaitReplication(); - -print("import the collection"); -runMongoProgram("mongoimport", "--host", replSetConnString, "--file", extFile, - "-d", "foo", "-c", "bar"); - -var x = master.getDB("foo").getCollection("bar").count(); -assert.eq(x, 100, "mongoimport should have successfully imported the collection"); - -// Test with mongooplog -var doc = { _id : 5, x : 17 }; -master.getDB("local").oplog.rs.insert({ ts : new Timestamp(), "op" : "i", "ns" : "foo.bar", - "o" : doc }); - -assert.eq(100, master.getDB("foo").getCollection("bar").count(), "count before running mongooplog " + - "was not 100 as expected"); - -runMongoProgram("mongooplog" , "--from", "127.0.0.1:" + replTest.ports[0], - "--host", replSetConnString); - -print("running mongooplog to replay the oplog") - -assert.eq(101, master.getDB("foo").getCollection("bar").count(), "count after running mongooplog " + - "was not 101 as expected") - -print("all tests successful, stopping replica set") - -replTest.stopSet(); - -print("replica set stopped, test complete") diff --git a/src/mongo/gotools/test/legacy24/jstests/tool/tsv1.js b/src/mongo/gotools/test/legacy24/jstests/tool/tsv1.js deleted file mode 100644 index 1b0ddbb7c9e..00000000000 --- a/src/mongo/gotools/test/legacy24/jstests/tool/tsv1.js +++ /dev/null @@ -1,32 +0,0 @@ -// tsv1.js - -t = new ToolTest( "tsv1" ) - -c = t.startDB( "foo" ); - -base = { a : "", b : 1 , c : "foobar" , d: 5, e: -6 }; - -t.runTool( "import" , "--file" , "jstests/tool/data/a.tsv" , "-d" , t.baseName , "-c" , "foo" , "--type" , "tsv" , "-f" , "a,b,c,d,e" ); -assert.soon( "2 == c.count()" , "restore 2" ); - -a = c.find().sort( { a : 1 } ).toArray(); -delete a[0]._id -delete a[1]._id - -assert.eq( { a : "a" , b : "b" , c : "c" , d: "d", e: "e"} , a[1] , "tsv parse 1" ); -assert.eq( base , a[0] , "tsv parse 0" ) - -c.drop() -assert.eq( 0 , c.count() , "after drop 2" ) - -t.runTool( "import" , "--file" , "jstests/tool/data/a.tsv" , "-d" , t.baseName , "-c" , "foo" , "--type" , "tsv" , "--headerline" ) -assert.soon( "c.findOne()" , "no data after sleep" ); -assert.eq( 1 , c.count() , "after restore 2" ); - -x = c.findOne() -delete x._id; -assert.eq( base , x , "tsv parse 2" ) - - - -t.stop() |