elasticsearch-transport 6.8.3 → 7.0.0.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +17 -0
  3. data/LICENSE.txt +199 -10
  4. data/README.md +32 -86
  5. data/Rakefile +23 -4
  6. data/elasticsearch-transport.gemspec +78 -45
  7. data/lib/elasticsearch-transport.rb +16 -3
  8. data/lib/elasticsearch/transport.rb +17 -3
  9. data/lib/elasticsearch/transport/client.rb +70 -174
  10. data/lib/elasticsearch/transport/redacted.rb +5 -9
  11. data/lib/elasticsearch/transport/transport/base.rb +63 -55
  12. data/lib/elasticsearch/transport/transport/connections/collection.rb +16 -3
  13. data/lib/elasticsearch/transport/transport/connections/connection.rb +16 -3
  14. data/lib/elasticsearch/transport/transport/connections/selector.rb +16 -3
  15. data/lib/elasticsearch/transport/transport/errors.rb +16 -3
  16. data/lib/elasticsearch/transport/transport/http/curb.rb +18 -5
  17. data/lib/elasticsearch/transport/transport/http/faraday.rb +18 -5
  18. data/lib/elasticsearch/transport/transport/http/manticore.rb +17 -4
  19. data/lib/elasticsearch/transport/transport/loggable.rb +85 -0
  20. data/lib/elasticsearch/transport/transport/response.rb +16 -3
  21. data/lib/elasticsearch/transport/transport/serializer/multi_json.rb +16 -3
  22. data/lib/elasticsearch/transport/transport/sniffer.rb +17 -5
  23. data/lib/elasticsearch/transport/version.rb +17 -4
  24. data/spec/elasticsearch/transport/base_spec.rb +8 -187
  25. data/spec/elasticsearch/transport/client_spec.rb +29 -163
  26. data/spec/elasticsearch/transport/sniffer_spec.rb +19 -0
  27. data/spec/spec_helper.rb +2 -11
  28. data/test/integration/transport_test.rb +18 -5
  29. data/test/profile/client_benchmark_test.rb +16 -3
  30. data/test/test_helper.rb +63 -14
  31. data/test/unit/connection_collection_test.rb +17 -4
  32. data/test/unit/connection_selector_test.rb +17 -4
  33. data/test/unit/connection_test.rb +17 -4
  34. data/test/unit/response_test.rb +18 -5
  35. data/test/unit/serializer_test.rb +17 -4
  36. data/test/unit/transport_base_test.rb +21 -8
  37. data/test/unit/transport_curb_test.rb +17 -4
  38. data/test/unit/transport_faraday_test.rb +17 -4
  39. data/test/unit/transport_manticore_test.rb +24 -6
  40. metadata +61 -86
  41. data/spec/elasticsearch/transport/meta_header_spec.rb +0 -214
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 84ce4d26d5dd03b5bc17d89e4ce0a873b5d57083f07cf54cf78552d7e88ff61f
4
- data.tar.gz: 69b164ec36cd3cb2ee3355c0806a0109e21a69ca605a9f87b020f9d8476e5096
3
+ metadata.gz: 4d9ee9ab46f5bef5dab7eee2f5f0e7d6b31e64df57b35b557cd84f9552688bec
4
+ data.tar.gz: 374b86b76a434a4e8f04a4a03545735ca87c3a0e64f368925bd2ab99fa990f7e
5
5
  SHA512:
6
- metadata.gz: e6a9fb8c521ffedd0faf79006e477e4360a2af6df876cee41ddd87278ddf06de34a69e9ccbdad0d83629a0cf1c52d0eefbf4facdb38a591a219c156a5d7d3fdf
7
- data.tar.gz: 2d729907c495a2946b68a193262b14261534d6811b2ea5517248977758ed869c3c2803284ff69bc9b9f5a863a9440a9f675f53287f136e5813677b95b1d106c8
6
+ metadata.gz: 69835b45e8378b42d9f6d8354886cf7e9c772b5aa4d8bc9e78191f65e5e083f6d7d24f1d87a5116ed93d4a7b0a34f2213eed58a62efe4c04362dcdb55b0fd9ea
7
+ data.tar.gz: 341e10f77729ee641ca3d235330d04072390ca53e4561b572e40fa27d77a4d563b0ecfd9a9f4353d2a0ff567582f192636502bb4e53683fc6a08b48370258c80
data/Gemfile CHANGED
@@ -1,3 +1,20 @@
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
+
1
18
  source 'https://rubygems.org'
2
19
 
3
20
  # Specify your gem's dependencies in elasticsearch-transport.gemspec
data/LICENSE.txt CHANGED
@@ -1,13 +1,202 @@
1
- Copyright (c) 2013 Elasticsearch
2
1
 
3
- Licensed under the Apache License, Version 2.0 (the "License");
4
- you may not use this file except in compliance with the License.
5
- You may obtain a copy of the License at
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
6
5
 
7
- http://www.apache.org/licenses/LICENSE-2.0
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
8
7
 
9
- Unless required by applicable law or agreed to in writing, software
10
- distributed under the License is distributed on an "AS IS" BASIS,
11
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- See the License for the specific language governing permissions and
13
- limitations under the License.
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
data/README.md CHANGED
@@ -28,16 +28,12 @@ Features overview:
28
28
  * Node reloading (based on cluster state) on errors or on demand
29
29
 
30
30
  For optimal performance, use a HTTP library which supports persistent ("keep-alive") connections,
31
- such as [patron](https://github.com/toland/patron) or [Typhoeus](https://github.com/typhoeus/typhoeus).
32
- Just require the library (`require 'patron'`) in your code, and it will be automatically used.
33
-
34
- Currently these libraries will be automatically detected and used:
35
- - [Patron](https://github.com/toland/patron)
36
- - [Typhoeus](https://github.com/typhoeus/typhoeus)
37
- - [HTTPClient](https://rubygems.org/gems/httpclient)
38
- - [Net::HTTP::Persistent](https://rubygems.org/gems/net-http-persistent)
39
-
40
- **Note on [Typhoeus](https://github.com/typhoeus/typhoeus)**: You need to use v1.4.0 or up since older versions are not compatible with Faraday 1.0.
31
+ such as [Typhoeus](https://github.com/typhoeus/typhoeus).
32
+ Just require the library (`require 'typhoeus'; require 'typhoeus/adapters/faraday'`) in your code,
33
+ and it will be automatically used; currently these libraries will be automatically detected and used:
34
+ [Patron](https://github.com/toland/patron),
35
+ [HTTPClient](https://rubygems.org/gems/httpclient) and
36
+ [Net::HTTP::Persistent](https://rubygems.org/gems/net-http-persistent).
41
37
 
42
38
  For detailed information, see example configurations [below](#transport-implementations).
43
39
 
@@ -73,22 +69,6 @@ Full documentation is available at <http://rubydoc.info/gems/elasticsearch-trans
73
69
 
74
70
  ## Configuration
75
71
 
76
- * [Setting Hosts](#setting-hosts)
77
- * [Default port](#default-port)
78
- * [Connect using an Elastic Cloud ID](#connect-using-an-elastic-cloud-id)
79
- * [Authentication](#authentication)
80
- * [Logging](#logging)
81
- * [Identifying running tasks with X-Opaque-Id](#identifying-running-tasks-with-x-opaque-id)
82
- * [Setting Timeouts](#setting-timeouts)
83
- * [Randomizing Hosts](#randomizing-hosts)
84
- * [Retrying on Failures](#retrying-on-failures)
85
- * [Reloading Hosts](#reloading-hosts)
86
- * [Connection Selector](#connection-selector)
87
- * [Transport Implementations](#transport-implementations)
88
- * [Serializer implementations](#serializer-implementations)
89
- * [Exception Handling](#exception-handling)
90
- * [Development and Community](#development-and-community)
91
-
92
72
  The client supports many configurations options for setting up and managing connections,
93
73
  configuring logging, customizing the transport library, etc.
94
74
 
@@ -148,26 +128,6 @@ use the `transport_options` option:
148
128
  Elasticsearch::Client.new url: 'https://username:password@example.com:9200',
149
129
  transport_options: { ssl: { ca_file: '/path/to/cacert.pem' } }
150
130
 
151
- You can also use [**API Key authentication**](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-create-api-key.html):
152
-
153
- ``` ruby
154
- Elasticsearch::Client.new(
155
- host: host,
156
- transport_options: transport_options,
157
- api_key: credentials
158
- )
159
- ```
160
-
161
- Where credentials is either the base64 encoding of `id` and `api_key` joined by a colon or a hash with the `id` and `api_key`:
162
-
163
- ``` ruby
164
- Elasticsearch::Client.new(
165
- host: host,
166
- transport_options: transport_options,
167
- api_key: {id: 'my_id', api_key: 'my_api_key'}
168
- )
169
- ```
170
-
171
131
  ### Logging
172
132
 
173
133
  To log requests and responses to standard output with the default logger (an instance of Ruby's {::Logger} class),
@@ -198,29 +158,6 @@ You can pass the client any conforming logger implementation:
198
158
 
199
159
  client = Elasticsearch::Client.new logger: log
200
160
 
201
- ### Identifying running tasks with X-Opaque-Id
202
-
203
- The X-Opaque-Id header allows to track certain calls, or associate certain tasks with the client that started them ([more on the Elasticsearch docs](https://www.elastic.co/guide/en/elasticsearch/reference/master/tasks.html#_identifying_running_tasks)). To use this feature, you need to set an id for `opaque_id` on the client on each request. Example:
204
-
205
- ```ruby
206
- client = Elasticsearch::Client.new
207
- client.search(index: 'myindex', q: 'title:test', opaque_id: '123456')
208
- ```
209
- The search request will include the following HTTP Header:
210
- ```
211
- X-Opaque-Id: 123456
212
- ```
213
-
214
- You can also set a prefix for X-Opaque-Id when initializing the client. This will be prepended to the id you set before each request if you're using X-Opaque-Id. Example:
215
- ```ruby
216
- client = Elasticsearch::Client.new(opaque_id_prefix: 'eu-west1')
217
- client.search(index: 'myindex', q: 'title:test', opaque_id: '123456')
218
- ```
219
- The request will include the following HTTP Header:
220
- ```
221
- X-Opaque-Id: eu-west1_123456
222
- ```
223
-
224
161
  ### Setting Timeouts
225
162
 
226
163
  For many operations in Elasticsearch, the default timeouts of HTTP libraries are too low.
@@ -355,35 +292,44 @@ constructor, use the `transport_options` key:
355
292
 
356
293
  To configure the _Faraday_ instance directly, use a block:
357
294
 
358
- require 'patron'
295
+ require 'typhoeus'
296
+ require 'typhoeus/adapters/faraday'
359
297
 
360
298
  client = Elasticsearch::Client.new(host: 'localhost', port: '9200') do |f|
361
299
  f.response :logger
362
- f.adapter :patron
300
+ f.adapter :typhoeus
363
301
  end
364
302
 
365
- You can use any standard Faraday middleware and plugins in the configuration block, for example sign the requests for the [AWS Elasticsearch service](https://aws.amazon.com/elasticsearch-service/). See [the AWS documentation](https://docs.aws.amazon.com/elasticsearch-service/latest/developerguide/es-request-signing.html#es-request-signing-ruby) for an example.
303
+ You can use any standard Faraday middleware and plugins in the configuration block,
304
+ for example sign the requests for the [AWS Elasticsearch service](https://aws.amazon.com/elasticsearch-service/):
305
+
306
+ require 'faraday_middleware/aws_signers_v4'
307
+
308
+ client = Elasticsearch::Client.new url: 'https://search-my-cluster-abc123....es.amazonaws.com' do |f|
309
+ f.request :aws_signers_v4,
310
+ credentials: Aws::Credentials.new(ENV['AWS_ACCESS_KEY'], ENV['AWS_SECRET_ACCESS_KEY']),
311
+ service_name: 'es',
312
+ region: 'us-east-1'
313
+ end
366
314
 
367
315
  You can also initialize the transport class yourself, and pass it to the client constructor
368
316
  as the `transport` argument:
369
317
 
370
- ```ruby
371
- require 'patron'
318
+ require 'typhoeus'
319
+ require 'typhoeus/adapters/faraday'
372
320
 
373
- transport_configuration = lambda do |f|
374
- f.response :logger
375
- f.adapter :patron
376
- end
377
-
378
- transport = Elasticsearch::Transport::Transport::HTTP::Faraday.new \
379
- hosts: [ { host: 'localhost', port: '9200' } ],
380
- &transport_configuration
321
+ transport_configuration = lambda do |f|
322
+ f.response :logger
323
+ f.adapter :typhoeus
324
+ end
381
325
 
382
- # Pass the transport to the client
383
- #
384
- client = Elasticsearch::Client.new transport: transport
385
- ```
326
+ transport = Elasticsearch::Transport::Transport::HTTP::Faraday.new \
327
+ hosts: [ { host: 'localhost', port: '9200' } ],
328
+ &transport_configuration
386
329
 
330
+ # Pass the transport to the client
331
+ #
332
+ client = Elasticsearch::Client.new transport: transport
387
333
 
388
334
  Instead of passing the transport to the constructor, you can inject it at run time:
389
335
 
data/Rakefile CHANGED
@@ -1,3 +1,20 @@
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
+
1
18
  require "bundler/gem_tasks"
2
19
 
3
20
  desc "Run unit tests"
@@ -11,13 +28,14 @@ require 'rspec/core/rake_task'
11
28
 
12
29
  namespace :test do
13
30
 
14
- RSpec::Core::RakeTask.new(:spec)
15
-
16
31
  desc "Wait for Elasticsearch to be in a green state"
17
32
  task :wait_for_green do
18
33
  sh '../scripts/wait-cluster.sh'
19
34
  end
20
35
 
36
+ task :spec => :wait_for_green
37
+ RSpec::Core::RakeTask.new(:spec)
38
+
21
39
  Rake::TestTask.new(:unit) do |test|
22
40
  test.libs << 'lib' << 'test'
23
41
  test.test_files = FileList["test/unit/**/*_test.rb"]
@@ -28,13 +46,14 @@ namespace :test do
28
46
  Rake::TestTask.new(:integration) do |test|
29
47
  test.libs << 'lib' << 'test'
30
48
  test.test_files = FileList["test/integration/**/*_test.rb"]
31
- test.deps = [ :wait_for_green, :spec ]
49
+ test.deps = [ 'test:wait_for_green', 'test:spec' ]
32
50
  test.verbose = false
33
51
  test.warning = false
34
52
  end
35
53
 
36
54
  Rake::TestTask.new(:all) do |test|
37
- test.deps = [ :unit, :integration ]
55
+ test.libs << 'lib' << 'test'
56
+ test.test_files = FileList["test/unit/**/*_test.rb", "test/integration/**/*_test.rb"]
38
57
  end
39
58
 
40
59
  Rake::TestTask.new(:profile) do |test|