Couchbase missing document often during development and automated testing

So we’re using couchbase for a while now and we’ve had so many problems with respect to the sleep and response time and also documents missing in response. These things happen mainly in the automated tests. The problem is, it returns False (missing the document) when the document actually exists in the bucket. And this problem occurs from time to time (not every time), more like when we run the test suite this occurs and fails our test we run again and everything passes since the document exists. This is making it hard for us to push our application to production. If anyone can throw some light on what needs to be done, it’ll be really helpful.

We’re using Couchbase 5 and running it with 2 core and 4GB of RAM. (And this occurs for just 50 documents taking only 30 MB disk space). We have other projects on separate buckets though.

Could you give some more details on how you’re application/test works - maybe some example code?

Surely. This is a test case for user login. I’m using django tests and this test case is prepended by a setUp() method which inserts a user document with all required credentials and is followed by a tearDown() which deletes the document after the test case.
def test_UserLogin_email_and_password_valid_success(self): data = {'email':self.valid_email, 'password': self.password, 'device_token': self.valid_device_token} response =, data, format='json') self.assertTrue('refresh_token' and 'access_token' in response.__dict__['_headers']) self.assertTrue(status.is_success(response.status_code)) print ("\n***S - Authenticate with right email and password ***\nCase: Success")
While this case passes most of the times, it tends to fail randomly saying there’s no document in the DB. I’ve also noticed this in development mode as my API return ‘Document doesnt exist’ while the subsequent request will be a success. Do let me know if any more info is needed.