Skip to content

Commit f51d00f

Browse files
committed
Remove transaction_shim from correctness.
1 parent 4445ac6 commit f51d00f

File tree

5 files changed

+30
-118
lines changed

5 files changed

+30
-118
lines changed

test/correctness/document-correctness.py

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import pymongo
3131

3232
import gen
33-
import transactional_shim
3433
import util
3534
from mongo_model import MongoCollection
3635
from 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

7372
def 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"

test/correctness/gen.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ class generator_options:
5454
allow_sorts = True
5555
multi_updates = True
5656
nested_elemmatch = True
57-
use_transactions = True
5857

5958

6059
def random_string(length):

test/correctness/mongo_model.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ def insert_one(self, dict):
495495
def insert_many(self, list):
496496
self.insert(list)
497497

498-
def find(self, query, fields=None):
498+
def find(self, query, fields=None, batch_size=None):
499499
if len(query) == 0:
500500
results = self.data.values()
501501
else:
@@ -531,6 +531,10 @@ def replace(self, key, new_value):
531531
self.data[key] = deepcopy(new_value)
532532
self.data[key]['_id'] = _id
533533

534+
def drop(self):
535+
self.drop_indexes()
536+
self.remove()
537+
534538
# So that we can use PyMongo and MongoModel implementations of a "collection" interchangeably
535539
def drop_indexes(self):
536540
self.indexes = []

test/correctness/transactional_shim.py

Lines changed: 0 additions & 92 deletions
This file was deleted.

test/correctness/util.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1100,7 +1100,6 @@ def weaken_tests_for_mongo(ns):
11001100
gen.generator_options.allow_long_ids = False
11011101
gen.generator_options.allow_id_elemmatch = False
11021102
gen.generator_options.allow_general_nots = False
1103-
gen.generator_options.use_transactions = False
11041103
# gen.generator_options.index_parallel_arrays = False
11051104
# gen.generator_options.allow_long_fields = False
11061105
ns['no_indexes'] = False

0 commit comments

Comments
 (0)