From 959b395da0195aa50a95b598204703e82afd582a Mon Sep 17 00:00:00 2001 From: Bernie Hackett Date: Fri, 17 Feb 2017 16:02:06 -0800 Subject: [PATCH] Fix infrequent read preference test failure --- test/test_read_preferences.py | 50 +++++++++++++++++------------------ 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/test/test_read_preferences.py b/test/test_read_preferences.py index b4f947bbf..ca0f085ff 100644 --- a/test/test_read_preferences.py +++ b/test/test_read_preferences.py @@ -471,6 +471,31 @@ class TestCommandAndReadPreference(TestReplicaSetClientBase): ctx.exit() # Obedient commands. + # Geo stuff. + self.c.pymongo_test.test.create_index([('location', '2d')]) + + self.c.pymongo_test.test.create_index([('location', 'geoHaystack'), + ('key', 1)], bucketSize=100) + + # Attempt to await replication of indexes replicated. + self.c.pymongo_test.test2.insert({}, w=self.w) + self.c.pymongo_test.test2.remove({}, w=self.w) + + self._test_fn(True, lambda: self.c.pymongo_test.command( + 'geoNear', 'test', near=[0, 0])) + self._test_fn(True, lambda: self.c.pymongo_test.command(SON([ + ('geoNear', 'test'), ('near', [0, 0])]))) + + self._test_fn( + True, lambda: self.c.pymongo_test.command( + 'geoSearch', 'test', near=[33, 33], maxDistance=6, + search={'type': 'restaurant'}, limit=30)) + + self._test_fn( + True, lambda: self.c.pymongo_test.command(SON([ + ('geoSearch', 'test'), ('near', [33, 33]), ('maxDistance', 6), + ('search', {'type': 'restaurant'}), ('limit', 30)]))) + self._test_fn(True, lambda: self.c.pymongo_test.command('group', { 'ns': 'test', 'key': {'a': 1}, '$reduce': 'function(obj, prev) { }', 'initial': {}})) @@ -498,31 +523,6 @@ class TestCommandAndReadPreference(TestReplicaSetClientBase): self._test_fn(True, lambda: self.c.pymongo_test.command(SON([ ('distinct', 'test'), ('key', 'a'), ('query', {'a': 1})]))) - # Geo stuff. - self.c.pymongo_test.test.create_index([('location', '2d')]) - - self.c.pymongo_test.test.create_index([('location', 'geoHaystack'), - ('key', 1)], bucketSize=100) - - # Attempt to await replication of indexes replicated. - self.c.pymongo_test.test2.insert({}, w=self.w) - self.c.pymongo_test.test2.remove({}, w=self.w) - - self._test_fn(True, lambda: self.c.pymongo_test.command( - 'geoNear', 'test', near=[0, 0])) - self._test_fn(True, lambda: self.c.pymongo_test.command(SON([ - ('geoNear', 'test'), ('near', [0, 0])]))) - - self._test_fn( - True, lambda: self.c.pymongo_test.command( - 'geoSearch', 'test', near=[33, 33], maxDistance=6, - search={'type': 'restaurant'}, limit=30)) - - self._test_fn( - True, lambda: self.c.pymongo_test.command(SON([ - ('geoSearch', 'test'), ('near', [33, 33]), ('maxDistance', 6), - ('search', {'type': 'restaurant'}), ('limit', 30)]))) - if (version.at_least(self.c, (2, 1, 0)) and not version.at_least(self.c, (3, 5, 1))): self._test_fn(