Commit 8abb006e authored by Derick Rethans's avatar Derick Rethans

Use server version as FCV when connected to mongos

parent a949df52
...@@ -8,6 +8,7 @@ use MongoDB\Driver\Manager; ...@@ -8,6 +8,7 @@ use MongoDB\Driver\Manager;
use MongoDB\Driver\ReadPreference; use MongoDB\Driver\ReadPreference;
use MongoDB\Driver\Query; use MongoDB\Driver\Query;
use MongoDB\Driver\Server; use MongoDB\Driver\Server;
use MongoDB\Driver\Exception\CommandException;
use stdClass; use stdClass;
use UnexpectedValueException; use UnexpectedValueException;
...@@ -49,6 +50,10 @@ abstract class FunctionalTestCase extends TestCase ...@@ -49,6 +50,10 @@ abstract class FunctionalTestCase extends TestCase
protected function getFeatureCompatibilityVersion(ReadPreference $readPreference = null) protected function getFeatureCompatibilityVersion(ReadPreference $readPreference = null)
{ {
if ($this->isShardedCluster()) {
return $this->getServerVersion($readPreference);
}
if (version_compare($this->getServerVersion(), '3.4.0', '<')) { if (version_compare($this->getServerVersion(), '3.4.0', '<')) {
return $this->getServerVersion($readPreference); return $this->getServerVersion($readPreference);
} }
...@@ -115,6 +120,15 @@ abstract class FunctionalTestCase extends TestCase ...@@ -115,6 +120,15 @@ abstract class FunctionalTestCase extends TestCase
throw new UnexpectedValueException('Could not determine server storage engine'); throw new UnexpectedValueException('Could not determine server storage engine');
} }
protected function isShardedCluster()
{
if ($this->getPrimaryServer()->getType() == Server::TYPE_MONGOS) {
return true;
}
return false;
}
protected function isShardedClusterUsingReplicasets() protected function isShardedClusterUsingReplicasets()
{ {
$cursor = $this->getPrimaryServer()->executeQuery( $cursor = $this->getPrimaryServer()->executeQuery(
...@@ -195,7 +209,7 @@ abstract class FunctionalTestCase extends TestCase ...@@ -195,7 +209,7 @@ abstract class FunctionalTestCase extends TestCase
} }
// TODO: MongoDB 4.2 should support sharded clusters (see: PHPLIB-374) // TODO: MongoDB 4.2 should support sharded clusters (see: PHPLIB-374)
if ($this->getPrimaryServer()->getType() === Server::TYPE_MONGOS) { if ($this->isShardedCluster()) {
$this->markTestSkipped('Transactions are not supported on sharded clusters'); $this->markTestSkipped('Transactions are not supported on sharded clusters');
} }
......
...@@ -21,7 +21,7 @@ class ModifyCollectionFunctionalTest extends FunctionalTestCase ...@@ -21,7 +21,7 @@ class ModifyCollectionFunctionalTest extends FunctionalTestCase
$this->getDatabaseName(), $this->getDatabaseName(),
$this->getCollectionName(), $this->getCollectionName(),
['index' => ['keyPattern' => ['lastAccess' => 1], 'expireAfterSeconds' => 1000]], ['index' => ['keyPattern' => ['lastAccess' => 1], 'expireAfterSeconds' => 1000]],
['typeMap' => ['root' => 'array']] ['typeMap' => ['root' => 'array', 'document' => 'array']]
); );
$result = $modifyCollection->execute($this->getPrimaryServer()); $result = $modifyCollection->execute($this->getPrimaryServer());
...@@ -30,8 +30,6 @@ class ModifyCollectionFunctionalTest extends FunctionalTestCase ...@@ -30,8 +30,6 @@ class ModifyCollectionFunctionalTest extends FunctionalTestCase
* non-primary shards that don't have chunks for the collection, the result contains a * non-primary shards that don't have chunks for the collection, the result contains a
* "ns does not exist" error. */ * "ns does not exist" error. */
foreach ($result['raw'] as $shard) { foreach ($result['raw'] as $shard) {
$shard = (array) $shard;
if (array_key_exists('ok', $shard) && $shard['ok'] == 1) { if (array_key_exists('ok', $shard) && $shard['ok'] == 1) {
$this->assertSame(3, $shard['expireAfterSeconds_old']); $this->assertSame(3, $shard['expireAfterSeconds_old']);
$this->assertSame(1000, $shard['expireAfterSeconds_new']); $this->assertSame(1000, $shard['expireAfterSeconds_new']);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment