Revert "feat: store split modulestore's course indexes in Django/MySQL"
This reverts commit 96e5ff8dce.
This commit is contained in:
@@ -114,8 +114,7 @@ class BadgrBackendTestCase(ModuleStoreTestCase, EventTrackingTestCase):
|
||||
Verify badge spec creation works.
|
||||
"""
|
||||
self.handler._get_access_token = Mock(return_value='12345')
|
||||
with self.allow_transaction_exception():
|
||||
self.handler._create_badge(self.badge_class)
|
||||
self.handler._create_badge(self.badge_class)
|
||||
args, kwargs = post.call_args
|
||||
assert args[0] == 'https://example.com/v2/issuers/test-issuer/badgeclasses'
|
||||
assert kwargs['files']['image'][0] == self.badge_class.image.name
|
||||
|
||||
@@ -196,8 +196,8 @@ class BadgeClassTest(ModuleStoreTestCase):
|
||||
Verify handing incomplete data for required fields when making a badge class raises an Integrity error.
|
||||
"""
|
||||
image = get_image('good')
|
||||
with pytest.raises(IntegrityError), self.allow_transaction_exception():
|
||||
BadgeClass.get_badge_class(slug='new_slug', issuing_component='new_component', image_file_handle=image)
|
||||
pytest.raises(IntegrityError, BadgeClass.get_badge_class, slug='new_slug', issuing_component='new_component',
|
||||
image_file_handle=image)
|
||||
|
||||
def test_get_for_user(self):
|
||||
"""
|
||||
|
||||
@@ -107,8 +107,7 @@ class BulkEnrollmentTest(ModuleStoreTestCase, LoginEnrollmentTestCase, APITestCa
|
||||
""" Test that non global staff users are forbidden from API use. """
|
||||
self.staff.is_staff = False
|
||||
self.staff.save()
|
||||
with self.allow_transaction_exception():
|
||||
response = self.request_bulk_enroll()
|
||||
response = self.request_bulk_enroll()
|
||||
assert response.status_code == 403
|
||||
|
||||
def test_missing_params(self):
|
||||
|
||||
@@ -271,22 +271,22 @@ class TestFieldOverrideSplitPerformance(FieldOverridePerformanceTestCase):
|
||||
__test__ = True
|
||||
|
||||
# TODO: decrease query count as part of REVO-28
|
||||
QUERY_COUNT = 34
|
||||
QUERY_COUNT = 33
|
||||
|
||||
TEST_DATA = {
|
||||
('no_overrides', 1, True, False): (QUERY_COUNT, 2),
|
||||
('no_overrides', 2, True, False): (QUERY_COUNT, 2),
|
||||
('no_overrides', 3, True, False): (QUERY_COUNT, 2),
|
||||
('ccx', 1, True, False): (QUERY_COUNT, 2),
|
||||
('ccx', 2, True, False): (QUERY_COUNT, 2),
|
||||
('ccx', 3, True, False): (QUERY_COUNT, 2),
|
||||
('ccx', 1, True, True): (QUERY_COUNT + 3, 2),
|
||||
('ccx', 2, True, True): (QUERY_COUNT + 3, 2),
|
||||
('ccx', 3, True, True): (QUERY_COUNT + 3, 2),
|
||||
('no_overrides', 1, False, False): (QUERY_COUNT, 2),
|
||||
('no_overrides', 2, False, False): (QUERY_COUNT, 2),
|
||||
('no_overrides', 3, False, False): (QUERY_COUNT, 2),
|
||||
('ccx', 1, False, False): (QUERY_COUNT, 2),
|
||||
('ccx', 2, False, False): (QUERY_COUNT, 2),
|
||||
('ccx', 3, False, False): (QUERY_COUNT, 2),
|
||||
('no_overrides', 1, True, False): (QUERY_COUNT, 3),
|
||||
('no_overrides', 2, True, False): (QUERY_COUNT, 3),
|
||||
('no_overrides', 3, True, False): (QUERY_COUNT, 3),
|
||||
('ccx', 1, True, False): (QUERY_COUNT, 3),
|
||||
('ccx', 2, True, False): (QUERY_COUNT, 3),
|
||||
('ccx', 3, True, False): (QUERY_COUNT, 3),
|
||||
('ccx', 1, True, True): (QUERY_COUNT + 2, 3),
|
||||
('ccx', 2, True, True): (QUERY_COUNT + 2, 3),
|
||||
('ccx', 3, True, True): (QUERY_COUNT + 2, 3),
|
||||
('no_overrides', 1, False, False): (QUERY_COUNT, 3),
|
||||
('no_overrides', 2, False, False): (QUERY_COUNT, 3),
|
||||
('no_overrides', 3, False, False): (QUERY_COUNT, 3),
|
||||
('ccx', 1, False, False): (QUERY_COUNT, 3),
|
||||
('ccx', 2, False, False): (QUERY_COUNT, 3),
|
||||
('ccx', 3, False, False): (QUERY_COUNT, 3),
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ class TestCCX(ModuleStoreTestCase):
|
||||
|
||||
def test_ccx_course_caching(self):
|
||||
"""verify that caching the propery works to limit queries"""
|
||||
with check_mongo_calls(2):
|
||||
with check_mongo_calls(3):
|
||||
# these statements are used entirely to demonstrate the
|
||||
# instance-level caching of these values on CCX objects. The
|
||||
# check_mongo_calls context is the point here.
|
||||
@@ -72,7 +72,7 @@ class TestCCX(ModuleStoreTestCase):
|
||||
"""verify that caching the start property works to limit queries"""
|
||||
now = datetime.now(utc)
|
||||
self.set_ccx_override('start', now)
|
||||
with check_mongo_calls(2):
|
||||
with check_mongo_calls(3):
|
||||
# these statements are used entirely to demonstrate the
|
||||
# instance-level caching of these values on CCX objects. The
|
||||
# check_mongo_calls context is the point here.
|
||||
@@ -97,7 +97,7 @@ class TestCCX(ModuleStoreTestCase):
|
||||
"""verify that caching the due property works to limit queries"""
|
||||
expected = datetime.now(utc)
|
||||
self.set_ccx_override('due', expected)
|
||||
with check_mongo_calls(2):
|
||||
with check_mongo_calls(3):
|
||||
# these statements are used entirely to demonstrate the
|
||||
# instance-level caching of these values on CCX objects. The
|
||||
# check_mongo_calls context is the point here.
|
||||
|
||||
@@ -224,17 +224,23 @@ class TestGetBlocksQueryCounts(TestGetBlocksQueryCountsBase):
|
||||
)
|
||||
|
||||
@ddt.data(
|
||||
(ModuleStoreEnum.Type.mongo, 5, True, 23),
|
||||
(ModuleStoreEnum.Type.mongo, 5, False, 13),
|
||||
(ModuleStoreEnum.Type.split, 2, True, 24),
|
||||
(ModuleStoreEnum.Type.split, 2, False, 14),
|
||||
*product(
|
||||
((ModuleStoreEnum.Type.mongo, 5), (ModuleStoreEnum.Type.split, 3)),
|
||||
(True, False),
|
||||
)
|
||||
)
|
||||
@ddt.unpack
|
||||
def test_query_counts_uncached(self, store_type, expected_mongo_queries, with_storage_backing, num_sql_queries):
|
||||
def test_query_counts_uncached(self, store_type_tuple, with_storage_backing):
|
||||
store_type, expected_mongo_queries = store_type_tuple
|
||||
with override_waffle_switch(STORAGE_BACKING_FOR_CACHE, active=with_storage_backing):
|
||||
course = self._create_course(store_type)
|
||||
clear_course_from_cache(course.id)
|
||||
|
||||
if with_storage_backing:
|
||||
num_sql_queries = 23
|
||||
else:
|
||||
num_sql_queries = 13
|
||||
|
||||
self._get_blocks(
|
||||
course,
|
||||
expected_mongo_queries,
|
||||
|
||||
@@ -1014,9 +1014,9 @@ class TestTOC(ModuleStoreTestCase):
|
||||
# Split makes 2 queries to load the course to depth 2:
|
||||
# - 1 for the structure
|
||||
# - 1 for 5 definitions
|
||||
# Split makes 1 MySQL query to render the toc:
|
||||
# - 1 MySQL for the active version at the start of the bulk operation (no mongo calls)
|
||||
@ddt.data((ModuleStoreEnum.Type.mongo, 3, 0, 0), (ModuleStoreEnum.Type.split, 2, 0, 0))
|
||||
# Split makes 1 query to render the toc:
|
||||
# - 1 for the active version at the start of the bulk operation
|
||||
@ddt.data((ModuleStoreEnum.Type.mongo, 3, 0, 0), (ModuleStoreEnum.Type.split, 2, 0, 1))
|
||||
@ddt.unpack
|
||||
def test_toc_toy_from_chapter(self, default_ms, setup_finds, setup_sends, toc_finds):
|
||||
with self.store.default_store(default_ms):
|
||||
@@ -1054,9 +1054,9 @@ class TestTOC(ModuleStoreTestCase):
|
||||
# Split makes 2 queries to load the course to depth 2:
|
||||
# - 1 for the structure
|
||||
# - 1 for 5 definitions
|
||||
# Split makes 1 MySQL query to render the toc:
|
||||
# - 1 MySQL for the active version at the start of the bulk operation (no mongo calls)
|
||||
@ddt.data((ModuleStoreEnum.Type.mongo, 3, 0, 0), (ModuleStoreEnum.Type.split, 2, 0, 0))
|
||||
# Split makes 1 query to render the toc:
|
||||
# - 1 for the active version at the start of the bulk operation
|
||||
@ddt.data((ModuleStoreEnum.Type.mongo, 3, 0, 0), (ModuleStoreEnum.Type.split, 2, 0, 1))
|
||||
@ddt.unpack
|
||||
def test_toc_toy_from_section(self, default_ms, setup_finds, setup_sends, toc_finds):
|
||||
with self.store.default_store(default_ms):
|
||||
|
||||
@@ -389,7 +389,7 @@ class IndexQueryTestCase(ModuleStoreTestCase):
|
||||
|
||||
@ddt.data(
|
||||
(ModuleStoreEnum.Type.mongo, 10, 164),
|
||||
(ModuleStoreEnum.Type.split, 3, 161),
|
||||
(ModuleStoreEnum.Type.split, 4, 160),
|
||||
)
|
||||
@ddt.unpack
|
||||
def test_index_query_counts(self, store_type, expected_mongo_query_count, expected_mysql_query_count):
|
||||
|
||||
@@ -162,9 +162,9 @@ class RenderXBlockTestMixin(MasqueradeMixin, metaclass=ABCMeta):
|
||||
|
||||
@ddt.data(
|
||||
('vertical_block', ModuleStoreEnum.Type.mongo, 13),
|
||||
('vertical_block', ModuleStoreEnum.Type.split, 4),
|
||||
('vertical_block', ModuleStoreEnum.Type.split, 6),
|
||||
('html_block', ModuleStoreEnum.Type.mongo, 14),
|
||||
('html_block', ModuleStoreEnum.Type.split, 4),
|
||||
('html_block', ModuleStoreEnum.Type.split, 6),
|
||||
)
|
||||
@ddt.unpack
|
||||
def test_courseware_html(self, block_name, default_store, mongo_calls):
|
||||
@@ -192,7 +192,7 @@ class RenderXBlockTestMixin(MasqueradeMixin, metaclass=ABCMeta):
|
||||
|
||||
@ddt.data(
|
||||
(ModuleStoreEnum.Type.mongo, 5),
|
||||
(ModuleStoreEnum.Type.split, 4),
|
||||
(ModuleStoreEnum.Type.split, 5),
|
||||
)
|
||||
@ddt.unpack
|
||||
def test_success_enrolled_staff(self, default_store, mongo_calls):
|
||||
|
||||
@@ -402,7 +402,7 @@ class ViewsQueryCountTestCase(
|
||||
|
||||
@ddt.data(
|
||||
(ModuleStoreEnum.Type.mongo, 3, 4, 39),
|
||||
(ModuleStoreEnum.Type.split, 3, 8, 44),
|
||||
(ModuleStoreEnum.Type.split, 3, 13, 39),
|
||||
)
|
||||
@ddt.unpack
|
||||
@count_queries
|
||||
@@ -411,7 +411,7 @@ class ViewsQueryCountTestCase(
|
||||
|
||||
@ddt.data(
|
||||
(ModuleStoreEnum.Type.mongo, 3, 3, 35),
|
||||
(ModuleStoreEnum.Type.split, 3, 6, 39),
|
||||
(ModuleStoreEnum.Type.split, 3, 10, 35),
|
||||
)
|
||||
@ddt.unpack
|
||||
@count_queries
|
||||
|
||||
@@ -413,10 +413,10 @@ class CourseTopicsViewTest(DiscussionAPIViewTestMixin, ModuleStoreTestCase):
|
||||
(2, ModuleStoreEnum.Type.mongo, 2, {"Test Topic 1": {"id": "test_topic_1"}}),
|
||||
(2, ModuleStoreEnum.Type.mongo, 2,
|
||||
{"Test Topic 1": {"id": "test_topic_1"}, "Test Topic 2": {"id": "test_topic_2"}}),
|
||||
(2, ModuleStoreEnum.Type.split, 2, {"Test Topic 1": {"id": "test_topic_1"}}),
|
||||
(2, ModuleStoreEnum.Type.split, 2,
|
||||
(2, ModuleStoreEnum.Type.split, 3, {"Test Topic 1": {"id": "test_topic_1"}}),
|
||||
(2, ModuleStoreEnum.Type.split, 3,
|
||||
{"Test Topic 1": {"id": "test_topic_1"}, "Test Topic 2": {"id": "test_topic_2"}}),
|
||||
(10, ModuleStoreEnum.Type.split, 2, {"Test Topic 1": {"id": "test_topic_1"}}),
|
||||
(10, ModuleStoreEnum.Type.split, 3, {"Test Topic 1": {"id": "test_topic_1"}}),
|
||||
)
|
||||
@ddt.unpack
|
||||
def test_bulk_response(self, modules_count, module_store, mongo_calls, topics):
|
||||
|
||||
@@ -483,15 +483,15 @@ class SingleThreadQueryCountTestCase(ForumsEnableMixin, ModuleStoreTestCase):
|
||||
(ModuleStoreEnum.Type.mongo, False, 1, 5, 2, 21, 7),
|
||||
(ModuleStoreEnum.Type.mongo, False, 50, 5, 2, 21, 7),
|
||||
# split mongo: 3 queries, regardless of thread response size.
|
||||
(ModuleStoreEnum.Type.split, False, 1, 2, 2, 22, 8),
|
||||
(ModuleStoreEnum.Type.split, False, 50, 2, 2, 22, 8),
|
||||
(ModuleStoreEnum.Type.split, False, 1, 3, 3, 21, 8),
|
||||
(ModuleStoreEnum.Type.split, False, 50, 3, 3, 21, 8),
|
||||
|
||||
# Enabling Enterprise integration should have no effect on the number of mongo queries made.
|
||||
(ModuleStoreEnum.Type.mongo, True, 1, 5, 2, 21, 7),
|
||||
(ModuleStoreEnum.Type.mongo, True, 50, 5, 2, 21, 7),
|
||||
# split mongo: 3 queries, regardless of thread response size.
|
||||
(ModuleStoreEnum.Type.split, True, 1, 2, 2, 22, 8),
|
||||
(ModuleStoreEnum.Type.split, True, 50, 2, 2, 22, 8),
|
||||
(ModuleStoreEnum.Type.split, True, 1, 3, 3, 21, 8),
|
||||
(ModuleStoreEnum.Type.split, True, 50, 3, 3, 21, 8),
|
||||
)
|
||||
@ddt.unpack
|
||||
def test_number_of_mongo_queries(
|
||||
|
||||
@@ -164,8 +164,8 @@ class RecalculateSubsectionGradeTest(HasCourseWithProblemsMixin, ModuleStoreTest
|
||||
@ddt.data(
|
||||
(ModuleStoreEnum.Type.mongo, 1, 39, True),
|
||||
(ModuleStoreEnum.Type.mongo, 1, 39, False),
|
||||
(ModuleStoreEnum.Type.split, 2, 40, True),
|
||||
(ModuleStoreEnum.Type.split, 2, 40, False),
|
||||
(ModuleStoreEnum.Type.split, 3, 39, True),
|
||||
(ModuleStoreEnum.Type.split, 3, 39, False),
|
||||
)
|
||||
@ddt.unpack
|
||||
def test_query_counts(self, default_store, num_mongo_calls, num_sql_calls, create_multiple_subsections):
|
||||
@@ -178,7 +178,7 @@ class RecalculateSubsectionGradeTest(HasCourseWithProblemsMixin, ModuleStoreTest
|
||||
|
||||
@ddt.data(
|
||||
(ModuleStoreEnum.Type.mongo, 1, 39),
|
||||
(ModuleStoreEnum.Type.split, 2, 40),
|
||||
(ModuleStoreEnum.Type.split, 3, 39),
|
||||
)
|
||||
@ddt.unpack
|
||||
def test_query_counts_dont_change_with_more_content(self, default_store, num_mongo_calls, num_sql_calls):
|
||||
@@ -224,7 +224,7 @@ class RecalculateSubsectionGradeTest(HasCourseWithProblemsMixin, ModuleStoreTest
|
||||
|
||||
@ddt.data(
|
||||
(ModuleStoreEnum.Type.mongo, 1, 22),
|
||||
(ModuleStoreEnum.Type.split, 2, 23),
|
||||
(ModuleStoreEnum.Type.split, 3, 22),
|
||||
)
|
||||
@ddt.unpack
|
||||
def test_persistent_grades_not_enabled_on_course(self, default_store, num_mongo_queries, num_sql_queries):
|
||||
@@ -239,7 +239,7 @@ class RecalculateSubsectionGradeTest(HasCourseWithProblemsMixin, ModuleStoreTest
|
||||
|
||||
@ddt.data(
|
||||
(ModuleStoreEnum.Type.mongo, 1, 40),
|
||||
(ModuleStoreEnum.Type.split, 2, 41),
|
||||
(ModuleStoreEnum.Type.split, 3, 40),
|
||||
)
|
||||
@ddt.unpack
|
||||
def test_persistent_grades_enabled_on_course(self, default_store, num_mongo_queries, num_sql_queries):
|
||||
|
||||
@@ -430,7 +430,7 @@ class MultiProblemModulestoreAccessTestCase(CourseStructureTestCase, SharedModul
|
||||
self.client.login(username=self.student.username, password=password)
|
||||
|
||||
@ddt.data(
|
||||
(ModuleStoreEnum.Type.split, 2),
|
||||
(ModuleStoreEnum.Type.split, 3),
|
||||
(ModuleStoreEnum.Type.mongo, 2),
|
||||
)
|
||||
@ddt.unpack
|
||||
|
||||
@@ -252,12 +252,12 @@ class TestSetDueDateExtension(ModuleStoreTestCase):
|
||||
|
||||
def test_set_due_date_extension_invalid_date(self):
|
||||
extended = datetime.datetime(2009, 1, 1, 0, 0, tzinfo=UTC)
|
||||
with pytest.raises(tools.DashboardError), self.allow_transaction_exception():
|
||||
with pytest.raises(tools.DashboardError):
|
||||
tools.set_due_date_extension(self.course, self.week1, self.user, extended)
|
||||
|
||||
def test_set_due_date_extension_no_date(self):
|
||||
extended = datetime.datetime(2013, 12, 25, 0, 0, tzinfo=UTC)
|
||||
with pytest.raises(tools.DashboardError), self.allow_transaction_exception():
|
||||
with pytest.raises(tools.DashboardError):
|
||||
tools.set_due_date_extension(self.course, self.week3, self.user, extended)
|
||||
|
||||
def test_reset_due_date_extension(self):
|
||||
|
||||
@@ -673,6 +673,6 @@ class TestInstructorDashboardPerformance(ModuleStoreTestCase, LoginEnrollmentTes
|
||||
|
||||
# check MongoDB calls count
|
||||
url = reverse('spoc_gradebook', kwargs={'course_id': self.course.id})
|
||||
with check_mongo_calls(6):
|
||||
with check_mongo_calls(9):
|
||||
response = self.client.get(url)
|
||||
assert response.status_code == 200
|
||||
|
||||
@@ -371,11 +371,11 @@ class TestInstructorGradeReport(InstructorGradeReportTestCase):
|
||||
self._verify_cell_data_for_user(verified_user.username, course.id, 'Certificate Eligible', 'Y', num_rows=2)
|
||||
|
||||
@ddt.data(
|
||||
(ModuleStoreEnum.Type.mongo, 4, 46),
|
||||
(ModuleStoreEnum.Type.split, 2, 47),
|
||||
(ModuleStoreEnum.Type.mongo, 4),
|
||||
(ModuleStoreEnum.Type.split, 3),
|
||||
)
|
||||
@ddt.unpack
|
||||
def test_query_counts(self, store_type, mongo_count, expected_query_count):
|
||||
def test_query_counts(self, store_type, mongo_count):
|
||||
with self.store.default_store(store_type):
|
||||
experiment_group_a = Group(2, 'Expériment Group A')
|
||||
experiment_group_b = Group(3, 'Expériment Group B')
|
||||
@@ -401,6 +401,7 @@ class TestInstructorGradeReport(InstructorGradeReportTestCase):
|
||||
|
||||
RequestCache.clear_all_namespaces()
|
||||
|
||||
expected_query_count = 46
|
||||
with patch('lms.djangoapps.instructor_task.tasks_helper.runner._get_current_task'):
|
||||
with check_mongo_calls(mongo_count):
|
||||
with self.assertNumQueries(expected_query_count):
|
||||
|
||||
@@ -2910,7 +2910,6 @@ INSTALLED_APPS = [
|
||||
'lms.djangoapps.courseware',
|
||||
'lms.djangoapps.coursewarehistoryextended',
|
||||
'common.djangoapps.student.apps.StudentConfig',
|
||||
'common.djangoapps.split_modulestore_django.apps.SplitModulestoreDjangoBackendAppConfig',
|
||||
|
||||
'lms.djangoapps.static_template_view',
|
||||
'lms.djangoapps.staticbook',
|
||||
|
||||
Reference in New Issue
Block a user