File tree Expand file tree Collapse file tree 2 files changed +38
-3
lines changed
tests/Elasticsearch/Tests/ConnectionPool Expand file tree Collapse file tree 2 files changed +38
-3
lines changed Original file line number Diff line number Diff line change @@ -114,9 +114,11 @@ function ($response) {
114
114
},
115
115
//onFailure
116
116
function ($ response ) {
117
- //some kind of real faiure here, like a timeout
118
- $ this ->connectionPool ->scheduleCheck ();
119
- // log stuff
117
+ // Ignore 400 level errors, as that means the server responded just fine
118
+ if (!(isset ($ response ['code ' ]) && $ response ['code ' ] >=400 && $ response ['code ' ] < 500 )) {
119
+ // Otherwise schedule a check
120
+ $ this ->connectionPool ->scheduleCheck ();
121
+ }
120
122
});
121
123
122
124
return $ future ;
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ /**
4
+ * Class StaticConnectionPoolIntegrationTest
5
+ *
6
+ * @category Tests
7
+ * @package Elasticsearch
8
+ * @subpackage Tests/StaticConnectionPoolTest
9
+ * @author Zachary Tong <[email protected] >
10
+ * @license http://www.apache.org/licenses/LICENSE-2.0 Apache2
11
+ * @link http://elasticsearch.org
12
+ */
13
+ class StaticConnectionPoolIntegrationTest extends \PHPUnit_Framework_TestCase
14
+ {
15
+ // Issue #636
16
+ public function test404Liveness () {
17
+ $ client = \Elasticsearch \ClientBuilder::create ()
18
+ ->setHosts ([$ _SERVER ['ES_TEST_HOST ' ]])
19
+ ->setConnectionPool (\Elasticsearch \ConnectionPool \StaticConnectionPool::class)
20
+ ->build ();
21
+
22
+ $ connection = $ client ->transport ->getConnection ();
23
+
24
+ // Ensure connection is dead
25
+ $ connection ->markDead ();
26
+
27
+ // The index doesn't exist, but the server is up so this will return a 404
28
+ $ this ->assertFalse ($ client ->indices ()->exists (['index ' => 'not_existing_index ' ]));
29
+
30
+ // But the node should be marked as alive since the server responded
31
+ $ this ->assertTrue ($ connection ->isAlive ());
32
+ }
33
+ }
You can’t perform that action at this time.
0 commit comments