Commit f4b5a6f4 authored by Jeremy Mikola's avatar Jeremy Mikola

Merge pull request #563

parents 9813df19 602c12cf
...@@ -1230,12 +1230,7 @@ class DocumentationExamplesTest extends FunctionalTestCase ...@@ -1230,12 +1230,7 @@ class DocumentationExamplesTest extends FunctionalTestCase
public function testTransactions_intro_example_1() public function testTransactions_intro_example_1()
{ {
if ($this->getPrimaryServer()->getType() === Server::TYPE_STANDALONE) { $this->skipIfTransactionsAreNotSupported();
$this->markTestSkipped('Transactions are not supported on standalone servers');
}
if (version_compare($this->getFeatureCompatibilityVersion(), '4.0', '<')) {
$this->markTestSkipped('Transactions are only supported on FCV 4.0 or higher');
}
$client = new Client($this->getUri()); $client = new Client($this->getUri());
...@@ -1395,12 +1390,7 @@ class DocumentationExamplesTest extends FunctionalTestCase ...@@ -1395,12 +1390,7 @@ class DocumentationExamplesTest extends FunctionalTestCase
public function testTransactions_retry_example_3() public function testTransactions_retry_example_3()
{ {
if ($this->getPrimaryServer()->getType() === Server::TYPE_STANDALONE) { $this->skipIfTransactionsAreNotSupported();
$this->markTestSkipped('Transactions are not supported on standalone servers');
}
if (version_compare($this->getFeatureCompatibilityVersion(), '4.0', '<')) {
$this->markTestSkipped('Transactions are only supported on FCV 4.0 or higher');
}
$client = new Client($this->getUri()); $client = new Client($this->getUri());
......
...@@ -6,6 +6,7 @@ use MongoDB\Driver\Command; ...@@ -6,6 +6,7 @@ use MongoDB\Driver\Command;
use MongoDB\Driver\Cursor; use MongoDB\Driver\Cursor;
use MongoDB\Driver\Manager; use MongoDB\Driver\Manager;
use MongoDB\Driver\ReadPreference; use MongoDB\Driver\ReadPreference;
use MongoDB\Driver\Server;
use stdClass; use stdClass;
use UnexpectedValueException; use UnexpectedValueException;
...@@ -95,4 +96,41 @@ abstract class FunctionalTestCase extends TestCase ...@@ -95,4 +96,41 @@ abstract class FunctionalTestCase extends TestCase
throw new UnexpectedValueException('Could not determine server version'); throw new UnexpectedValueException('Could not determine server version');
} }
protected function getServerStorageEngine(ReadPreference $readPreference = null)
{
$cursor = $this->manager->executeCommand(
$this->getDatabaseName(),
new Command(['serverStatus' => 1]),
$readPreference ?: new ReadPreference('primary')
);
$result = current($cursor->toArray());
if (isset($result->storageEngine->name) && is_string($result->storageEngine->name)) {
return $result->storageEngine->name;
}
throw new UnexpectedValueException('Could not determine server storage engine');
}
protected function skipIfTransactionsAreNotSupported()
{
if ($this->getPrimaryServer()->getType() === Server::TYPE_STANDALONE) {
$this->markTestSkipped('Transactions are not supported on standalone servers');
}
// TODO: MongoDB 4.2 should support sharded clusters (see: PHPLIB-374)
if ($this->getPrimaryServer()->getType() === Server::TYPE_MONGOS) {
$this->markTestSkipped('Transactions are not supported on sharded clusters');
}
if (version_compare($this->getFeatureCompatibilityVersion(), '4.0', '<')) {
$this->markTestSkipped('Transactions are only supported on FCV 4.0 or higher');
}
if ($this->getServerStorageEngine() !== 'wiredTiger') {
$this->markTestSkipped('Transactions require WiredTiger storage engine');
}
}
} }
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