Unverified Commit a0bf63a1 by Robert Raposa Committed by GitHub

Merge pull request #16967 from edx/robrap/remove-flaky-timing-assertions

PLAT-1864: Fix test_course_listing_performance flaky test.
parents 82ad9295 d2b0d0cd
...@@ -264,32 +264,22 @@ class TestCourseListing(ModuleStoreTestCase): ...@@ -264,32 +264,22 @@ class TestCourseListing(ModuleStoreTestCase):
else: else:
self._create_course_with_access_groups(course_location, store=store) self._create_course_with_access_groups(course_location, store=store)
# time the get courses by iterating through all courses # get courses by iterating through all courses
with Timer() as iteration_over_courses_time_1: courses_iter, __ = _accessible_courses_iter_for_tests(self.request)
courses_iter, __ = _accessible_courses_iter_for_tests(self.request)
self.assertEqual(len(list(courses_iter)), USER_COURSES_COUNT) self.assertEqual(len(list(courses_iter)), USER_COURSES_COUNT)
# time again the get courses by iterating through all courses # again get courses by iterating through all courses
with Timer() as iteration_over_courses_time_2: courses_iter, __ = _accessible_courses_iter_for_tests(self.request)
courses_iter, __ = _accessible_courses_iter_for_tests(self.request)
self.assertEqual(len(list(courses_iter)), USER_COURSES_COUNT) self.assertEqual(len(list(courses_iter)), USER_COURSES_COUNT)
# time the get courses by reversing django groups # get courses by reversing django groups
with Timer() as iteration_over_groups_time_1: courses_list, __ = _accessible_courses_list_from_groups(self.request)
courses_list, __ = _accessible_courses_list_from_groups(self.request)
self.assertEqual(len(courses_list), USER_COURSES_COUNT) self.assertEqual(len(courses_list), USER_COURSES_COUNT)
# time again the get courses by reversing django groups # again get courses by reversing django groups
with Timer() as iteration_over_groups_time_2: courses_list, __ = _accessible_courses_list_from_groups(self.request)
courses_list, __ = _accessible_courses_list_from_groups(self.request)
self.assertEqual(len(courses_list), USER_COURSES_COUNT) self.assertEqual(len(courses_list), USER_COURSES_COUNT)
# Test that the time taken by getting courses through reversing django
# groups is lower then the time taken by traversing through all courses
# (if accessible courses are relatively small).
self.assertGreaterEqual(iteration_over_courses_time_1.elapsed, iteration_over_groups_time_1.elapsed)
self.assertGreaterEqual(iteration_over_courses_time_2.elapsed, iteration_over_groups_time_2.elapsed)
# Now count the db queries # Now count the db queries
with check_mongo_calls(courses_list_from_group_calls): with check_mongo_calls(courses_list_from_group_calls):
_accessible_courses_list_from_groups(self.request) _accessible_courses_list_from_groups(self.request)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment