Unverified Commit 90748471 authored by Andreas Braun's avatar Andreas Braun

Merge pull request #663

parents 703401d0 870024ed
...@@ -138,6 +138,14 @@ abstract class FunctionalTestCase extends TestCase ...@@ -138,6 +138,14 @@ abstract class FunctionalTestCase extends TestCase
*/ */
protected function configureFailPoint($command) protected function configureFailPoint($command)
{ {
if (! $this->isFailCommandSupported()) {
$this->markTestSkipped('failCommand is only supported on mongod >= 4.0.0 and mongos >= 4.1.5.');
}
if (! $this->isFailCommandEnabled()) {
$this->markTestSkipped('The enableTestCommands parameter is not enabled.');
}
if (is_array($command)) { if (is_array($command)) {
$command = (object) $command; $command = (object) $command;
} }
...@@ -394,4 +402,37 @@ abstract class FunctionalTestCase extends TestCase ...@@ -394,4 +402,37 @@ abstract class FunctionalTestCase extends TestCase
$operation->execute($server); $operation->execute($server);
} }
} }
/**
* Checks if the failCommand command is supported on this server version
*
* @return bool
*/
private function isFailCommandSupported()
{
$minVersion = $this->isShardedCluster() ? '4.1.5' : '4.0.0';
return version_compare($this->getServerVersion(), $minVersion, '>=');
}
/**
* Checks if the failCommand command is enabled by checking the enableTestCommands parameter
*
* @return bool
*/
private function isFailCommandEnabled()
{
try {
$cursor = $this->manager->executeCommand(
'admin',
new Command(['getParameter' => 1, 'enableTestCommands' => 1])
);
$document = current($cursor->toArray());
} catch (CommandException $e) {
return false;
}
return isset($document->enableTestCommands) && $document->enableTestCommands === true;
}
} }
...@@ -689,10 +689,6 @@ class WatchFunctionalTest extends FunctionalTestCase ...@@ -689,10 +689,6 @@ class WatchFunctionalTest extends FunctionalTestCase
*/ */
public function testNonResumableErrorCodes($errorCode) public function testNonResumableErrorCodes($errorCode)
{ {
if (version_compare($this->getServerVersion(), '4.0.0', '<')) {
$this->markTestSkipped('failCommand is not supported');
}
$this->configureFailPoint([ $this->configureFailPoint([
'configureFailPoint' => 'failCommand', 'configureFailPoint' => 'failCommand',
'mode' => ['times' => 1], 'mode' => ['times' => 1],
......
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