Debian Codegraph @

t/40_Transport/30_perform_request.t

raw symbols SCIP
1 # Licensed to Elasticsearch B.V. under one or more contributor
2 # license agreements. See the NOTICE file distributed with
3 # this work for additional information regarding copyright
4 # ownership. Elasticsearch B.V. licenses this file to you under
5 # the Apache License, Version 2.0 (the "License"); you may
6 # not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing,
12 # software distributed under the License is distributed on an
13 # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 # KIND, either express or implied. See the License for the
15 # specific language governing permissions and limitations
16 # under the License.
17
18 use Test::Morescip-perl cpan Search-Elasticsearch 8.12 Test/More/;
19 use Test::Deepscip-perl cpan Search-Elasticsearch 8.12 Test/Deep/;
20 use Test::Exceptionscip-perl cpan Search-Elasticsearch 8.12 Test/Exception/;
21 use Search::Elasticsearchscip-perl cpan Search-Elasticsearch 8.12 Search/Elasticsearch/;
22 use libscip-perl cpan Search-Elasticsearch 8.12 lib/ 't/lib';
23 use MockCxnscip-perl cpan Search-Elasticsearch 8.12 MockCxn/ qw(mock_static_client);
24
25 our $tscip-perl cpan Search-Elasticsearch 8.12 main/$t.;
26
27 # good request
28 $tscip-perl cpan Search-Elasticsearch 8.12 main/$t. = mock_static_clientscip-perl cpan Search-Elasticsearch 8.12 MockCxn/mock_static_client().(
29 { nodes => ['one'] }, #
30 { node => 1, ping => 1 }, #
31 { node => 1, code => '200', content => 1 }
32 );
33
34 okscip-perl cpan Search-Elasticsearch 8.12 main/ok(). $tscip-perl cpan Search-Elasticsearch 8.12 main/$t.->perform_requestscip-perl cpan Search-Elasticsearch 8.12 main/perform_request()., 'Simple request';
35
36 # Request error
37 $tscip-perl cpan Search-Elasticsearch 8.12 main/$t. = mock_static_clientscip-perl cpan Search-Elasticsearch 8.12 MockCxn/mock_static_client().(
38 { nodes => ['one'] },
39 { node => 1, ping => 1 },
40 { node => 1, code => '404', error => 'NotFound' }
41 );
42
43 throws_okscip-perl cpan Search-Elasticsearch 8.12 main/throws_ok(). { $tscip-perl cpan Search-Elasticsearch 8.12 main/$t.->perform_requestscip-perl cpan Search-Elasticsearch 8.12 main/perform_request(). } qr/Missing/, 'Request error';
44
45 # Timeout error
46 $tscip-perl cpan Search-Elasticsearch 8.12 main/$t. = mock_static_clientscip-perl cpan Search-Elasticsearch 8.12 MockCxn/mock_static_client().(
47 { nodes => ['one'] },
48 { node => 1, ping => 1 },
49 { node => 1, code => '509', error => 'Timeout' },
50 { node => 1, ping => 1 },
51 { node => 1, code => '200', content => 1 }
52 );
53
54 throws_okscip-perl cpan Search-Elasticsearch 8.12 main/throws_ok(). { $tscip-perl cpan Search-Elasticsearch 8.12 main/$t.->perform_requestscip-perl cpan Search-Elasticsearch 8.12 main/perform_request(). } qr/Timeout/, 'Timeout error';
55 okscip-perl cpan Search-Elasticsearch 8.12 main/ok(). $tscip-perl cpan Search-Elasticsearch 8.12 main/$t.->perform_requestscip-perl cpan Search-Elasticsearch 8.12 main/perform_request()., 'Timeout resolved';
56
57 # Cxn error
58 $tscip-perl cpan Search-Elasticsearch 8.12 main/$t. = mock_static_clientscip-perl cpan Search-Elasticsearch 8.12 MockCxn/mock_static_client().(
59 { nodes => ['one'] },
60 { node => 1, ping => 1 },
61 { node => 1, code => '509', error => 'Cxn' },
62 { node => 1, ping => 1 },
63 { node => 1, code => '200', content => 1 }
64 );
65
66 okscip-perl cpan Search-Elasticsearch 8.12 main/ok(). $tscip-perl cpan Search-Elasticsearch 8.12 main/$t.->perform_requestscip-perl cpan Search-Elasticsearch 8.12 main/perform_request()., 'Retried connection error';
67
68 # NoNodes from failure
69 $tscip-perl cpan Search-Elasticsearch 8.12 main/$t. = mock_static_clientscip-perl cpan Search-Elasticsearch 8.12 MockCxn/mock_static_client().(
70 { nodes => ['one'] },
71 { node => 1, ping => 1 },
72 { node => 1, code => '509', error => 'Cxn' },
73 { node => 1, ping => 0 },
74 );
75
76 throws_okscip-perl cpan Search-Elasticsearch 8.12 main/throws_ok(). { $tscip-perl cpan Search-Elasticsearch 8.12 main/$t.->perform_requestscip-perl cpan Search-Elasticsearch 8.12 main/perform_request(). } qr/NoNodes/, 'Cxn then bad ping';
77
78 # NoNodes reachable
79 $tscip-perl cpan Search-Elasticsearch 8.12 main/$t. = mock_static_clientscip-perl cpan Search-Elasticsearch 8.12 MockCxn/mock_static_client().(
80 { nodes => ['one'] }, #
81 { node => 1, ping => 0 },
82 );
83
84 throws_okscip-perl cpan Search-Elasticsearch 8.12 main/throws_ok(). { $tscip-perl cpan Search-Elasticsearch 8.12 main/$t.->perform_requestscip-perl cpan Search-Elasticsearch 8.12 main/perform_request(). } qr/NoNodes/, 'Initial bad ping';
85
86 done_testing;