3030import pymongo
3131
3232import gen
33- import transactional_shim
3433import util
3534from mongo_model import MongoCollection
3635from mongo_model import MongoModel
@@ -60,8 +59,8 @@ def get_clients_and_collections(ns):
6059 db2 = client2 ['test' ]
6160 collection1 = db1 ['correctness' + instance ]
6261 collection2 = db2 ['correctness' + instance ]
63- transactional_shim . remove ( collection1 )
64- transactional_shim . remove ( collection2 )
62+ collection1 . drop ( )
63+ collection2 . drop ( )
6564 return (client1 , client2 , collection1 , collection2 )
6665
6766
@@ -72,7 +71,10 @@ def get_collections(ns):
7271
7372def get_result (query , collection , projection , sort , limit , skip , exception_msg ):
7473 try :
75- cur = transactional_shim .find (collection , query , projection )
74+ if gen .global_prng .random () < 0.10 :
75+ cur = collection .find (query , projection , batch_size = gen .global_prng .randint (2 , 10 ))
76+ else :
77+ cur = collection .find (query , projection )
7678
7779 if sort is None :
7880 ret = [util .deep_convert_to_unordered (i ) for i in cur ]
@@ -221,7 +223,7 @@ def test_update(collections, verbose=False):
221223 util .trace ('debug' , 'Update:' , str (update ['update' ]))
222224 util .trace ('debug' , 'Number results from collection: ' , gen .count_query_results (
223225 collections [0 ], update ['query' ]))
224- for item in transactional_shim . find ( collections [0 ], update ['query' ]):
226+ for item in collections [0 ]. find ( update ['query' ]):
225227 util .trace ('debug' , 'Find Result0:' , item )
226228
227229 exception = []
@@ -230,12 +232,11 @@ def test_update(collections, verbose=False):
230232 try :
231233 if verbose :
232234 all = [x for x in coll .find (dict ())]
233- for item in transactional_shim .find (coll , update ['query' ]):
235+ for item in coll .find (update ['query' ]):
234236 print 'Before update doc:' , item
235237 print 'Before update coll size: ' , len (all )
236238
237- transactional_shim .update (
238- coll , update ['query' ], update ['update' ], upsert = update ['upsert' ], multi = update ['multi' ])
239+ coll .update (update ['query' ], update ['update' ], upsert = update ['upsert' ], multi = update ['multi' ])
239240
240241 if verbose :
241242 all = [x for x in coll .find (dict ())]
@@ -296,14 +297,18 @@ def _run_operation_(op1, op2):
296297 try :
297298 func1 (* args1 , ** kwargs1 )
298299 except pymongo .errors .OperationFailure as e :
300+ print "Failed func1 with " + str (e )
299301 exceptionOne = e
300302 except MongoModelException as e :
303+ print "Failed func1 with " + str (e )
301304 exceptionOne = e
302305 try :
303- func1 (* args2 , ** kwargs2 )
306+ func2 (* args2 , ** kwargs2 )
304307 except pymongo .errors .OperationFailure as e :
308+ print "Failed func2 with " + str (e )
305309 exceptionTwo = e
306310 except MongoModelException as e :
311+ print "Failed func2 with " + str (e )
307312 exceptionTwo = e
308313
309314 if ((exceptionOne is None and exceptionTwo is None )
@@ -326,14 +331,11 @@ def _run_operation_(op1, op2):
326331
327332 fname = util .save_cmd_line (util .command_line_str (ns , seed ))
328333
329- if indexes_enabled :
330- transactional_shim .drop_indexes (collection1 )
331- transactional_shim .drop_indexes (collection2 )
332- transactional_shim .remove (collection1 )
333- transactional_shim .remove (collection2 )
334+ collection1 .drop ()
335+ collection2 .drop ()
334336
335337 indexes = []
336- num_of_indexes = 5 ;
338+ num_of_indexes = 5
337339 indexes_first = gen .global_prng .choice ([True , False ])
338340 if indexes_enabled :
339341 for i in range (0 , num_of_indexes ):
@@ -352,9 +354,9 @@ def _run_operation_(op1, op2):
352354 else :
353355 uniqueIndex = False
354356 okay = _run_operation_ (
355- (transactional_shim .ensure_index , (collection1 , i ), {"unique" :uniqueIndex }),
356- (transactional_shim .ensure_index , (collection2 , i ), {"unique" :uniqueIndex })
357- )
357+ (collection1 .ensure_index , (i , ), {"unique" : uniqueIndex }),
358+ (collection2 .ensure_index , (i , ), {"unique" : uniqueIndex })
359+ )
358360 if not okay :
359361 return (okay , fname , None )
360362 ii += 1
@@ -364,9 +366,9 @@ def _run_operation_(op1, op2):
364366 docs .append (doc )
365367
366368 okay = _run_operation_ (
367- (transactional_shim .insert , (collection1 , docs ), {}),
368- (transactional_shim .insert , (collection2 , docs ), {})
369- )
369+ (collection1 .insert , (docs , ), {}),
370+ (collection2 .insert , (docs , ), {})
371+ )
370372 if not okay :
371373 print "Failed when doing inserts"
372374 return (okay , fname , None )
@@ -379,8 +381,8 @@ def _run_operation_(op1, op2):
379381 else :
380382 uniqueIndex = False
381383 okay = _run_operation_ (
382- (transactional_shim .ensure_index , (collection1 , i ), {"unique" :uniqueIndex }),
383- (transactional_shim .ensure_index , (collection2 , i ), {"unique" :uniqueIndex })
384+ (collection1 .ensure_index , (i , ), {"unique" : uniqueIndex }),
385+ (collection2 .ensure_index , (i , ), {"unique" : uniqueIndex })
384386 )
385387 if not okay :
386388 print "Failed when adding index after insert"
0 commit comments