Skip to content

Commit

Permalink
Merge branch 'master' of github.com:mongodb/mongo
Browse files Browse the repository at this point in the history
  • Loading branch information
dwight committed Sep 22, 2012
2 parents 532bc1a + ec6187a commit 0c260c0
Show file tree
Hide file tree
Showing 226 changed files with 6,947 additions and 2,355 deletions.
8 changes: 5 additions & 3 deletions SConscript.smoke
Expand Up @@ -53,16 +53,18 @@ def addSmoketest( name, deps, extraSmokeArgs=[] ):
smokeArgs = smokeFlags + [target] + extraSmokeArgs
addTest(name, deps, utils.run_smoke_command(*smokeArgs))

def addSmokeSuite( name, suitefile ):
def addSmokeSuite( name, suitefile, needMongod=False ):
# Add a smoketest target which invokes smoke.py with
# --from-file, and passes the named suitefile as the
# command line argument.

# resolve an initial # in the suitefile
suitefile = str(env.File(suitefile))

addTest(name, [suitefile],
utils.run_smoke_command('--mode', 'files', '--from-file', suitefile))
smoke_args = ['--mode', 'files', '--from-file', suitefile]
if not needMongod:
smoke_args.append('--dont-start-mongod')
addTest(name, [suitefile], utils.run_smoke_command(*smoke_args))

addSmoketest( "smoke", [ add_exe( "test" ), add_exe( "mongod" ), add_exe( "mongo" ) ] )
addSmoketest( "smokePerf", [ add_exe("perftest") ] )
Expand Down
23 changes: 12 additions & 11 deletions SConstruct
Expand Up @@ -555,12 +555,12 @@ elif "win32" == os.sys.platform:
env.Append( CPPDEFINES=[ "MONGO_USE_SRW_ON_WINDOWS" ] )

for pathdir in env['ENV']['PATH'].split(os.pathsep):
if os.path.exists(os.path.join(pathdir, 'cl.exe')):
if os.path.exists(os.path.join(pathdir, 'cl.exe')):
print( "found visual studio at " + pathdir )
break
break
else:
#use current environment
env['ENV'] = dict(os.environ)
#use current environment
env['ENV'] = dict(os.environ)

env.Append( CPPDEFINES=[ "_UNICODE" ] )
env.Append( CPPDEFINES=[ "UNICODE" ] )
Expand Down Expand Up @@ -861,7 +861,7 @@ def doConfigure(myenv):

# discover modules (subdirectories of db/modules/), and
# load the (python) module for each module's build.py
modules = moduleconfig.discover_modules('.')
modules = moduleconfig.discover_modules('src/mongo/')

# ask each module to configure itself, and return a
# dictionary of name => list_of_sources for each module.
Expand Down Expand Up @@ -927,7 +927,6 @@ env.Alias( "style" , [] , [ doStyling ] )
env.AlwaysBuild( "style" )



# ---- INSTALL -------

def getSystemInstallName():
Expand All @@ -936,19 +935,21 @@ def getSystemInstallName():
n += "-static"
if has_option("nostrip"):
n += "-debugsymbols"
if nix and os.uname()[2].startswith( "8." ):
if nix and os.uname()[2].startswith("8."):
n += "-tiger"

if len(env.get("MONGO_MODULES", None)):
n += "-" + "-".join(env["MONGO_MODULES"].keys())

try:
findSettingsSetup()
import settings
if "distmod" in dir( settings ):
n = n + "-" + str( settings.distmod )
if "distmod" in dir(settings):
n = n + "-" + str(settings.distmod)
except:
pass


dn = GetOption( "distmod" )
dn = GetOption("distmod")
if dn and len(dn) > 0:
n = n + "-" + dn

Expand Down
54 changes: 54 additions & 0 deletions buildscripts/aggregate_tracefiles.py
@@ -0,0 +1,54 @@
import subprocess
import os
import sys
from optparse import OptionParser

""" This script aggregates several tracefiles into one tracefile
All but the last argument are input tracefiles or .txt files which list tracefiles.
The last argument is the tracefile to which the output will be written
"""
def aggregate(inputs, output):
"""Aggregates the tracefiles given in inputs to a tracefile given by output"""
args = ['lcov']

for name in inputs:
args += ['-a', name]

args += ['-o', output]

print ' '.join(args)

return subprocess.call(args)

def getfilesize(path):
if not os.path.isfile(path):
return 0
return os.path.getsize(path)

def main ():
inputs = []

usage = "usage: %prog input1.info input2.info ... output.info"
parser = OptionParser(usage=usage)

(options, args) = parser.parse_args()
if len(args) < 2:
return "must supply input files"

for path in args[:-1]:
name, ext = os.path.splitext(path)

if ext == '.info':
if getfilesize(path) > 0:
inputs.append(path)

elif ext == '.txt':
inputs += [line.strip() for line in open(path)
if getfilesize(line.strip()) > 0]
else:
return "unrecognized file type"

return aggregate(inputs, args[-1])

if __name__ == '__main__':
sys.exit(main())
21 changes: 20 additions & 1 deletion buildscripts/s3del.py
Expand Up @@ -16,11 +16,30 @@

def check_dir( bucket , prefix , todel ):

deleteAll = False

for ( key , modify , etag , size ) in bucket.listdir( prefix=prefix ):
if key.find( todel ) < 0:
continue
print( key )
time.sleep( 2 )

if not deleteAll:

val = raw_input( "Delete (Y,y,n,N):" ).strip()

if val == "n":
print( "skipping this one" )
continue
elif val == "N":
break

if val == "Y":
val = "y"
deleteAll = True

if val != "y":
raise Exception( "invalid input :(" )

bucket.delete( key )

def clean( todel ):
Expand Down
35 changes: 26 additions & 9 deletions buildscripts/smoke.py
Expand Up @@ -67,6 +67,7 @@
shell_executable = None
continue_on_failure = None
file_of_commands_mode = False
start_mongod = True

tests = []
winners = []
Expand Down Expand Up @@ -325,20 +326,29 @@ def ternary( b , l="true", r="false" ):
# Blech.
def skipTest(path):
basename = os.path.basename(path)
parentDir = os.path.basename(os.path.dirname(path))
parentPath = os.path.dirname(path)
parentDir = os.path.basename(parentPath)
if small_oplog: # For tests running in parallel
if basename in ["cursor8.js", "indexh.js", "dropdb.js"]:
return True
if auth or keyFile: # For tests running with auth
# Skip any tests that run with auth explicitly
if parentDir == "auth" or "auth" in basename or parentDir == "tool": # SERVER-6368
if parentDir == "auth" or "auth" in basename:
return True
# These tests don't pass with authentication due to limitations of the test infrastructure,
# not due to actual bugs.
if parentDir == "tool": # SERVER-6368
return True
if parentPath == mongo_repo: # Skip client tests
return True
# SERVER-6388
if os.path.join(parentDir,basename) in ["sharding/sync3.js", "sharding/sync6.js", "sharding/parallel.js", "jstests/bench_test1.js", "jstests/bench_test2.js", "jstests/bench_test3.js"]:
return True
# SERVER-6972
if os.path.join(parentDir,basename) == "sharding/read_pref_rs_client.js":
return True
# These tests fail due to bugs
if os.path.join(parentDir,basename) in ["sharding/sync_conn_cmd.js"]:
if os.path.join(parentDir,basename) in ["sharding/sync_conn_cmd.js"]: # SERVER-6327
return True

return False
Expand Down Expand Up @@ -441,10 +451,11 @@ def runTest(test):
if r != 0:
raise TestExitFailure(path, r)

try:
c = Connection( "127.0.0.1" , int(mongod_port) )
except Exception,e:
raise TestServerFailure(path)
if start_mongod:
try:
c = Connection( "127.0.0.1" , int(mongod_port) )
except Exception,e:
raise TestServerFailure(path)

print ""

Expand All @@ -457,7 +468,10 @@ def run_tests(tests):
# The reason we want to use "with" is so that we get __exit__ semantics
# but "with" is only supported on Python 2.5+

master = mongod(small_oplog_rs=small_oplog_rs,small_oplog=small_oplog,no_journal=no_journal,no_preallocj=no_preallocj,auth=auth).__enter__()
if start_mongod:
master = mongod(small_oplog_rs=small_oplog_rs,small_oplog=small_oplog,no_journal=no_journal,no_preallocj=no_preallocj,auth=auth).__enter__()
else:
master = Nothing()
try:
if small_oplog:
slave = mongod(slave=True).__enter__()
Expand Down Expand Up @@ -628,8 +642,9 @@ def add_exe(e):
return e

def set_globals(options, tests):
global mongod_executable, mongod_port, shell_executable, continue_on_failure, small_oplog, small_oplog_rs, no_journal, no_preallocj, auth, keyFile, smoke_db_prefix, test_path
global mongod_executable, mongod_port, shell_executable, continue_on_failure, small_oplog, small_oplog_rs, no_journal, no_preallocj, auth, keyFile, smoke_db_prefix, test_path, start_mongod
global file_of_commands_mode
start_mongod = options.start_mongod
#Careful, this can be called multiple times
test_path = options.test_path

Expand Down Expand Up @@ -789,6 +804,8 @@ def main():
parser.add_option('--with-cleanbb', dest='with_cleanbb', default=False,
action="store_true",
help='Clear database files from previous smoke.py runs')
parser.add_option(
'--dont-start-mongod', dest='start_mongod', default=True, action='store_false')

# Buildlogger invocation from command line
parser.add_option('--buildlogger-builder', dest='buildlogger_builder', default=None,
Expand Down
5 changes: 3 additions & 2 deletions jstests/aggregation/bugs/server6045.js
Expand Up @@ -52,8 +52,9 @@ var s6045p4 = db.runCommand({aggregate:"aggtype", pipeline: [
]});
// Expected result
var a6045 = {
"errmsg" : "Pipeline received empty document as argument",
"ok" : 0
"errmsg" : "exception: A pipeline stage specification object must contain exactly one field.",
"code" : 16435,
"ok" : 0
};

// Asserts
Expand Down
26 changes: 26 additions & 0 deletions jstests/aggregation/bugs/server6861.js
@@ -0,0 +1,26 @@
// Providing the wrong number of fields in a pipeline stage specification triggers a parsing error.
// SERVER-6861

t = db.jstests_server6861;
t.drop();

t.save( { a:1 } );

function assertCode( code, expression ) {
assert.eq( code, t.aggregate( expression ).code );
}

function assertResult( result, expression ) {
assert.eq( result, t.aggregate( expression ).result );
}

// Correct number of fields.
assertResult( [ { a:1 } ], { $project:{ _id:0, a:1 } } );

// Incorrect number of fields.
assertCode( 16435, {} );
assertCode( 16435, { $project:{ _id:0, a:1 }, $group:{ _id:0 } } );
assertCode( 16435, { $project:{ _id:0, a:1 }, $group:{ _id:0 }, $sort:{ a:1 } } );

// Invalid stage specification.
assertCode( 16436, { $noSuchStage:{ a:1 } } );
17 changes: 17 additions & 0 deletions jstests/cursorb.js
@@ -0,0 +1,17 @@
// The 'cursor not found in map -1' warning is not logged when get more exhausts a client cursor.
// SERVER-6931

t = db.jstests_cursorb;
t.drop();

// Exhaust a client cursor in get more.
for( i = 0; i < 200; ++i ) {
t.save( { a:i } );
}
t.find().itcount();

// Check that the 'cursor not found in map -1' message is not printed. This message indicates an
// attempt to look up a cursor with an invalid id and should never appear in the log.
log = db.adminCommand( { getLog:'global' } ).log
log.forEach( function( line ) { assert( !line.match( /cursor not found in map -1 / ),
'Cursor map lookup with id -1.' ); } );
11 changes: 9 additions & 2 deletions jstests/distinct3.js
Expand Up @@ -16,8 +16,15 @@ for( i = 0; i < 1000; ++i ) {
}
db.getLastError();

// The idea here is to try and remove the last match for the {a:1} index scan while distinct is yielding.
p = startParallelShell( 'for( i = 0; i < 2500; ++i ) { db.jstests_distinct3.remove({a:49}); for( j = 0; j < 20; ++j ) { db.jstests_distinct3.save({a:49,c:49,d:j}) } }' );
// Attempt to remove the last match for the {a:1} index scan while distinct is yielding.
p = startParallelShell( 'for( i = 0; i < 2500; ++i ) { ' +
' db.jstests_distinct3.remove( { a:49 } ); ' +
' for( j = 0; j < 20; ++j ) { ' +
' db.jstests_distinct3.save( { a:49, c:49, d:j } ); ' +
' } ' +
'} ' +
'// Wait for the above writes to complete. ' +
'db.getLastError(); ' );

for( i = 0; i < 100; ++i ) {
count = t.distinct( 'c', {$or:[{a:{$gte:0},d:0},{b:{$gte:0}}]} ).length;
Expand Down
41 changes: 32 additions & 9 deletions jstests/evalb.js
@@ -1,17 +1,40 @@
// Check the return value of a db.eval function running a database query, and ensure the function's
// contents are logged in the profile log.

t = db.evalb;
t.drop();
// Use a reserved database name to avoid a conflict in the parallel test suite.
var stddb = db;
var db = db.getSisterDB( 'evalb' );

t.save( { x : 3 } );
function profileCursor() {
return db.system.profile.find( { user:username } );
}

assert.eq( 3, db.eval( function(){ return db.evalb.findOne().x; } ) , "A" );
function lastOp() {
return profileCursor().sort( { $natural:-1 } ).next();
}

db.setProfilingLevel( 2 );
try {

assert.eq( 3, db.eval( function(){ return db.evalb.findOne().x; } ) , "B" );
username = 'jstests_evalb_user';
db.addUser( username, 'password', false, 1 );
db.auth( username, 'password' );

o = db.system.profile.find( { "command.$eval" : { $exists : true } } ).sort( { $natural : -1 } ).limit(1).next();
assert( tojson(o).indexOf( "findOne().x" ) > 0 , "C : " + tojson( o ) )
t = db.evalb;
t.drop();

db.setProfilingLevel( 0 );
t.save( { x:3 } );

assert.eq( 3, db.eval( function() { return db.evalb.findOne().x; } ), 'A' );

db.setProfilingLevel( 2 );

assert.eq( 3, db.eval( function() { return db.evalb.findOne().x; } ), 'B' );

o = lastOp();
assert( tojson( o ).indexOf( 'findOne().x' ) > 0, 'C : ' + tojson( o ) );
}
finally {

db.setProfilingLevel(0);
db = stddb;
}

0 comments on commit 0c260c0

Please sign in to comment.