Catch BSON errors as well as PyMongo errors when emitting

MongoDB events.

TNL-2035
This commit is contained in:
Diana Huang
2015-05-13 11:00:31 -04:00
parent ac8b75ca7f
commit 362c632ad7
2 changed files with 4 additions and 3 deletions

View File

@@ -7,6 +7,7 @@ import logging
import pymongo
from pymongo import MongoClient
from pymongo.errors import PyMongoError
from bson.errors import BSONError
from track.backends import BaseBackend
@@ -89,8 +90,9 @@ class MongoBackend(BaseBackend):
"""Insert the event in to the Mongo collection"""
try:
self.collection.insert(event, manipulate=False)
except PyMongoError:
# The event will be lost in case of a connection error.
except (PyMongoError, BSONError):
# The event will be lost in case of a connection error or any error
# that occurs when trying to insert the event into Mongo.
# pymongo will re-connect/re-authenticate automatically
# during the next event.
msg = 'Error inserting to MongoDB event tracker backend'

View File

@@ -1044,7 +1044,6 @@ class GroupConfigurationsTest(ContainerBase, SplitTestMixin):
rendered_group_names = self.get_select_options(page=courseware_page, selector=".split-test-select")
self.assertListEqual(group_names, rendered_group_names)
@skip # TODO fix this, see TNL-2035
def test_split_test_LMS_staff_view(self):
"""
Scenario: Ensure that split test is correctly rendered in LMS staff mode as it is