Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions Test/ElasticsearchTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace ONGR\ElasticsearchBundle\Test;

use Elasticsearch\Common\Exceptions\ElasticsearchException;
use ONGR\ElasticsearchBundle\Client\Connection;
use ONGR\ElasticsearchBundle\ORM\Manager;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
Expand Down Expand Up @@ -43,12 +44,15 @@ public function runTest()
foreach (range(1, $this->getNumberOfRetries()) as $try) {
try {
return parent::runTest();
} catch (\PHPUnit_Framework_SkippedTestError $e) {
throw $e;
} catch (\PHPUnit_Framework_IncompleteTestError $e) {
throw $e;
} catch (\Exception $e) {
// Try more.
if (!($e instanceof ElasticsearchException)) {
throw $e;
}
// If error was from elasticsearch re-setup tests and retry.
if ($try !== $this->getNumberOfRetries()) {
$this->tearDown();
$this->setUp();
}
}
}

Expand Down