Skip to content

Commit 9687f9a

Browse files
author
Martynas Sudintas
committed
ElasticsearchTestCase catches only es related exceptions and resetups test
1 parent faa7a6c commit 9687f9a

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

Test/ElasticsearchTestCase.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace ONGR\ElasticsearchBundle\Test;
1313

14+
use Elasticsearch\Common\Exceptions\ElasticsearchException;
1415
use ONGR\ElasticsearchBundle\Client\Connection;
1516
use ONGR\ElasticsearchBundle\ORM\Manager;
1617
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
@@ -43,12 +44,15 @@ public function runTest()
4344
foreach (range(1, $this->getNumberOfRetries()) as $try) {
4445
try {
4546
return parent::runTest();
46-
} catch (\PHPUnit_Framework_SkippedTestError $e) {
47-
throw $e;
48-
} catch (\PHPUnit_Framework_IncompleteTestError $e) {
49-
throw $e;
5047
} catch (\Exception $e) {
51-
// Try more.
48+
if (!($e instanceof ElasticsearchException)) {
49+
throw $e;
50+
}
51+
// If error was from elasticsearch re-setup tests and retry.
52+
if ($try !== $this->getNumberOfRetries()) {
53+
$this->tearDown();
54+
$this->setUp();
55+
}
5256
}
5357
}
5458

0 commit comments

Comments
 (0)