0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-30 09:06:21 +01:00
This commit is contained in:
Dwight 2010-05-19 13:12:04 -04:00
commit 103ce4cc69
2 changed files with 98 additions and 40 deletions

View File

@ -0,0 +1,82 @@
#!/usr/bin/python
# Download mongodb stuff (at present builds, sources, docs, but not
# drivers).
# Usage: <progname> [directory] # directory defaults to cwd.
# FIXME: this script is fairly sloppy.
import sys
import os
import urllib2
import time
import hashlib
import warnings
def report(url, filename):
print "downloading %s to %s" % (url, filename)
def checkmd5(md5str, filename):
m = hashlib.md5()
m.update(open(filename, 'rb').read())
d = m.hexdigest()
if d != md5str:
warnings.warn("md5sum mismatch for file %s: wanted %s; got %s" % (filename, md5str, d))
osarches=(("osx", ("i386", "i386-tiger", "x86_64"), ("tgz", )),
("linux", ("i686", "x86_64"), ("tgz", )),
("win32", ("i386", "x86_64"), ("zip", )),
("sunos5", ("i86pc", "x86_64"), ("tgz", )),
("src", ("src", ), ("tar.gz", "zip")), )
# KLUDGE: this will need constant editing.
versions = ("1.4.2", "1.5.1", "latest")
url_format = "http://downloads.mongodb.org/%s/mongodb-%s-%s.%s"
filename_format = "mongodb-%s-%s.%s"
def do_it():
for version in versions:
for (os, architectures, archives) in osarches:
for architecture in architectures:
for archive in archives:
osarch = os + '-' + architecture if architecture != 'src' else 'src'
# ugh.
if architecture == 'src' and version == 'latest':
if archive == 'tar.gz':
archive2 = 'tarball'
elif archive == 'zip':
archive2 == 'zipball'
url = "http://github.com/mongodb/mongo/"+archive2+"/master"
version2 = "master"
else:
version2 = version if architecture != 'src' else 'r'+version
url = url_format % (os, osarch, version2, archive)
# ugh ugh
md5url = url+'.md5' if architecture != 'src' else None
filename = filename_format % (osarch, version2, archive)
report(url, filename)
open(filename, 'w').write(urllib2.urlopen(url).read())
if md5url:
print "fetching md5 url " + md5url
md5str = urllib2.urlopen(md5url).read()
checkmd5(md5str, filename)
# FIXME: in principle, the doc PDFs could be out of date.
docs_url = time.strftime("http://downloads.mongodb.org/docs/mongodb-docs-%Y-%m-%d.pdf")
docs_filename = time.strftime("mongodb-docs-%Y-%m-%d.pdf")
report(docs_url, docs_filename)
open(docs_filename, 'w').write(urllib2.urlopen(docs_url).read())
# Drivers... FIXME: drivers.
#langs=("c", "java", "python", "php", "perl")
if len(sys.argv) > 1:
dir=sys.argv[1]
os.makedirs(dir)
os.chdir(dir)
print """NOTE: the md5sums for all the -latest tarballs are out of
date. You will probably see warnings as this script runs. (If you
don't, feel free to delete this note.)"""
do_it()

View File

@ -29,24 +29,14 @@
namespace mongo {
extern BSONObj id_obj;
Message _runQuery(Message& m, QueryMessage& q ){
void runQuery(Message& m, QueryMessage& q, Message &response ){
CurOp op( &(cc()) );
op.ensureStarted();
Message b;
{
Message response;
runQuery( m , q , op, response );
MsgData *a = response.header();
b = response;
MsgData *bb = b.header();
cout << "z";
}
double x = 99;
cout << "z";
MsgData *c = b.header();
double qqx = 99;
cout << "zzzzzzzzzzzzzzzzzzzzzzzz" << qqx << endl;
return b;
runQuery( m , q , op, response );
}
void runQuery(Message& m, QueryMessage& q ){
Message response;
runQuery( m, q, response );
}
} // namespace mongo
@ -789,29 +779,15 @@ namespace QueryOptimizerTests {
log() << "end QueryMissingNs" << endl;
}
void run() {
{
Message m;
assembleRequest( "unittests.missingNS", BSONObj(), 0, 0, 0, 0, m );
stringstream ss;
cout << "a" << endl;
{
cout << "b" << endl;
DbMessage d(m);
cout << "c" << endl;
QueryMessage q(d);
cout << "d" << endl;
Message x = _runQuery(m, q);
MsgData *md = x.header();
QueryResult *qr = (QueryResult *) md;
ASSERT_EQUALS( 0, qr->nReturned );
cout << "e" << endl;
}
cout << "tmp" << endl;
}
cout << "tmp" << endl;
Message m;
assembleRequest( "unittests.missingNS", BSONObj(), 0, 0, 0, 0, m );
DbMessage d(m);
QueryMessage q(d);
Message ret;
runQuery( m, q, ret );
ASSERT_EQUALS( 0, ((QueryResult*)ret.header())->nReturned );
}
};
class UnhelpfulIndex : public Base {
@ -1082,7 +1058,7 @@ namespace QueryOptimizerTests {
{
DbMessage d(m);
QueryMessage q(d);
_runQuery( m, q);
runQuery( m, q);
}
ASSERT( BSON( "$natural" << 1 ).woCompare( NamespaceDetailsTransient::_get( ns() ).indexForPattern( FieldRangeSet( ns(), BSON( "b" << 0 << "a" << GTE << 0 ) ).pattern() ) ) == 0 );
@ -1091,7 +1067,7 @@ namespace QueryOptimizerTests {
{
DbMessage d(m2);
QueryMessage q(d);
_runQuery( m2, q);
runQuery( m2, q);
}
ASSERT( BSON( "a" << 1 ).woCompare( NamespaceDetailsTransient::_get( ns() ).indexForPattern( FieldRangeSet( ns(), BSON( "b" << 0 << "a" << GTE << 0 ) ).pattern() ) ) == 0 );
ASSERT_EQUALS( 2, NamespaceDetailsTransient::_get( ns() ).nScannedForPattern( FieldRangeSet( ns(), BSON( "b" << 0 << "a" << GTE << 0 ) ).pattern() ) );