summaryrefslogtreecommitdiff
path: root/jstests
diff options
context:
space:
mode:
authorAaron <aaron@10gen.com>2009-05-20 12:16:25 -0400
committerAaron <aaron@10gen.com>2009-05-20 12:16:25 -0400
commit919bdb31ce848612896dbfc8dfac529652329a3a (patch)
tree67dd3d6eb5091fb24278560c525a8bbb17af2cae /jstests
parent3aa95556bd50e2f3fb671c0720dce31ca74e28fd (diff)
downloadmongo-919bdb31ce848612896dbfc8dfac529652329a3a.tar.gz
add tool tests where db data files are accessed directly
Diffstat (limited to 'jstests')
-rw-r--r--jstests/tool/tool1.js43
1 files changed, 30 insertions, 13 deletions
diff --git a/jstests/tool/tool1.js b/jstests/tool/tool1.js
index ba044f58fc0..7a9a7c6970f 100644
--- a/jstests/tool/tool1.js
+++ b/jstests/tool/tool1.js
@@ -1,36 +1,53 @@
// mongo tool tests, very basic to start with
baseName = "jstests_tool_tool1";
-dbPath = "/data/db/" + baseName;
-externalPath = "/data/db/" + baseName + "/external"
-externalFile = externalPath + "/export.json"
-
+dbPath = "/data/db/" + baseName + "/";
+externalPath = "/data/db/" + baseName + "_external/"
+externalFile = externalPath + "export.json"
port = allocatePorts( 1 )[ 0 ];
+resetDbpath( externalPath );
m = startMongod( "--port", port, "--dbpath", dbPath, "--nohttpinterface" );
-resetDbpath( externalPath );
c = m.getDB( baseName ).getCollection( baseName );
c.save( { a: 1 } );
startMongoProgramNoConnect( "mongodump", "--host", "127.0.0.1:" + port, "--out", externalPath );
-
sleep( 3000 );
-
c.drop();
-
startMongoProgramNoConnect( "mongorestore", "--host", "127.0.0.1:" + port, "--dir", externalPath );
-
assert.soon( function() { return c.findOne() && 1 == c.findOne().a; } );
resetDbpath( externalPath );
startMongoProgramNoConnect( "mongoexport", "--host", "127.0.0.1:" + port, "-d", baseName, "-c", baseName, "--out", externalFile );
-
sleep( 3000 );
-
c.drop();
-
startMongoProgramNoConnect( "mongoimportjson", "--host", "127.0.0.1:" + port, "-d", baseName, "-c", baseName, "--file", externalFile );
-
assert.soon( function() { return c.findOne() && 1 == c.findOne().a; } );
+
+stopMongod( port );
+resetDbpath( externalPath );
+
+startMongoProgramNoConnect( "mongodump", "--dbpath", dbPath, "--out", externalPath );
+sleep( 3000 );
+resetDbpath( dbPath );
+startMongoProgramNoConnect( "mongorestore", "--dbpath", dbPath, "--dir", externalPath );
+sleep( 5000 );
+m = startMongoProgram( "mongod", "--port", port, "--dbpath", dbPath, "--nohttpinterface" );
+c = m.getDB( baseName ).getCollection( baseName );
+assert( c.findOne(), "object missing" );
+assert( 1 == c.findOne().a, "object wrong" );
+
+stopMongod( port );
+resetDbpath( externalPath );
+
+startMongoProgramNoConnect( "mongoexport", "--dbpath", dbPath, "-d", baseName, "-c", baseName, "--out", externalFile );
+sleep( 3000 );
+resetDbpath( dbPath );
+startMongoProgramNoConnect( "mongoimportjson", "--dbpath", dbPath, "-d", baseName, "-c", baseName, "--file", externalFile );
+sleep( 5000 );
+m = startMongoProgram( "mongod", "--port", port, "--dbpath", dbPath, "--nohttpinterface" );
+c = m.getDB( baseName ).getCollection( baseName );
+assert( c.findOne(), "object missing" );
+assert( 1 == c.findOne().a, "object wrong" );