elastomer-client 3.2.2 → 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 +76 -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 +6 -4
- 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 +165 -143
- 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/cluster_test.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative "../test_helper"
|
2
4
|
|
3
|
-
describe
|
5
|
+
describe ElastomerClient::Client::Cluster do
|
4
6
|
|
5
7
|
before do
|
6
8
|
@name = "elastomer-cluster-test"
|
@@ -15,12 +17,14 @@ describe Elastomer::Client::Cluster do
|
|
15
17
|
|
16
18
|
it "gets the cluster health" do
|
17
19
|
h = @cluster.health
|
20
|
+
|
18
21
|
assert h.key?("cluster_name"), "the cluster name is returned"
|
19
22
|
assert h.key?("status"), "the cluster status is returned"
|
20
23
|
end
|
21
24
|
|
22
25
|
it "gets the cluster state" do
|
23
26
|
h = @cluster.state
|
27
|
+
|
24
28
|
assert h.key?("cluster_name"), "the cluster name is returned"
|
25
29
|
assert h.key?("master_node"), "the master node is returned"
|
26
30
|
assert_instance_of Hash, h["nodes"], "the node list is returned"
|
@@ -29,65 +33,76 @@ describe Elastomer::Client::Cluster do
|
|
29
33
|
|
30
34
|
it "filters cluster state by metrics" do
|
31
35
|
h = @cluster.state(metrics: "nodes")
|
36
|
+
|
32
37
|
refute h.key("metadata"), "expected only nodes state"
|
33
38
|
h = @cluster.state(metrics: "metadata")
|
39
|
+
|
34
40
|
refute h.key("nodes"), "expected only metadata state"
|
35
41
|
end
|
36
42
|
|
37
43
|
it "filters cluster state by indices" do
|
38
44
|
@index.create(default_index_settings) unless @index.exists?
|
39
45
|
h = @cluster.state(metrics: "metadata", indices: @name)
|
40
|
-
|
46
|
+
|
47
|
+
assert_equal [@name], h["metadata"]["indices"].keys
|
41
48
|
end
|
42
49
|
|
43
50
|
it "gets the cluster settings" do
|
44
51
|
h = @cluster.get_settings
|
52
|
+
|
45
53
|
assert_instance_of Hash, h["persistent"], "the persistent settings are returned"
|
46
54
|
assert_instance_of Hash, h["transient"], "the transient settings are returned"
|
47
55
|
end
|
48
56
|
|
49
57
|
it "gets the cluster settings with .settings" do
|
50
58
|
h = @cluster.settings
|
59
|
+
|
51
60
|
assert_instance_of Hash, h["persistent"], "the persistent settings are returned"
|
52
61
|
assert_instance_of Hash, h["transient"], "the transient settings are returned"
|
53
62
|
end
|
54
63
|
|
55
64
|
it "updates the cluster settings" do
|
56
|
-
@cluster.update_settings transient: { "indices.
|
65
|
+
@cluster.update_settings transient: { "indices.recovery.max_bytes_per_sec" => "30mb" }
|
57
66
|
h = @cluster.settings
|
58
67
|
|
59
|
-
value = h["transient"]["indices"]["
|
60
|
-
|
68
|
+
value = h["transient"]["indices"]["recovery"]["max_bytes_per_sec"]
|
69
|
+
|
70
|
+
assert_equal "30mb", value
|
61
71
|
|
62
|
-
@cluster.update_settings transient: { "indices.
|
72
|
+
@cluster.update_settings transient: { "indices.recovery.max_bytes_per_sec" => "60mb" }
|
63
73
|
h = @cluster.settings
|
64
74
|
|
65
|
-
value = h["transient"]["indices"]["
|
66
|
-
|
75
|
+
value = h["transient"]["indices"]["recovery"]["max_bytes_per_sec"]
|
76
|
+
|
77
|
+
assert_equal "60mb", value
|
67
78
|
end
|
68
79
|
|
69
80
|
it "returns cluster stats" do
|
70
81
|
h = @cluster.stats
|
71
|
-
expected = %w[cluster_name indices nodes status timestamp]
|
72
|
-
expected.unshift("_nodes")
|
82
|
+
expected = $client.version_support.es_version_8_plus? ? %w[cluster_name cluster_uuid indices nodes snapshots status timestamp] : %w[cluster_name indices nodes status timestamp]
|
83
|
+
expected.unshift("_nodes")
|
84
|
+
|
73
85
|
assert_equal expected, h.keys.sort
|
74
86
|
end
|
75
87
|
|
76
88
|
it "returns a list of pending tasks" do
|
77
89
|
h = @cluster.pending_tasks
|
90
|
+
|
78
91
|
assert_equal %w[tasks], h.keys.sort
|
79
|
-
|
92
|
+
assert_kind_of Array, h["tasks"], "the tasks lists is always an Array even if empty"
|
80
93
|
end
|
81
94
|
|
82
95
|
it "returns the list of indices in the cluster" do
|
83
96
|
@index.create(default_index_settings) unless @index.exists?
|
84
97
|
indices = @cluster.indices
|
85
|
-
|
98
|
+
|
99
|
+
refute_empty indices, "expected to see an index"
|
86
100
|
end
|
87
101
|
|
88
102
|
it "returns the list of nodes in the cluster" do
|
89
103
|
nodes = @cluster.nodes
|
90
|
-
|
104
|
+
|
105
|
+
refute_empty nodes, "we have to have some nodes"
|
91
106
|
end
|
92
107
|
|
93
108
|
describe "when working with aliases" do
|
@@ -104,23 +119,27 @@ describe Elastomer::Client::Cluster do
|
|
104
119
|
|
105
120
|
it "adds and gets an alias" do
|
106
121
|
hash = @cluster.get_aliases
|
122
|
+
|
107
123
|
assert_empty hash[@name]["aliases"]
|
108
124
|
|
109
125
|
@cluster.update_aliases \
|
110
126
|
add: {index: @name, alias: "elastomer-test-unikitty"}
|
111
127
|
|
112
128
|
hash = @cluster.get_aliases
|
129
|
+
|
113
130
|
assert_equal ["elastomer-test-unikitty"], hash[@name]["aliases"].keys
|
114
131
|
end
|
115
132
|
|
116
133
|
it "adds and gets an alias with .aliases" do
|
117
134
|
hash = @cluster.aliases
|
135
|
+
|
118
136
|
assert_empty hash[@name]["aliases"]
|
119
137
|
|
120
138
|
@cluster.update_aliases \
|
121
139
|
add: {index: @name, alias: "elastomer-test-unikitty"}
|
122
140
|
|
123
141
|
hash = @cluster.aliases
|
142
|
+
|
124
143
|
assert_equal ["elastomer-test-unikitty"], hash[@name]["aliases"].keys
|
125
144
|
end
|
126
145
|
|
@@ -129,6 +148,7 @@ describe Elastomer::Client::Cluster do
|
|
129
148
|
add: {index: @name, alias: "elastomer-test-unikitty"}
|
130
149
|
|
131
150
|
hash = @cluster.get_aliases
|
151
|
+
|
132
152
|
assert_equal ["elastomer-test-unikitty"], hash[@name]["aliases"].keys
|
133
153
|
|
134
154
|
@cluster.update_aliases([
|
@@ -137,6 +157,7 @@ describe Elastomer::Client::Cluster do
|
|
137
157
|
])
|
138
158
|
|
139
159
|
hash = @cluster.get_aliases
|
160
|
+
|
140
161
|
assert_equal ["elastomer-test-SpongeBob-SquarePants"], hash[@name]["aliases"].keys
|
141
162
|
end
|
142
163
|
|
@@ -147,6 +168,7 @@ describe Elastomer::Client::Cluster do
|
|
147
168
|
]
|
148
169
|
|
149
170
|
hash = @cluster.get_aliases(index: @name)
|
171
|
+
|
150
172
|
assert_equal %w[elastomer-test-He-Man elastomer-test-Skeletor], hash[@name]["aliases"].keys.sort
|
151
173
|
end
|
152
174
|
end
|