-
Type: Task
-
Resolution: Fixed
-
Priority: Minor - P4
-
Affects Version/s: 1.5.0
-
Component/s: None
-
None
While updating the test suite for compatibility with server version 4.0.0-rc5, I noticed that some tests were failing because I was using the default MONGODB_URI environment variable, which was connecting to "mongodb://127.0.0.1/". That mongod was actually a replica set primary and because the the is_replica_set() function only checks the topology type of the node, it returned true; however, the absence of both replicaSet and multiple nodes in the connection string meant that libmongoc was operating in single-server mode and it did not evaluate any read preferences. This lead to failures in the following two tests:
- tests/manager/manager-executeCommand-002.phpt
- tests/manager/manager-executeCommand-003.phpt
It may be convenient if is_replica_set() was improved to check for either multiple servers or the presence of a replicaSet URI option (by calling get_uri_option()).
Note: in this case, Manager::getServers() returns an array with a single server. Although the server identifies as a replica set primary (TYPE_RS_PRIMARY) and the secondary is shown in its isMaster output, the topology does not contain any other nodes.