pulp/pulp — pull request #1363 by bmbouter (2014-11-24 21:54:59+00:00)
Title: Ports DB connection to mongoengine and adds lots of tests

This PR replaces PyMongo connection with mongoengine which still uses PyMongo underneath. It also improves the test coverage significantly of the module significantly and fixes some internationalization problems.

I removed the send_message() and send_message_with_response() wrappers which were related to an older bug, [BZ 976561](https://bugzilla.redhat.com/show_bug.cgi?id=976561). I tested with mongoengine==0.7.10 and pymongo==2.6.3

I think this may be an issue that was fixed in pymongo. The oldest version Pulp would use is pymongo==2.5.2 on EL6. When I [look into the PyMongo code](https://github.com/mongodb/mongo-python-driver/blob/v2.5/pymongo/mongo_client.py#L922) it seems to do a good job of releasing these sockets at the right times.

I also hand tested it by doing the following:

1. Adjust Pulp to use only 1 WSGI process, restart httpd, and verify with `ps` that exactly 1 WSGI process is running for Pulp. My WSGI PID is 21638
2. I then create 5000 rpms and upload them as described by [this comment](https://bugzilla.redhat.com/show_bug.cgi?id=976561#c10).
3. I also monitored the uploads using `sudo lsof -p 21638 | wc -l`

I was able to upload all the RPMs without error, and I monitored the lsof output which was at 251 prior to the upload starting and stayed between 258 - 260 at all times during the upload. I also propose that I move [BZ 976561](https://bugzilla.redhat.com/show_bug.cgi?id=976561) to ON_QA for 2.6 so that QE can verify I haven't introduced a regression. I'd like feedback on that idea specifically.

I did not refactor PulpCollection or provide coverage for the helper methods it uses. Those things will be rewritten at a later time so writing tests for them now is not valuable.