Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
d2b0d0cd
Commit
d2b0d0cd
authored
Dec 19, 2017
by
Robert Raposa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix test_course_listing_performance flaky test.
Fix test by removing timers and leaving other assertions.
parent
a4fa04ec
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
18 deletions
+8
-18
cms/djangoapps/contentstore/tests/test_course_listing.py
+8
-18
No files found.
cms/djangoapps/contentstore/tests/test_course_listing.py
View file @
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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment