Hey guys,
So, I use mongo atlas search.
I have pytest cases all over the place to make sure that things are working as expected.
Here is a sample endpoint test case
def test_list_obj(self, test_profile) -> None:
response = self.endpoint.get()
assert response.status_code == 200
assert len(response.json()) == 3
for received in response.json():
assert_list_obj_fields(
received,
ObjModel.objects.get(id=received["id"]),
)
Here is the sample atlas search query we do in the api:
search_query = {
"compound": {
"must": [
{"text": {"query": OPEN_OBJ_CONSTANT, "path": PATH0}},
]
},
}
if search_title is not None:
search_query["compound"]["should"] = [
{
"autocomplete": {
"query": search_title,
"path": PATH1,
"fuzzy": {"maxEdits": 1}
}
},
{
"autocomplete": {
"query": search_title,
"path": PATH2,
"fuzzy": {"maxEdits": 1}
}
},
]
search_query["compound"]["minimumShouldMatch"] = 1
obj_search = obj_search.aggregate(
[
{"$search": search_query},
{"$skip": start},
{"$limit": size},
{
"$project": {
"_id": 0,
}
},
],
)
I refactored the code and removed sensitive data, meaning I may have made punctuation errors in doing so.
Either way, when I run tests locally, everything and I mean every 120 endpoint test cases related to atlas search work well.
However, when these tests are run from bitbucket pipelines, things are uncertain.
- There will be few weeks straight when every test case will pass well from bitbucket pipelines
- Then there will be the other few weeks when there will always be something to fail. Sometimes test A will fail, other times test B or C or D. But something will surely fail.
Meanwhile, those tests are all passing from every developers local environment. - Then again few weeks all will work well
- Then again something failing for few weeks in straight
Bitbucket IPs are added to Mongo’s network connection access point.
Bitbucket devs have gotten back to me showing that there has been no network drops between test cases or during test cases that might have caused the issue.
This issue is becoming very annoying. Recently I saw that usually things begin to behave differently after there is a new mongo update.
Has anyone ever faced this issue?
What is the resolution? How can I achieve consistency here?