FC-0057: implement search test cases#76
Conversation
fd7d919 to
ad1c302
Compare
|
@regisb To reproduce this error, first start the Elasticsearch container. Here, you can see that the port is different from the one we are using in the edx. To enable the use of elastic search instead of fixtures, update the value of FORUM_ENABLE_ELASTIC_SEARCH to True in the tests/conftest.py:33. We are focused on fixing the issue mentioned in the forum/search/search_manager.py at line 80, and the relevant test case is To reproduce the error, comment out the temporary fix in the search_manager.py. After doing so, the first test case will fail because Elasticsearch won't be able to find "pineapples" in the comments index. Use this command to run test cases for search only: |
|
I believe that the issue stems from the construction of the indices in v2. The only difference between v1 and v2 I managed to find was the content of the indices. To identify the difference, I queried the content of the comments and comment_thread indices. In v1: In v2: The index contents are very different. In particular, I think that the field mappings should be identical between comment_threads and comments. This is something that you could investigate (I think). |
|
I implement it this way. There is a bug in the cs_comment service, which I have fixed in the V2 version. They store the exact MongoDB data to the index, but the mapping they created does not match the object. Also, in the search function, they are not utilizing any of the additional fields. We can still try this, but I don't think it will have a significant impact. However, I will give it a try. https://github.com/openedx/cs_comments_service/blob/master/models/comment_thread.rb#L47 |
f781640 to
ab1f5f9
Compare
4ef3330 to
3c491d3
Compare
ce2d269 to
8ace927
Compare
- Implemented test cases similar to those in the cs_comments_service/spec/api/search_spec.rb. - Added MongoDB indexes. - Fixed issues in the search API view. - By default, the test cases use fixtures to get dummy data. To test with the actual Elasticsearch, follow the guidelines mentioned in test_search.py. - Added relevant constants i.e. FORUM_DEFAULT_PAGE and FORUM_DEFAULT_PER_PAGE. close #53
3219f32 to
20d28d6
Compare
| ).limit(per_page) | ||
| threads = list(paginated_collection) | ||
| num_pages = max(1, (thread_count // per_page)) | ||
| num_pages = max(1, math.ceil(thread_count / per_page)) |
There was a problem hiding this comment.
nit: The max(...) part is no longer necessary here. It used to be, because the // division could result in a zero result, but this is no longer the case here with ceil.
|
Good job figuring out this one :) Some parts of this PR were hardcore 🤘. |
The PR includes the test cases for the search API along with some fixes in additional files.
close #53