1use Test::More; 2use Test::Exception; 3use Search::Elasticsearch; 4use lib 't/lib'; 5use MockCxn qw(mock_noping_client); 6 7## Nodes fail and recover 8 9my $t = mock_noping_client( 10 { nodes => [ 'one', 'two', 'three' ] }, 11 12 { node => 1, code => 200, content => 1 }, 13 { node => 2, code => 509, error => 'Timeout' }, 14 { node => 3, code => 200, content => 1 }, 15 { node => 1, code => 200, content => 1 }, 16 { node => 3, code => 200, content => 1 }, 17 18 # force check 19 { node => 1, code => 200, content => 1 }, 20 { node => 2, code => 200, content => 1 }, 21 { node => 3, code => 200, content => 1 }, 22); 23 24ok $t->perform_request() 25 && !eval { $t->perform_request } 26 && $@ =~ /Timeout/ 27 && $t->perform_request 28 && $t->perform_request 29 && $t->perform_request 30 && $t->cxn_pool->cxns->[1]->force_ping 31 && $t->perform_request 32 && $t->perform_request 33 && $t->perform_request, 34 'Node timesout and recovers'; 35 36done_testing; 37 38