Debug occasionally-failing test_large_limit

This commit is contained in:
A. Jesse Jiryu Davis 2012-06-10 00:03:53 -04:00
parent e3f3bf23ea
commit 58b3d646bd

View File

@ -1155,21 +1155,25 @@ class TestCollection(unittest.TestCase):
def test_large_limit(self):
db = self.db
db.drop_collection("test")
db.test.create_index([('x', 1)])
db.test_large_limit.create_index([('x', 1)])
for i in range(2000):
db.test.insert({"x": i, "y": "mongomongo" * 1000}, safe=True)
doc = {"x": i, "y": "mongomongo" * 1000}
db.test_large_limit.insert(doc, safe=True)
# Wait for insert to complete; often mysteriously failing in Jenkins
st = time.time()
while len(list(db.test.find())) < 2000 and time.time() - st < 30:
while (
len(list(db.test_large_limit.find())) < 2000
and time.time() - st < 30
):
time.sleep(1)
self.assertEqual(2000, len(list(db.test.find())))
self.assertEqual(2000, len(list(db.test_large_limit.find())))
i = 0
y = 0
for doc in db.test.find(limit=1900).sort([('x', 1)]):
for doc in db.test_large_limit.find(limit=1900).sort([('x', 1)]):
i += 1
y += doc["x"]