Skip to content

Commit 8abb006

Browse files
committed
Use server version as FCV when connected to mongos
1 parent a949df5 commit 8abb006

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

tests/FunctionalTestCase.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use MongoDB\Driver\ReadPreference;
99
use MongoDB\Driver\Query;
1010
use MongoDB\Driver\Server;
11+
use MongoDB\Driver\Exception\CommandException;
1112
use stdClass;
1213
use UnexpectedValueException;
1314

@@ -49,6 +50,10 @@ protected function assertSameObjectId($expectedObjectId, $actualObjectId)
4950

5051
protected function getFeatureCompatibilityVersion(ReadPreference $readPreference = null)
5152
{
53+
if ($this->isShardedCluster()) {
54+
return $this->getServerVersion($readPreference);
55+
}
56+
5257
if (version_compare($this->getServerVersion(), '3.4.0', '<')) {
5358
return $this->getServerVersion($readPreference);
5459
}
@@ -115,6 +120,15 @@ protected function getServerStorageEngine(ReadPreference $readPreference = null)
115120
throw new UnexpectedValueException('Could not determine server storage engine');
116121
}
117122

123+
protected function isShardedCluster()
124+
{
125+
if ($this->getPrimaryServer()->getType() == Server::TYPE_MONGOS) {
126+
return true;
127+
}
128+
129+
return false;
130+
}
131+
118132
protected function isShardedClusterUsingReplicasets()
119133
{
120134
$cursor = $this->getPrimaryServer()->executeQuery(
@@ -195,7 +209,7 @@ protected function skipIfTransactionsAreNotSupported()
195209
}
196210

197211
// TODO: MongoDB 4.2 should support sharded clusters (see: PHPLIB-374)
198-
if ($this->getPrimaryServer()->getType() === Server::TYPE_MONGOS) {
212+
if ($this->isShardedCluster()) {
199213
$this->markTestSkipped('Transactions are not supported on sharded clusters');
200214
}
201215

tests/Operation/ModifyCollectionFunctionalTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function testCollMod()
2121
$this->getDatabaseName(),
2222
$this->getCollectionName(),
2323
['index' => ['keyPattern' => ['lastAccess' => 1], 'expireAfterSeconds' => 1000]],
24-
['typeMap' => ['root' => 'array']]
24+
['typeMap' => ['root' => 'array', 'document' => 'array']]
2525
);
2626
$result = $modifyCollection->execute($this->getPrimaryServer());
2727

@@ -30,8 +30,6 @@ public function testCollMod()
3030
* non-primary shards that don't have chunks for the collection, the result contains a
3131
* "ns does not exist" error. */
3232
foreach ($result['raw'] as $shard) {
33-
$shard = (array) $shard;
34-
3533
if (array_key_exists('ok', $shard) && $shard['ok'] == 1) {
3634
$this->assertSame(3, $shard['expireAfterSeconds_old']);
3735
$this->assertSame(1000, $shard['expireAfterSeconds_new']);

0 commit comments

Comments
 (0)