Test multiple threads linear growth
This commit is contained in:
@@ -8,17 +8,19 @@ import datetime
|
||||
from contentstore.tests.utils import CourseTestCase
|
||||
from contentstore.utils import reverse_course_url, add_instructor
|
||||
from contentstore.views.access import has_course_access
|
||||
from contentstore.views.course import course_outline_initial_state
|
||||
from contentstore.views.course import course_outline_initial_state, _course_outline_json
|
||||
from contentstore.views.item import create_xblock_info, VisibilityState
|
||||
from course_action_state.models import CourseRerunState
|
||||
from util.date_utils import get_default_time_display
|
||||
from xmodule.modulestore import ModuleStoreEnum
|
||||
from xmodule.modulestore.django import modulestore
|
||||
from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory
|
||||
from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory, check_mongo_calls
|
||||
from opaque_keys.edx.locator import CourseLocator
|
||||
from student.tests.factories import UserFactory
|
||||
from course_action_state.managers import CourseRerunUIStateManager
|
||||
from django.conf import settings
|
||||
import ddt
|
||||
import threading
|
||||
|
||||
|
||||
class TestCourseIndex(CourseTestCase):
|
||||
@@ -308,3 +310,28 @@ class TestCourseOutline(CourseTestCase):
|
||||
|
||||
self.assertEqual(_get_release_date(response), get_default_time_display(self.course.start))
|
||||
_assert_settings_link_present(response)
|
||||
|
||||
|
||||
@ddt.ddt
|
||||
class OutlinePerfTest(TestCourseOutline):
|
||||
def setUp(self):
|
||||
with modulestore().default_store(ModuleStoreEnum.Type.split):
|
||||
super(OutlinePerfTest, self).setUp()
|
||||
|
||||
@ddt.data(1, 2, 4, 8)
|
||||
def test_query_counts(self, num_threads):
|
||||
"""
|
||||
Test that increasing threads does not increase query counts
|
||||
"""
|
||||
def test_client():
|
||||
with modulestore().default_store(ModuleStoreEnum.Type.split):
|
||||
with modulestore().bulk_operations(self.course.id):
|
||||
course = modulestore().get_course(self.course.id, depth=0)
|
||||
return _course_outline_json(None, course)
|
||||
|
||||
with check_mongo_calls(5 * num_threads, 0):
|
||||
outline_threads = [threading.Thread(target=test_client) for __ in range(num_threads)]
|
||||
[thread.start() for thread in outline_threads]
|
||||
self.assertTrue(all(thread.is_alive() for thread in outline_threads))
|
||||
# now wait until they all finish
|
||||
[thread.join() for thread in outline_threads]
|
||||
|
||||
Reference in New Issue
Block a user