Skip to content

Instantly share code, notes, and snippets.

@dmitchell
Last active August 29, 2015 14:06
Show Gist options
  • Save dmitchell/9e61c2141069f3072e76 to your computer and use it in GitHub Desktop.
Save dmitchell/9e61c2141069f3072e76 to your computer and use it in GitHub Desktop.
thread test
@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]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment