Commit Graph

74 Commits

Author SHA1 Message Date
Shane Harvey
c7f5b1b1fe PYTHON-1725 Fix TestThreadsAuth.test_auto_auth_login
Create the database upfront to avoid test failures on sharded clusters.

(cherry picked from commit fd34c1da2a)
2019-03-12 16:29:27 -07:00
Bernie Hackett
507f954ed4 Update copyright dates 2017-12-01 17:23:39 -08:00
A. Jesse Jiryu Davis
520cf31409 PYTHON-1204 - More reliable test_client_disconnect 2017-04-03 14:51:29 -04:00
A. Jesse Jiryu Davis
93fd58aa10 PYTHON-2014 - Topology.close fixes
Ensure a monitor thread is restarted by Topology.open if it exited with
an exception, set Topology._opened = False in Topology.close, and extend
the timeout in test_client_disconnect.
2017-04-02 20:35:01 -04:00
Shane Harvey
f167252148 PYTHON-1204 Disable test_client_disconnect 2017-02-17 13:55:50 -08:00
Shane Harvey
5905a86785 PYTHON-1075 Support running the entire test suite with SSL/TLS
SSL connections are configurable via the environment variables
"CLIENT_PEM", "CA_PEM", and "CERT_REQS".
2016-09-28 16:34:14 -07:00
Bernie Hackett
aec685b374 Fix up copyright dates. 2015-03-25 11:55:02 -07:00
aherlihy
70c06d11a9 PYTHON-813 Removed client_knobs where no longer needed 2015-03-11 13:03:59 -07:00
aherlihy
fa1466179f PYTHON-813 Added support for serverSelectionTimeoutMS 2015-03-09 12:38:24 -07:00
Bernie Hackett
3f3b6bedfc PYTHON-846 - Database.connection -> Database.client 2015-02-25 11:57:39 -08:00
A. Jesse Jiryu Davis
7f42430978 PYTHON-847 Remove disconnect(), synonym of MongoClient.close().
close() seems more standard among MongoDB drivers.
2015-02-25 14:52:34 -05:00
Bernie Hackett
30af616009 PYTHON-821 - Migrate most tests to new the CRUD API. 2015-02-13 08:46:43 -08:00
A. Jesse Jiryu Davis
34560199ba Two test failures on Windows. 2015-01-20 12:44:04 -05:00
A. Jesse Jiryu Davis
e8be121a89 PYTHON-785 Don't use requests in tests. 2014-11-20 22:57:56 -05:00
A. Jesse Jiryu Davis
13cb74a760 Simplify auth tests, don't create additional root users.
Don't log out the global test client either; keep it logged in as root and
use it to create additional non-root users to test Database.add_user,
authenticate, logout, and so on.
2014-11-17 21:39:22 -05:00
Luke Lovett
3bc1d1db7d Re-authenticate after logging out from TestThreadsAuth. 2014-11-04 00:10:26 +00:00
A. Jesse Jiryu Davis
38848d47f3 MongoClient.close() stops monitors.
Subsequent operations restart them.
2014-11-03 14:40:06 -05:00
A. Jesse Jiryu Davis
772da8931e Redundant test code. 2014-10-30 19:35:26 -04:00
A. Jesse Jiryu Davis
3c9fd60fed PYTHON-525 Use MongoClient in replica set tests.
Connect the MongoClient to the replica set if one is running,
otherwise connect it to the standalone. Only continue to use
MongoReplicaSetClient when testing the specific behavior of
that deprecated class.

Also suppress some warnings when running tests, and better
determine whether to test IPv6.
2014-09-20 08:42:23 -04:00
A. Jesse Jiryu Davis
2f9d24ade6 PYTHON-525 Reimplement MongoClient to use Cluster.
Replace MongoClient with an implementation that relies on Cluster and Server. The new MongoClient takes over MongoReplicaSetClient's responsibilities.

Authentication, secondary-pinning, and Mongos high-availability are broken and will be reimplemented in a future commit. RS tests are temporarily disabled.
2014-08-28 16:57:57 -04:00
Luke Lovett
d7ec3a7704 PYTHON-715 Fix tests for MongoDB >= 2.7.1 when running with auth enabled. 2014-07-07 19:05:21 +00:00
Luke Lovett
4fa96c6c2e PYTHON-683 Separate unit tests and integration tests in the pymongo test suite.
Raise SkipTest in tests that require a connection to MongoDB when none is available.
2014-06-30 17:42:29 +00:00
Luke Lovett
141200083e PYTHON-680 Stop using nose in favor of pure unittest/unittest2 2014-04-25 22:57:33 +00:00
Luke Lovett
4d6d1e067b PYTHON-676 python 2/3 single-source for the test module 2014-04-23 18:37:02 +00:00
A. Jesse Jiryu Davis
de9062cf50 Reduce numbers of threads and trials in tests. 2014-02-12 15:59:13 -05:00
A. Jesse Jiryu Davis
2fa1750b07 Update copyright notices and company name. 2014-01-31 09:36:46 -05:00
A. Jesse Jiryu Davis
8f6a34326e Improve multithreaded connection and reconnection in MongoClient, PYTHON-487. 2013-12-04 21:09:15 -05:00
Bernie Hackett
0cb632784a Skip auth tests if auth not enabled PYTHON-556
This change does a few things:

1. In anticipation of the server defaulting to a "disabled" mode for
auth, only run authentication related tests if auth is enabled.
2. Attempt to clean up users in a finally block, even if tests failed.
3. Look for auth settings in "parsed" from getCmdLineOpts in case the
cluster was started with config files.
4. Remove useless remove_all_users calls at the beginning of tests - if
users were added in a previous test and we forgot to clean them up
these are going to fail no matter what when auth is enabled.
2013-11-05 09:10:00 -08:00
A. Jesse Jiryu Davis
c1f6fece26 Test refactoring: get_pool() and pools_from_rs_client(). 2013-10-08 10:40:16 -04:00
hawka
a02e37ba5e PYTHON-552: Manipulate user objects exclusively via commands for 2.6 2013-09-24 17:30:33 -07:00
A. Jesse Jiryu Davis
6c2e009f45 Fix MongoReplicaSetClient race conditions PYTHON-467
* RSState, Member, and MovingAverage are now immutable
* In refresh(), try up members before down ones
* A test_ha fixup (clear process-list after killing them in each test, so we don't re-kill previous tests' processes)
2013-05-01 14:14:20 -04:00
A. Jesse Jiryu Davis
c758efcb34 Rename test_connection -> test_client, test_replica_set_connection -> test_replica_set_client PYTHON-451 2013-02-11 21:33:55 -05:00
A. Jesse Jiryu Davis
d35bec12e5 Tests use MongoClient instead of Connection PYTHON-451 2013-02-11 20:57:17 -05:00
behackett
118ab45001 Tests should clean up after themselves. 2013-01-23 13:10:54 -08:00
A. Jesse Jiryu Davis
024ed62313 Factor out thread-rendezvous logic from test_threads.py, and use it in test_thread_util.py 2012-12-31 13:06:17 -05:00
behackett
afe49a4002 MongoClient/MongoReplicaSetClient PYTHON-423
This change adds two new top level classes, MongoClient
and MongoReplicaSetClient. They work almost exactly the
same as Connection and ReplicaSetConnection with a few
differences:

1. These connection objects awknowledge write operations by default.
2. The network_timeout parameter is gone, use socketTimeoutMS instead.
3. auto_start_request defaults to False.

Default acknowledged write operation will be the biggest change for
most users. Using MongoClient and MongoReplicaSetClient you no longer
have to pass safe=True to a write method (save, update, insert, remove)
to request an acknowledgement from the server.

Connection and ReplicaSetConnection are now deprecated but retain their
previous behavior. This should not be a backward breaking change.
2012-11-16 13:39:18 -08:00
Ross Lawley
8637cfbe27 Adding first user from localhost works but raises OperationFailure - PYTHON-407 2012-10-05 15:04:56 +00:00
A. Jesse Jiryu Davis
f275b2291a Implement read preferences for distributing reads among replica set members PYTHON-367
Replace the 'mongo' dict with a Member object everywhere in ReplicaSetConnection.
A handful of commands obey read preferences; most are always sent to primary.
Track a 5-sample moving average of each replica set member's ping time.
Connection detects whether it's connected to primary, secondary, or mongos.
2012-07-25 00:05:06 -04:00
behackett
a33b0fce4d Fix safe with auth for MongoDB >= 2.1.x PYTHON-371
The getLastError command requires authentication in
MongoDB 2.2. See the associated ticket for more
information.
2012-07-12 10:49:13 -07:00
behackett
65bece6396 Get rid of a few weird timeout tests.
These never made much sense to me. They seem to
cause issues in CI and don't seem to be correct
either way.
2012-07-03 13:52:16 -07:00
behackett
1fe6029c5d Fix replica set monitor issues PYTHON-365.
Note: In CPython the monitor is no longer a daemon thread. This means that
care must be taken in the interactive shell and simple scripts to set
ReplicaSetConnection references to None so the monitor dies.

The monitor is still a daemon thread in Jython and PyPy.
2012-07-03 12:56:01 -07:00
A. Jesse Jiryu Davis
f2cd5c6f2b Slightly refactor threading tests 2012-04-29 21:34:05 -04:00
A. Jesse Jiryu Davis
326b710382 More reliable multithread tests on slow machines 2012-04-23 15:23:20 -04:00
A. Jesse Jiryu Davis
839d3af512 Daemonize threads used in tests so failed test won't hang process 2012-04-21 07:13:06 -06:00
behackett
0ee7170cc2 It's 2012... 2012-04-19 12:40:38 -07:00
A. Jesse Jiryu Davis
c4dd702143 Fix up tests for Python pre-2.7 PYTHON-345 2012-04-17 22:05:05 -04:00
A. Jesse Jiryu Davis
1def725f4a PYTHON-345 don't reuse request sockets after the pool is reset 2012-04-16 16:53:38 -04:00
behackett
12592be1fe Python 3 unittest changes PYTHON-84. 2012-03-28 11:53:47 -07:00
A. Jesse Jiryu Davis
62e0c23d67 Don't drop databases unnecessarily during tests, saves about 35% of unittest time PYTHON-320 2012-03-19 12:16:33 -04:00
A. Jesse Jiryu Davis
34538c155e Make auto_start_request optional (default True), add ReplicaSetConnection.start_request, return sockets to pool when threads die PYTHON-287
Big change to PyMongo connection pooling:

* While we still allocate a socket per thread by default, this is now optional. It is also possible to share sockets among threads, safely, and thus using fewer total sockets, by creating a Connection or ReplicaSetConnection with auto_start_request=False.

* In the past, when a thread died without calling end_request() its socket was closed. We now reclaim such sockets for the pool, which should reduce connection churn.

* start_request() now returns a context manager so you can do "with connection.start_request():"

* ReplicaSetConnection now supports start_request, although its semantics aren't consistent for ReadPreferences other than PRIMARY

* Refactoring: Connection and ReplicaSetConnection had different pool implementations, now they share one.
2012-03-14 17:12:11 -04:00