|
8 | 8 | use MongoDB\Driver\ReadPreference; |
9 | 9 | use MongoDB\Driver\Query; |
10 | 10 | use MongoDB\Driver\Server; |
| 11 | +use MongoDB\Driver\Exception\CommandException; |
11 | 12 | use stdClass; |
12 | 13 | use UnexpectedValueException; |
13 | 14 |
|
@@ -49,6 +50,10 @@ protected function assertSameObjectId($expectedObjectId, $actualObjectId) |
49 | 50 |
|
50 | 51 | protected function getFeatureCompatibilityVersion(ReadPreference $readPreference = null) |
51 | 52 | { |
| 53 | + if ($this->isShardedCluster()) { |
| 54 | + return $this->getServerVersion($readPreference); |
| 55 | + } |
| 56 | + |
52 | 57 | if (version_compare($this->getServerVersion(), '3.4.0', '<')) { |
53 | 58 | return $this->getServerVersion($readPreference); |
54 | 59 | } |
@@ -115,6 +120,15 @@ protected function getServerStorageEngine(ReadPreference $readPreference = null) |
115 | 120 | throw new UnexpectedValueException('Could not determine server storage engine'); |
116 | 121 | } |
117 | 122 |
|
| 123 | + protected function isShardedCluster() |
| 124 | + { |
| 125 | + if ($this->getPrimaryServer()->getType() == Server::TYPE_MONGOS) { |
| 126 | + return true; |
| 127 | + } |
| 128 | + |
| 129 | + return false; |
| 130 | + } |
| 131 | + |
118 | 132 | protected function isShardedClusterUsingReplicasets() |
119 | 133 | { |
120 | 134 | $cursor = $this->getPrimaryServer()->executeQuery( |
@@ -195,7 +209,7 @@ protected function skipIfTransactionsAreNotSupported() |
195 | 209 | } |
196 | 210 |
|
197 | 211 | // TODO: MongoDB 4.2 should support sharded clusters (see: PHPLIB-374) |
198 | | - if ($this->getPrimaryServer()->getType() === Server::TYPE_MONGOS) { |
| 212 | + if ($this->isShardedCluster()) { |
199 | 213 | $this->markTestSkipped('Transactions are not supported on sharded clusters'); |
200 | 214 | } |
201 | 215 |
|
|
0 commit comments