elastomer-client 3.2.3 → 6.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.devcontainer/devcontainer.json +46 -0
- data/.devcontainer/postCreateCommand.sh +4 -0
- data/.github/dependabot.yaml +11 -0
- data/.github/workflows/main.yml +45 -0
- data/.github/workflows/rubocop.yml +15 -0
- data/.gitignore +1 -1
- data/.rubocop.yml +13 -65
- data/.ruby-version +1 -0
- data/CHANGELOG.md +73 -0
- data/Gemfile +18 -1
- data/README.md +110 -51
- data/Rakefile +3 -1
- data/docker/compose.yaml +71 -0
- data/docker/elasticsearch8plus.yml +13 -0
- data/docs/README.md +4 -5
- data/docs/bulk_indexing.md +1 -1
- data/docs/client.md +20 -33
- data/docs/cluster.md +8 -8
- data/docs/docs.md +5 -5
- data/docs/index.md +4 -4
- data/docs/multi_search.md +1 -1
- data/docs/notifications.md +3 -3
- data/docs/scan_scroll.md +1 -1
- data/docs/snapshots.md +1 -1
- data/docs/templates.md +1 -1
- data/elastomer-client.gemspec +7 -16
- data/lib/{elastomer → elastomer_client}/client/bulk.rb +70 -47
- data/lib/{elastomer → elastomer_client}/client/cluster.rb +18 -16
- data/lib/{elastomer → elastomer_client}/client/delete_by_query.rb +6 -4
- data/lib/{elastomer → elastomer_client}/client/docs.rb +82 -72
- data/lib/{elastomer → elastomer_client}/client/errors.rb +7 -17
- data/lib/{elastomer → elastomer_client}/client/index.rb +55 -79
- data/lib/{elastomer → elastomer_client}/client/multi_percolate.rb +7 -5
- data/lib/{elastomer → elastomer_client}/client/multi_search.rb +5 -3
- data/lib/{elastomer → elastomer_client}/client/native_delete_by_query.rb +6 -6
- data/lib/{elastomer → elastomer_client}/client/nodes.rb +11 -10
- data/lib/{elastomer → elastomer_client}/client/percolator.rb +9 -10
- data/lib/elastomer_client/client/reindex.rb +29 -0
- data/lib/{elastomer → elastomer_client}/client/repository.rb +7 -5
- data/lib/{elastomer → elastomer_client}/client/rest_api_spec/api_spec.rb +7 -6
- data/lib/{elastomer → elastomer_client}/client/rest_api_spec/api_spec_v5_6.rb +1 -1
- data/lib/elastomer_client/client/rest_api_spec/api_spec_v8_13.rb +7567 -0
- data/lib/elastomer_client/client/rest_api_spec/api_spec_v8_7.rb +6553 -0
- data/lib/{elastomer → elastomer_client}/client/rest_api_spec/rest_api.rb +5 -3
- data/lib/{elastomer → elastomer_client}/client/rest_api_spec.rb +3 -2
- data/lib/{elastomer → elastomer_client}/client/scroller.rb +17 -16
- data/lib/{elastomer → elastomer_client}/client/snapshot.rb +10 -8
- data/lib/{elastomer → elastomer_client}/client/tasks.rb +9 -13
- data/lib/{elastomer → elastomer_client}/client/template.rb +10 -9
- data/lib/elastomer_client/client/update_by_query.rb +50 -0
- data/lib/{elastomer → elastomer_client}/client.rb +51 -62
- data/lib/{elastomer → elastomer_client}/core_ext/time.rb +2 -0
- data/lib/{elastomer → elastomer_client}/middleware/compress.rb +2 -2
- data/lib/{elastomer → elastomer_client}/middleware/encode_json.rb +4 -2
- data/lib/{elastomer → elastomer_client}/middleware/limit_size.rb +5 -3
- data/lib/{elastomer → elastomer_client}/middleware/opaque_id.rb +10 -7
- data/lib/{elastomer → elastomer_client}/middleware/parse_json.rb +5 -3
- data/lib/{elastomer → elastomer_client}/notifications.rb +17 -15
- data/lib/elastomer_client/version.rb +9 -0
- data/lib/elastomer_client/version_support.rb +24 -0
- data/script/bootstrap +4 -2
- data/script/console +3 -1
- data/script/generate-rest-api-spec +77 -22
- data/test/assertions.rb +32 -39
- data/test/client/bulk_test.rb +166 -141
- data/test/client/cluster_test.rb +35 -13
- data/test/client/docs_test.rb +387 -274
- data/test/client/errors_test.rb +38 -40
- data/test/client/index_test.rb +243 -202
- data/test/client/multi_percolate_test.rb +46 -41
- data/test/client/multi_search_test.rb +122 -67
- data/test/client/native_delete_by_query_test.rb +96 -88
- data/test/client/nodes_test.rb +21 -10
- data/test/client/percolator_test.rb +19 -14
- data/test/client/reindex_test.rb +76 -0
- data/test/client/repository_test.rb +31 -19
- data/test/client/rest_api_spec/api_spec_test.rb +13 -11
- data/test/client/rest_api_spec/rest_api_test.rb +9 -7
- data/test/client/scroller_test.rb +44 -70
- data/test/client/snapshot_test.rb +38 -21
- data/test/client/stubbed_client_test.rb +7 -4
- data/test/client/tasks_test.rb +12 -17
- data/test/client/template_test.rb +34 -13
- data/test/client/update_by_query_test.rb +137 -0
- data/test/client_test.rb +158 -92
- data/test/core_ext/time_test.rb +14 -12
- data/test/middleware/encode_json_test.rb +18 -7
- data/test/middleware/opaque_id_test.rb +18 -14
- data/test/middleware/parse_json_test.rb +17 -9
- data/test/mock_response.rb +30 -0
- data/test/notifications_test.rb +15 -8
- data/test/test_helper.rb +40 -97
- data/test/version_support_test.rb +13 -78
- metadata +60 -208
- data/.overcommit.yml +0 -5
- data/.travis.yml +0 -34
- data/docker/docker-compose.cibuild.yml +0 -8
- data/docker/docker-compose.es24.yml +0 -34
- data/docker/docker-compose.es56.yml +0 -37
- data/docs/warmers.md +0 -3
- data/lib/elastomer/client/app_delete_by_query.rb +0 -144
- data/lib/elastomer/client/rest_api_spec/api_spec_v2_3.rb +0 -2232
- data/lib/elastomer/client/rest_api_spec/api_spec_v2_4.rb +0 -2250
- data/lib/elastomer/client/warmer.rb +0 -98
- data/lib/elastomer/version.rb +0 -7
- data/lib/elastomer/version_support.rb +0 -182
- data/script/cibuild +0 -103
- data/script/cibuild-elastomer-client +0 -1
- data/script/cibuild-elastomer-client-es24 +0 -8
- data/script/cibuild-elastomer-client-es56 +0 -8
- data/test/client/app_delete_by_query_test.rb +0 -192
- data/test/client/es_5_x_warmer_test.rb +0 -13
- data/test/client/warmer_test.rb +0 -60
data/test/client/errors_test.rb
CHANGED
@@ -1,19 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative "../test_helper"
|
2
4
|
|
3
|
-
describe
|
5
|
+
describe ElastomerClient::Client::Error do
|
4
6
|
|
5
7
|
it "is instantiated with a simple message" do
|
6
|
-
err =
|
8
|
+
err = ElastomerClient::Client::Error.new "something went wrong"
|
9
|
+
|
7
10
|
assert_equal "something went wrong", err.message
|
8
11
|
end
|
9
12
|
|
10
13
|
it "is instantiated from an HTTP response" do
|
11
|
-
response = Faraday::Response.new(:
|
12
|
-
err =
|
14
|
+
response = Faraday::Response.new(body: "UTF8Error invalid middle-byte")
|
15
|
+
err = ElastomerClient::Client::Error.new(response)
|
16
|
+
|
13
17
|
assert_equal "UTF8Error invalid middle-byte", err.message
|
14
18
|
|
15
|
-
response = Faraday::Response.new(:
|
16
|
-
err =
|
19
|
+
response = Faraday::Response.new(body: {"error" => "IndexMissingException"})
|
20
|
+
err = ElastomerClient::Client::Error.new(response)
|
21
|
+
|
17
22
|
assert_equal "IndexMissingException", err.message
|
18
23
|
assert_equal "IndexMissingException", err.error
|
19
24
|
|
@@ -34,64 +39,57 @@ describe Elastomer::Client::Error do
|
|
34
39
|
},
|
35
40
|
"status" => 404
|
36
41
|
}
|
37
|
-
response = Faraday::Response.new(:
|
38
|
-
err =
|
42
|
+
response = Faraday::Response.new(body:)
|
43
|
+
err = ElastomerClient::Client::Error.new(response)
|
44
|
+
|
39
45
|
assert_equal body["error"].to_s, err.message
|
40
46
|
assert_equal body["error"], err.error
|
41
47
|
end
|
42
48
|
|
43
49
|
it "is instantiated from another exception" do
|
44
|
-
err = Faraday::
|
50
|
+
err = Faraday::ConnectionFailed.new "could not connect to host"
|
45
51
|
err.set_backtrace %w[one two three four]
|
46
52
|
|
47
|
-
err =
|
53
|
+
err = ElastomerClient::Client::Error.new(err, "POST", "/index/doc")
|
54
|
+
|
48
55
|
assert_equal "could not connect to host :: POST /index/doc", err.message
|
49
56
|
assert_equal %w[one two three four], err.backtrace
|
50
57
|
end
|
51
58
|
|
52
59
|
it "is fatal by default" do
|
53
|
-
assert
|
60
|
+
assert ElastomerClient::Client::Error.fatal, "client errors are fatal by default"
|
61
|
+
|
62
|
+
error = ElastomerClient::Client::Error.new "oops!"
|
54
63
|
|
55
|
-
error
|
56
|
-
assert !error.retry?, "client errors are not retryable by default"
|
64
|
+
refute_predicate error, :retry?, "client errors are not retryable by default"
|
57
65
|
end
|
58
66
|
|
59
67
|
it "supports .fatal? alias" do
|
60
|
-
|
68
|
+
assert_predicate ElastomerClient::Client::Error, :fatal?, "client errors support .fatal?"
|
61
69
|
end
|
62
70
|
|
63
71
|
it "has some fatal subclasses" do
|
64
|
-
assert
|
65
|
-
assert
|
66
|
-
assert
|
67
|
-
assert
|
68
|
-
assert
|
72
|
+
assert ElastomerClient::Client::ResourceNotFound.fatal, "Resource not found is fatal"
|
73
|
+
assert ElastomerClient::Client::ParsingError.fatal, "Parsing error is fatal"
|
74
|
+
assert ElastomerClient::Client::SSLError.fatal, "SSL error is fatal"
|
75
|
+
assert ElastomerClient::Client::RequestError.fatal, "Request error is fatal"
|
76
|
+
assert ElastomerClient::Client::DocumentAlreadyExistsError.fatal, "DocumentAlreadyExistsError error is fatal"
|
69
77
|
end
|
70
78
|
|
71
79
|
it "has some non-fatal subclasses" do
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
80
|
+
refute ElastomerClient::Client::TimeoutError.fatal, "Timeouts are not fatal"
|
81
|
+
refute ElastomerClient::Client::ConnectionFailed.fatal, "Connection failures are not fatal"
|
82
|
+
refute ElastomerClient::Client::ServerError.fatal, "Server errors are not fatal"
|
83
|
+
refute ElastomerClient::Client::RejectedExecutionError.fatal, "Rejected execution errors are not fatal"
|
76
84
|
end
|
77
85
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
end
|
86
|
-
end
|
87
|
-
else
|
88
|
-
it "does not raise illegal argument exceptions" do
|
89
|
-
begin
|
90
|
-
$client.get("/_cluster/health?consistency=all")
|
91
|
-
assert true, "Exception was not raised"
|
92
|
-
rescue Elastomer::Client::Error => err
|
93
|
-
assert false, "Exception #{err} was raised"
|
94
|
-
end
|
86
|
+
it "wraps illegal argument exceptions" do
|
87
|
+
begin
|
88
|
+
$client.get("/_cluster/health?consistency=all")
|
89
|
+
|
90
|
+
assert false, "IllegalArgument exception was not raised"
|
91
|
+
rescue ElastomerClient::Client::IllegalArgument => err
|
92
|
+
assert_match(/request \[\/_cluster\/health\] contains unrecognized parameter: \[consistency\]/, err.message)
|
95
93
|
end
|
96
94
|
end
|
97
95
|
end
|