-
Notifications
You must be signed in to change notification settings - Fork 970
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not schedule connection pool checks on 4xx level errors
Closes #636
- Loading branch information
1 parent
71ccfc1
commit fd75e99
Showing
2 changed files
with
40 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
tests/Elasticsearch/Tests/ConnectionPool/StaticConnectionPoolIntegrationTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
/** | ||
* Class StaticConnectionPoolIntegrationTest | ||
* | ||
* @category Tests | ||
* @package Elasticsearch | ||
* @subpackage Tests/StaticConnectionPoolTest | ||
* @author Zachary Tong <zachary.tong@elasticsearch.com> | ||
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache2 | ||
* @link http://elasticsearch.org | ||
*/ | ||
class StaticConnectionPoolIntegrationTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
// Issue #636 | ||
public function test404Liveness() { | ||
$client = \Elasticsearch\ClientBuilder::create() | ||
->setHosts([$_SERVER['ES_TEST_HOST']]) | ||
->setConnectionPool(\Elasticsearch\ConnectionPool\StaticConnectionPool::class) | ||
->build(); | ||
|
||
$connection = $client->transport->getConnection(); | ||
|
||
// Ensure connection is dead | ||
$connection->markDead(); | ||
|
||
// The index doesn't exist, but the server is up so this will return a 404 | ||
$this->assertFalse($client->indices()->exists(['index' => 'not_existing_index'])); | ||
|
||
// But the node should be marked as alive since the server responded | ||
$this->assertTrue($connection->isAlive()); | ||
} | ||
} |