elasticsearch-extensions 0.0.31 → 0.0.32

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
  module Elasticsearch
2
19
  module Extensions
3
20
  module Test
@@ -1,5 +1,22 @@
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
  module Elasticsearch
2
19
  module Extensions
3
- VERSION = "0.0.31"
20
+ VERSION = '0.0.32'.freeze
4
21
  end
5
22
  end
@@ -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 'test_helper'
2
19
  require 'elasticsearch/extensions/ansi'
3
20
 
@@ -7,10 +24,10 @@ class Elasticsearch::Extensions::AnsiTest < Elasticsearch::Test::UnitTestCase
7
24
  @client = Elasticsearch::Client.new
8
25
  @client.stubs(:perform_request).returns \
9
26
  Elasticsearch::Transport::Transport::Response.new(200, { "ok" => true, "status" => 200, "name" => "Hit-Maker",
10
- "version" => { "number" => "0.90.7",
11
- "build_hash" => "abc123",
12
- "build_timestamp"=>"2013-11-13T12:06:54Z", "build_snapshot"=>false, "lucene_version"=>"4.5.1" },
13
- "tagline"=>"You Know, for Search" })
27
+ "version" => { "number" => "0.90.7",
28
+ "build_hash" => "abc123",
29
+ "build_timestamp"=>"2013-11-13T12:06:54Z", "build_snapshot"=>false, "lucene_version"=>"4.5.1" },
30
+ "tagline"=>"You Know, for Search" })
14
31
  end
15
32
 
16
33
  should "wrap the response" do
@@ -30,7 +47,7 @@ class Elasticsearch::Extensions::AnsiTest < Elasticsearch::Test::UnitTestCase
30
47
  should "call the 'awesome_inspect' method when available and no handler found" do
31
48
  @client.stubs(:perform_request).returns \
32
49
  Elasticsearch::Transport::Transport::Response.new(200, {"index-1"=>{"aliases"=>{}}})
33
- response = @client.indices.get_aliases
50
+ response = @client.cat.aliases
34
51
 
35
52
  response.instance_eval do
36
53
  def awesome_inspect; "---PRETTY---"; end
@@ -41,7 +58,7 @@ class Elasticsearch::Extensions::AnsiTest < Elasticsearch::Test::UnitTestCase
41
58
  should "call `to_s` method when no pretty printer or handler found" do
42
59
  @client.stubs(:perform_request).returns \
43
60
  Elasticsearch::Transport::Transport::Response.new(200, {"index-1"=>{"aliases"=>{}}})
44
- response = @client.indices.get_aliases
61
+ response = @client.cat.aliases
45
62
 
46
63
  assert_equal '{"index-1"=>{"aliases"=>{}}}', response.to_ansi
47
64
  end
@@ -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 'test_helper'
2
19
  require 'logger'
3
20
 
@@ -106,5 +123,9 @@ class Elasticsearch::Extensions::BackupTest < Elasticsearch::Test::UnitTestCase
106
123
 
107
124
  @subject.__perform_single
108
125
  end
126
+
127
+ should "sanitize filename" do
128
+ assert_equal "foo-bar-baz", @subject.__sanitize_filename("foo/bar\nbaz")
129
+ end
109
130
  end
110
131
  end
@@ -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 'test_helper'
2
19
  require 'elasticsearch/extensions/reindex'
3
20
 
@@ -17,7 +34,7 @@ class Elasticsearch::Extensions::ReindexIntegrationTest < Elasticsearch::Test::I
17
34
  ANSI.ansi(severity[0] + ' ', color, :faint) + ANSI.ansi(msg, :white, :faint) + "\n"
18
35
  end
19
36
 
20
- @client = Elasticsearch::Client.new host: "localhost:#{@port}", logger: @logger
37
+ @client = Elasticsearch::Client.new host: "#{TEST_HOST}:#{TEST_PORT}", logger: @logger
21
38
  @client.indices.delete index: '_all'
22
39
 
23
40
  @client.index index: 'test1', type: 'd', id: 1, body: { title: 'TEST 1', category: 'one' }
@@ -37,53 +54,53 @@ class Elasticsearch::Extensions::ReindexIntegrationTest < Elasticsearch::Test::I
37
54
  should "copy documents from one index to another" do
38
55
  reindex = Elasticsearch::Extensions::Reindex.new \
39
56
  source: { index: 'test1', client: @client },
40
- target: { index: 'test2' },
57
+ dest: { index: 'test2' },
41
58
  batch_size: 2,
42
59
  refresh: true
43
60
 
44
61
  result = reindex.perform
45
62
 
46
63
  assert_equal 0, result[:errors]
47
- assert_equal 3, @client.search(index: 'test2')['hits']['total']
64
+ assert_equal 3, @client.search(index: 'test2')['hits']['total']['value']
48
65
  end
49
66
 
50
67
  should "transform documents with a lambda" do
51
68
  reindex = Elasticsearch::Extensions::Reindex.new \
52
69
  source: { index: 'test1', client: @client },
53
- target: { index: 'test2' },
70
+ dest: { index: 'test2' },
54
71
  transform: lambda { |d| d['_source']['category'].upcase! },
55
72
  refresh: true
56
73
 
57
74
  result = reindex.perform
58
75
 
59
76
  assert_equal 0, result[:errors]
60
- assert_equal 3, @client.search(index: 'test2')['hits']['total']
77
+ assert_equal 3, @client.search(index: 'test2')['hits']['total']['value']
61
78
  assert_equal 'ONE', @client.get(index: 'test2', type: 'd', id: 1)['_source']['category']
62
79
  end
63
80
 
64
81
  should "return the number of errors" do
65
- @client.indices.create index: 'test3', body: { mappings: { d: { properties: { category: { type: 'integer' } }}}}
82
+ @client.indices.create index: 'test3', body: { mappings: { properties: { category: { type: 'integer' } }}}
66
83
  @client.cluster.health wait_for_status: 'yellow'
67
84
 
68
85
  reindex = Elasticsearch::Extensions::Reindex.new \
69
86
  source: { index: 'test1', client: @client },
70
- target: { index: 'test3' }
87
+ dest: { index: 'test3' }
71
88
 
72
89
  result = reindex.perform
73
90
 
74
91
  @client.indices.refresh index: 'test3'
75
92
 
76
93
  assert_equal 3, result[:errors]
77
- assert_equal 0, @client.search(index: 'test3')['hits']['total']
94
+ assert_equal 0, @client.search(index: 'test3')['hits']['total']['value']
78
95
  end
79
96
 
80
97
  should "reindex via the API integration" do
81
98
  @client.indices.create index: 'test4'
82
99
 
83
- @client.reindex source: { index: 'test1' }, target: { index: 'test4' }
100
+ @client.reindex source: { index: 'test1' }, dest: { index: 'test4' }
84
101
  @client.indices.refresh index: 'test4'
85
102
 
86
- assert_equal 3, @client.search(index: 'test4')['hits']['total']
103
+ assert_equal 3, @client.search(index: 'test4')['hits']['total']['value']
87
104
  end
88
105
  end
89
106
 
@@ -1,9 +1,26 @@
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 'test_helper'
2
19
  require 'elasticsearch/extensions/reindex'
3
20
 
4
21
  class Elasticsearch::Extensions::ReindexTest < Elasticsearch::Test::UnitTestCase
5
22
  context "The Reindex extension module" do
6
- DEFAULT_OPTIONS = { source: { index: 'foo', client: Object.new }, target: { index: 'bar' } }
23
+ DEFAULT_OPTIONS = { source: { index: 'foo', client: Object.new }, dest: { index: 'bar' } }
7
24
 
8
25
  should "require options" do
9
26
  assert_raise ArgumentError do
@@ -50,7 +67,7 @@ class Elasticsearch::Extensions::ReindexTest < Elasticsearch::Test::UnitTestCase
50
67
  should "scroll through the index and save batches in bulk" do
51
68
  client = mock()
52
69
  subject = Elasticsearch::Extensions::Reindex.new source: { index: 'foo', client: client },
53
- target: { index: 'bar' }
70
+ dest: { index: 'bar' }
54
71
 
55
72
  client.expects(:search)
56
73
  .returns({ '_scroll_id' => 'scroll_id_1' }.merge(Marshal.load(Marshal.dump(@default_response))))
@@ -70,7 +87,7 @@ class Elasticsearch::Extensions::ReindexTest < Elasticsearch::Test::UnitTestCase
70
87
  should "return the number of errors" do
71
88
  client = mock()
72
89
  subject = Elasticsearch::Extensions::Reindex.new source: { index: 'foo', client: client },
73
- target: { index: 'bar' }
90
+ dest: { index: 'bar' }
74
91
 
75
92
  client.expects(:search).returns({ '_scroll_id' => 'scroll_id_1' }.merge(@default_response))
76
93
  client.expects(:scroll).returns(@empty_response)
@@ -85,7 +102,7 @@ class Elasticsearch::Extensions::ReindexTest < Elasticsearch::Test::UnitTestCase
85
102
  client = mock()
86
103
  subject = Elasticsearch::Extensions::Reindex.new \
87
104
  source: { index: 'foo', client: client },
88
- target: { index: 'bar' },
105
+ dest: { index: 'bar' },
89
106
  transform: lambda { |d| d['_source']['foo'].upcase!; d }
90
107
 
91
108
  client.expects(:search).returns({ '_scroll_id' => 'scroll_id_1' }.merge(@default_response))
@@ -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 'test_helper'
2
19
  require 'pathname'
3
20
 
@@ -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 'test_helper'
2
19
 
3
20
  require 'elasticsearch/extensions/test/cluster'
@@ -274,6 +291,24 @@ class Elasticsearch::Extensions::TestClusterTest < Elasticsearch::Test::UnitTest
274
291
  assert_equal '2.0', @subject.__determine_version
275
292
  end
276
293
 
294
+ should "return version from `elasticsearch --version` when version reaches double digits" do
295
+ File.expects(:exist?).with('/foo/bar/bin/../lib/').returns(false)
296
+ File.expects(:exist?).with('/foo/bar/bin/elasticsearch').returns(true)
297
+
298
+ io = mock('IO')
299
+ io.expects(:pid).returns(123)
300
+ io.expects(:read).returns('Version: 7.11.0-SNAPSHOT, Build: d1c86b0/2016-03-30T10:43:20Z, JVM: 1.8.0_60')
301
+ io.expects(:closed?).returns(false)
302
+ io.expects(:close)
303
+ IO.expects(:popen).returns(io)
304
+
305
+ Process.stubs(:wait)
306
+ Process.expects(:kill).with('INT', 123)
307
+
308
+ assert_equal '7.0', @subject.__determine_version
309
+ end
310
+
311
+
277
312
  should "return version from arguments" do
278
313
  cluster = Elasticsearch::Extensions::Test::Cluster::Cluster.new command: '/foo/bar/bin/elasticsearch', version: '5.2'
279
314
  assert_equal '5.0', cluster.__determine_version
@@ -1,6 +1,31 @@
1
- JRUBY = defined?(JRUBY_VERSION)
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.
2
17
 
3
- if ENV['COVERAGE'] && ENV['CI'].nil? && !RUBY_1_8
18
+ ELASTICSEARCH_HOSTS = if (hosts = ENV['TEST_ES_SERVER'] || ENV['ELASTICSEARCH_HOSTS'])
19
+ hosts.split(',').map do |host|
20
+ /(http\:\/\/)?(\S+)/.match(host)[2]
21
+ end
22
+ end.freeze
23
+
24
+ TEST_HOST, TEST_PORT = ELASTICSEARCH_HOSTS.first.split(':') if ELASTICSEARCH_HOSTS
25
+
26
+ JRUBY = defined?(JRUBY_VERSION)
27
+
28
+ if ENV['COVERAGE'] && ENV['CI'].nil?
4
29
  require 'simplecov'
5
30
  SimpleCov.start { add_filter "/test|test_" }
6
31
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elasticsearch-extensions
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.31
4
+ version: 0.0.32
5
5
  platform: ruby
6
6
  authors:
7
7
  - Karel Minarik
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-06 00:00:00.000000000 Z
11
+ date: 2020-12-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ansi
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '11.1'
75
+ version: '12.3'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '11.1'
82
+ version: '12.3'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: awesome_print
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -126,30 +126,30 @@ dependencies:
126
126
  name: minitest
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - ">="
129
+ - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: '0'
131
+ version: '5'
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - ">="
136
+ - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: '0'
138
+ version: '5'
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: minitest-reporters
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - ">="
143
+ - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: '0'
145
+ version: '1'
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
- - - ">="
150
+ - - "~>"
151
151
  - !ruby/object:Gem::Version
152
- version: '0'
152
+ version: '1'
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: simplecov
155
155
  requirement: !ruby/object:Gem::Requirement
@@ -267,10 +267,14 @@ files:
267
267
  - test/test/cluster/integration/cluster_test.rb
268
268
  - test/test/cluster/unit/cluster_test.rb
269
269
  - test/test_helper.rb
270
- homepage: https://github.com/elasticsearch/elasticsearch-ruby/tree/master/elasticsearch-extensions
270
+ homepage: https://www.elastic.co/guide/en/elasticsearch/client/ruby-api/current/index.html
271
271
  licenses:
272
- - Apache 2
273
- metadata: {}
272
+ - Apache-2.0
273
+ metadata:
274
+ homepage_uri: https://www.elastic.co/guide/en/elasticsearch/client/ruby-api/current/index.html
275
+ changelog_uri: https://github.com/elastic/elasticsearch-ruby/blob/master/CHANGELOG.md
276
+ source_code_uri: https://github.com/elastic/elasticsearch-ruby/tree/master/elasticsearch-extensions
277
+ bug_tracker_uri: https://github.com/elastic/elasticsearch-ruby/issues
274
278
  post_install_message:
275
279
  rdoc_options: []
276
280
  require_paths:
@@ -286,8 +290,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
286
290
  - !ruby/object:Gem::Version
287
291
  version: '0'
288
292
  requirements: []
289
- rubyforge_project:
290
- rubygems_version: 2.7.7
293
+ rubygems_version: 3.1.2
291
294
  signing_key:
292
295
  specification_version: 4
293
296
  summary: Extensions for the Elasticsearch Rubygem