elastomer-client 3.2.3 → 6.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. checksums.yaml +4 -4
  2. data/.devcontainer/devcontainer.json +46 -0
  3. data/.devcontainer/postCreateCommand.sh +4 -0
  4. data/.github/dependabot.yaml +11 -0
  5. data/.github/workflows/main.yml +45 -0
  6. data/.github/workflows/rubocop.yml +15 -0
  7. data/.gitignore +1 -1
  8. data/.rubocop.yml +13 -65
  9. data/.ruby-version +1 -0
  10. data/CHANGELOG.md +76 -0
  11. data/Gemfile +18 -1
  12. data/README.md +110 -51
  13. data/Rakefile +3 -1
  14. data/docker/compose.yaml +71 -0
  15. data/docker/elasticsearch8plus.yml +13 -0
  16. data/docs/README.md +4 -5
  17. data/docs/bulk_indexing.md +1 -1
  18. data/docs/client.md +20 -33
  19. data/docs/cluster.md +8 -8
  20. data/docs/docs.md +5 -5
  21. data/docs/index.md +4 -4
  22. data/docs/multi_search.md +1 -1
  23. data/docs/notifications.md +3 -3
  24. data/docs/scan_scroll.md +1 -1
  25. data/docs/snapshots.md +1 -1
  26. data/docs/templates.md +1 -1
  27. data/elastomer-client.gemspec +7 -16
  28. data/lib/{elastomer → elastomer_client}/client/bulk.rb +70 -47
  29. data/lib/{elastomer → elastomer_client}/client/cluster.rb +18 -16
  30. data/lib/{elastomer → elastomer_client}/client/delete_by_query.rb +6 -4
  31. data/lib/{elastomer → elastomer_client}/client/docs.rb +82 -72
  32. data/lib/{elastomer → elastomer_client}/client/errors.rb +7 -17
  33. data/lib/{elastomer → elastomer_client}/client/index.rb +55 -79
  34. data/lib/{elastomer → elastomer_client}/client/multi_percolate.rb +7 -5
  35. data/lib/{elastomer → elastomer_client}/client/multi_search.rb +5 -3
  36. data/lib/{elastomer → elastomer_client}/client/native_delete_by_query.rb +6 -6
  37. data/lib/{elastomer → elastomer_client}/client/nodes.rb +11 -10
  38. data/lib/{elastomer → elastomer_client}/client/percolator.rb +9 -10
  39. data/lib/elastomer_client/client/reindex.rb +34 -0
  40. data/lib/{elastomer → elastomer_client}/client/repository.rb +7 -5
  41. data/lib/{elastomer → elastomer_client}/client/rest_api_spec/api_spec.rb +7 -6
  42. data/lib/{elastomer → elastomer_client}/client/rest_api_spec/api_spec_v5_6.rb +1 -1
  43. data/lib/elastomer_client/client/rest_api_spec/api_spec_v8_13.rb +7567 -0
  44. data/lib/elastomer_client/client/rest_api_spec/api_spec_v8_7.rb +6553 -0
  45. data/lib/{elastomer → elastomer_client}/client/rest_api_spec/rest_api.rb +5 -3
  46. data/lib/{elastomer → elastomer_client}/client/rest_api_spec.rb +3 -2
  47. data/lib/{elastomer → elastomer_client}/client/scroller.rb +17 -16
  48. data/lib/{elastomer → elastomer_client}/client/snapshot.rb +10 -8
  49. data/lib/{elastomer → elastomer_client}/client/tasks.rb +9 -13
  50. data/lib/{elastomer → elastomer_client}/client/template.rb +10 -9
  51. data/lib/elastomer_client/client/update_by_query.rb +50 -0
  52. data/lib/{elastomer → elastomer_client}/client.rb +51 -62
  53. data/lib/{elastomer → elastomer_client}/core_ext/time.rb +2 -0
  54. data/lib/{elastomer → elastomer_client}/middleware/compress.rb +2 -2
  55. data/lib/{elastomer → elastomer_client}/middleware/encode_json.rb +4 -2
  56. data/lib/{elastomer → elastomer_client}/middleware/limit_size.rb +5 -3
  57. data/lib/{elastomer → elastomer_client}/middleware/opaque_id.rb +10 -7
  58. data/lib/{elastomer → elastomer_client}/middleware/parse_json.rb +5 -3
  59. data/lib/{elastomer → elastomer_client}/notifications.rb +17 -15
  60. data/lib/elastomer_client/version.rb +9 -0
  61. data/lib/elastomer_client/version_support.rb +24 -0
  62. data/script/bootstrap +4 -2
  63. data/script/console +3 -1
  64. data/script/generate-rest-api-spec +77 -22
  65. data/test/assertions.rb +32 -39
  66. data/test/client/bulk_test.rb +166 -141
  67. data/test/client/cluster_test.rb +35 -13
  68. data/test/client/docs_test.rb +387 -274
  69. data/test/client/errors_test.rb +38 -40
  70. data/test/client/index_test.rb +243 -202
  71. data/test/client/multi_percolate_test.rb +46 -41
  72. data/test/client/multi_search_test.rb +122 -67
  73. data/test/client/native_delete_by_query_test.rb +96 -88
  74. data/test/client/nodes_test.rb +21 -10
  75. data/test/client/percolator_test.rb +19 -14
  76. data/test/client/reindex_test.rb +100 -0
  77. data/test/client/repository_test.rb +31 -19
  78. data/test/client/rest_api_spec/api_spec_test.rb +13 -11
  79. data/test/client/rest_api_spec/rest_api_test.rb +9 -7
  80. data/test/client/scroller_test.rb +44 -70
  81. data/test/client/snapshot_test.rb +38 -21
  82. data/test/client/stubbed_client_test.rb +7 -4
  83. data/test/client/tasks_test.rb +12 -17
  84. data/test/client/template_test.rb +34 -13
  85. data/test/client/update_by_query_test.rb +137 -0
  86. data/test/client_test.rb +158 -92
  87. data/test/core_ext/time_test.rb +14 -12
  88. data/test/middleware/encode_json_test.rb +18 -7
  89. data/test/middleware/opaque_id_test.rb +18 -14
  90. data/test/middleware/parse_json_test.rb +17 -9
  91. data/test/mock_response.rb +30 -0
  92. data/test/notifications_test.rb +15 -8
  93. data/test/test_helper.rb +40 -97
  94. data/test/version_support_test.rb +13 -78
  95. metadata +60 -208
  96. data/.overcommit.yml +0 -5
  97. data/.travis.yml +0 -34
  98. data/docker/docker-compose.cibuild.yml +0 -8
  99. data/docker/docker-compose.es24.yml +0 -34
  100. data/docker/docker-compose.es56.yml +0 -37
  101. data/docs/warmers.md +0 -3
  102. data/lib/elastomer/client/app_delete_by_query.rb +0 -144
  103. data/lib/elastomer/client/rest_api_spec/api_spec_v2_3.rb +0 -2232
  104. data/lib/elastomer/client/rest_api_spec/api_spec_v2_4.rb +0 -2250
  105. data/lib/elastomer/client/warmer.rb +0 -98
  106. data/lib/elastomer/version.rb +0 -7
  107. data/lib/elastomer/version_support.rb +0 -182
  108. data/script/cibuild +0 -103
  109. data/script/cibuild-elastomer-client +0 -1
  110. data/script/cibuild-elastomer-client-es24 +0 -8
  111. data/script/cibuild-elastomer-client-es56 +0 -8
  112. data/test/client/app_delete_by_query_test.rb +0 -192
  113. data/test/client/es_5_x_warmer_test.rb +0 -13
  114. data/test/client/warmer_test.rb +0 -60
@@ -1,6 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative "../test_helper"
2
4
 
3
- describe Elastomer::Client::Cluster do
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
- assert [@name], h["metadata"]["indices"].keys
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.ttl.interval" => "30m" }
65
+ @cluster.update_settings transient: { "indices.recovery.max_bytes_per_sec" => "30mb" }
57
66
  h = @cluster.settings
58
67
 
59
- value = h["transient"]["indices"]["ttl"]["interval"]
60
- assert_equal "30m", value
68
+ value = h["transient"]["indices"]["recovery"]["max_bytes_per_sec"]
69
+
70
+ assert_equal "30mb", value
61
71
 
62
- @cluster.update_settings transient: { "indices.ttl.interval" => "60m" }
72
+ @cluster.update_settings transient: { "indices.recovery.max_bytes_per_sec" => "60mb" }
63
73
  h = @cluster.settings
64
74
 
65
- value = h["transient"]["indices"]["ttl"]["interval"]
66
- assert_equal "60m", value
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") if cluster_stats_includes_underscore_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
- assert h["tasks"].is_a?(Array), "the tasks lists is always an Array even if empty"
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
- assert !indices.empty?, "expected to see an index"
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
- assert !nodes.empty?, "we have to have some nodes"
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