solr_wrapper 0.17.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +8 -7
- data/exe/solr_wrapper +20 -14
- data/lib/solr_wrapper/configuration.rb +15 -1
- data/lib/solr_wrapper/downloader.rb +1 -1
- data/lib/solr_wrapper/instance.rb +9 -9
- data/lib/solr_wrapper/md5.rb +2 -2
- data/lib/solr_wrapper/settings.rb +7 -3
- data/lib/solr_wrapper/version.rb +1 -1
- data/lib/solr_wrapper.rb +1 -1
- data/solr_wrapper.gemspec +1 -1
- data/spec/lib/solr_wrapper/client_spec.rb +5 -5
- data/spec/lib/solr_wrapper/configuration_spec.rb +22 -0
- data/spec/lib/solr_wrapper/instance_spec.rb +5 -1
- data/spec/spec_helper.rb +3 -1
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: '092270d968ea024833bc6185caf854c05c8e623e'
|
|
4
|
+
data.tar.gz: 83d3dd71ca0de7c18ee9090a06ff051b174dbf4a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c4da5d83939b7d10b089d4453b79fb778aa499809cbd114d634fe8e7e790a21896c73320055fa43d3682559768fcb5729f2062bde7ab1ee9beeb92e967c1cf50
|
|
7
|
+
data.tar.gz: c7373e52dcd5520e541947655b1e95c6fcd53e9ccf7b356d7bf2efa37f60bb36555508451bc46546c92b3b1899859040453072802e54ba9fd59238fed106553d
|
data/.travis.yml
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
language: ruby
|
|
2
2
|
sudo: false
|
|
3
3
|
rvm:
|
|
4
|
-
- 2.
|
|
5
|
-
- 2.3.
|
|
6
|
-
- jruby-9.1.
|
|
7
|
-
cache:
|
|
8
|
-
directories:
|
|
9
|
-
- /tmp/solr-5.4.1
|
|
4
|
+
- 2.4.1
|
|
5
|
+
- 2.3.4
|
|
6
|
+
- jruby-9.1.8.0
|
|
10
7
|
|
|
11
8
|
jdk:
|
|
12
|
-
- oraclejdk8
|
|
9
|
+
- oraclejdk8
|
|
10
|
+
|
|
11
|
+
env:
|
|
12
|
+
global:
|
|
13
|
+
JRUBY_OPTS=-J-Xmx2g
|
data/exe/solr_wrapper
CHANGED
|
@@ -8,6 +8,7 @@ collection_options = {}
|
|
|
8
8
|
subtext = <<HELP
|
|
9
9
|
Commonly used command are:
|
|
10
10
|
clean : cleans all data from solr and configures a clean instance based on configuration options
|
|
11
|
+
dir : prints the solr instance dir
|
|
11
12
|
See 'solr_wrapper COMMAND --help' for more information on a specific command.
|
|
12
13
|
HELP
|
|
13
14
|
|
|
@@ -75,6 +76,9 @@ subcommands = {
|
|
|
75
76
|
'clean' => OptionParser.new do |opts|
|
|
76
77
|
opts.banner = "Usage: clean"
|
|
77
78
|
end,
|
|
79
|
+
'dir' => OptionParser.new do |opts|
|
|
80
|
+
opts.banner = "Usage: dir"
|
|
81
|
+
end,
|
|
78
82
|
}
|
|
79
83
|
|
|
80
84
|
|
|
@@ -94,26 +98,28 @@ end
|
|
|
94
98
|
|
|
95
99
|
instance = SolrWrapper.instance(options)
|
|
96
100
|
|
|
97
|
-
|
|
101
|
+
case command
|
|
102
|
+
when 'clean'
|
|
98
103
|
if instance.started?
|
|
99
104
|
$stderr.puts "Please stop solr before cleaning"
|
|
100
105
|
exit 1
|
|
101
106
|
end
|
|
102
107
|
$stderr.puts "cleaning #{instance.instance_dir}..."
|
|
103
108
|
instance.remove_instance_dir!
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
$stderr.print "Starting Solr #{instance.version} on port #{instance.port} ... "
|
|
108
|
-
instance.wrap do |conn|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
109
|
+
when 'dir'
|
|
110
|
+
puts instance.instance_dir
|
|
111
|
+
else
|
|
112
|
+
$stderr.print "Starting Solr #{instance.version} on port #{instance.port} ... "
|
|
113
|
+
instance.wrap do |conn|
|
|
114
|
+
conn.with_collection(collection_options) do
|
|
115
|
+
$stderr.puts "http://#{instance.host}:#{instance.port}/solr/"
|
|
116
|
+
begin
|
|
117
|
+
conn.wait
|
|
118
|
+
rescue Interrupt
|
|
119
|
+
Signal.trap("SIGTERM") {"IGNORE"}
|
|
120
|
+
Signal.trap("SIGINT") {"IGNORE"}
|
|
121
|
+
$stderr.puts "Solr is shutting down."
|
|
122
|
+
end
|
|
117
123
|
end
|
|
118
124
|
end
|
|
119
125
|
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
require 'faraday'
|
|
2
|
+
|
|
1
3
|
module SolrWrapper
|
|
2
4
|
class Configuration
|
|
3
5
|
attr_reader :options
|
|
@@ -77,7 +79,14 @@ module SolrWrapper
|
|
|
77
79
|
end
|
|
78
80
|
|
|
79
81
|
def version
|
|
80
|
-
@version ||=
|
|
82
|
+
@version ||= begin
|
|
83
|
+
config_version = options.fetch(:version, SolrWrapper.default_instance_options[:version])
|
|
84
|
+
if config_version == 'latest'
|
|
85
|
+
fetch_latest_version
|
|
86
|
+
else
|
|
87
|
+
config_version
|
|
88
|
+
end
|
|
89
|
+
end
|
|
81
90
|
end
|
|
82
91
|
|
|
83
92
|
def mirror_url
|
|
@@ -145,5 +154,10 @@ module SolrWrapper
|
|
|
145
154
|
def default_configuration_paths
|
|
146
155
|
['~/.solr_wrapper.yml', '~/.solr_wrapper', '.solr_wrapper.yml', '.solr_wrapper']
|
|
147
156
|
end
|
|
157
|
+
|
|
158
|
+
def fetch_latest_version
|
|
159
|
+
response = Faraday.get('https://svn.apache.org/repos/asf/lucene/cms/trunk/content/latestversion.mdtext')
|
|
160
|
+
response.body.strip
|
|
161
|
+
end
|
|
148
162
|
end
|
|
149
163
|
end
|
|
@@ -8,7 +8,7 @@ module SolrWrapper
|
|
|
8
8
|
IO.copy_stream(io, output)
|
|
9
9
|
end
|
|
10
10
|
rescue OpenURI::HTTPError => e
|
|
11
|
-
raise SolrWrapperError, "Unable to download solr from #{url}\n#{e.message}"
|
|
11
|
+
raise SolrWrapperError, "Unable to download solr from #{url}\n#{e.message}: #{e.io.read}"
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
class SafeProgressBar < ProgressBar::Base
|
|
@@ -221,16 +221,16 @@ module SolrWrapper
|
|
|
221
221
|
def clean!
|
|
222
222
|
stop
|
|
223
223
|
remove_instance_dir!
|
|
224
|
-
FileUtils.remove_entry(config.download_dir, true) if File.
|
|
225
|
-
FileUtils.remove_entry(config.tmp_save_dir, true) if File.
|
|
224
|
+
FileUtils.remove_entry(config.download_dir, true) if File.exist?(config.download_dir)
|
|
225
|
+
FileUtils.remove_entry(config.tmp_save_dir, true) if File.exist? config.tmp_save_dir
|
|
226
226
|
md5.clean!
|
|
227
|
-
FileUtils.remove_entry(config.version_file) if File.
|
|
227
|
+
FileUtils.remove_entry(config.version_file) if File.exist? config.version_file
|
|
228
228
|
end
|
|
229
229
|
|
|
230
230
|
##
|
|
231
231
|
# Clean up any files in the Solr instance dir
|
|
232
232
|
def remove_instance_dir!
|
|
233
|
-
FileUtils.remove_entry(instance_dir, true) if File.
|
|
233
|
+
FileUtils.remove_entry(instance_dir, true) if File.exist? instance_dir
|
|
234
234
|
end
|
|
235
235
|
|
|
236
236
|
def configure
|
|
@@ -278,18 +278,18 @@ module SolrWrapper
|
|
|
278
278
|
|
|
279
279
|
config.instance_dir
|
|
280
280
|
ensure
|
|
281
|
-
FileUtils.remove_entry config.tmp_save_dir if File.
|
|
281
|
+
FileUtils.remove_entry config.tmp_save_dir if File.exist? config.tmp_save_dir
|
|
282
282
|
end
|
|
283
283
|
# rubocop:enable Lint/RescueException
|
|
284
284
|
|
|
285
285
|
protected
|
|
286
286
|
|
|
287
287
|
def extracted?
|
|
288
|
-
File.
|
|
288
|
+
File.exist?(config.solr_binary) && extracted_version == config.version
|
|
289
289
|
end
|
|
290
290
|
|
|
291
291
|
def download
|
|
292
|
-
unless File.
|
|
292
|
+
unless File.exist?(config.solr_zip_path) && md5.validate?(config.solr_zip_path)
|
|
293
293
|
Downloader.fetch_with_progressbar config.download_url, config.solr_zip_path
|
|
294
294
|
md5.validate! config.solr_zip_path
|
|
295
295
|
end
|
|
@@ -353,7 +353,7 @@ module SolrWrapper
|
|
|
353
353
|
|
|
354
354
|
stringio.rewind
|
|
355
355
|
if exit_status != 0 && cmd != 'status'
|
|
356
|
-
raise "Failed to execute solr #{cmd}: #{stringio.read}"
|
|
356
|
+
raise "Failed to execute solr #{cmd}: #{stringio.read}. Further information may be available in #{instance_dir}/logs"
|
|
357
357
|
end
|
|
358
358
|
|
|
359
359
|
stringio
|
|
@@ -372,7 +372,7 @@ module SolrWrapper
|
|
|
372
372
|
end
|
|
373
373
|
|
|
374
374
|
def extracted_version
|
|
375
|
-
File.read(config.version_file).strip if File.
|
|
375
|
+
File.read(config.version_file).strip if File.exist? config.version_file
|
|
376
376
|
end
|
|
377
377
|
|
|
378
378
|
def extracted_version=(version)
|
data/lib/solr_wrapper/md5.rb
CHANGED
|
@@ -6,7 +6,7 @@ module SolrWrapper
|
|
|
6
6
|
end
|
|
7
7
|
|
|
8
8
|
def clean!
|
|
9
|
-
FileUtils.remove_entry(config.md5sum_path) if File.
|
|
9
|
+
FileUtils.remove_entry(config.md5sum_path) if File.exist? config.md5sum_path
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
def validate?(file)
|
|
@@ -33,7 +33,7 @@ module SolrWrapper
|
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
def md5file
|
|
36
|
-
unless File.
|
|
36
|
+
unless File.exist? config.md5sum_path
|
|
37
37
|
Downloader.fetch_with_progressbar config.md5url, config.md5sum_path
|
|
38
38
|
end
|
|
39
39
|
|
|
@@ -56,7 +56,7 @@ module SolrWrapper
|
|
|
56
56
|
end
|
|
57
57
|
|
|
58
58
|
def managed?
|
|
59
|
-
File.
|
|
59
|
+
File.exist?(instance_dir)
|
|
60
60
|
end
|
|
61
61
|
|
|
62
62
|
def download_url
|
|
@@ -74,7 +74,11 @@ module SolrWrapper
|
|
|
74
74
|
end
|
|
75
75
|
|
|
76
76
|
def md5url
|
|
77
|
-
|
|
77
|
+
if default_download_url == archive_download_url
|
|
78
|
+
"#{archive_download_url}.md5"
|
|
79
|
+
else
|
|
80
|
+
"http://www.us.apache.org/dist/lucene/solr/#{static_config.version}/solr-#{static_config.version}.zip.md5"
|
|
81
|
+
end
|
|
78
82
|
end
|
|
79
83
|
|
|
80
84
|
def md5sum_path
|
|
@@ -128,7 +132,7 @@ module SolrWrapper
|
|
|
128
132
|
end
|
|
129
133
|
|
|
130
134
|
def archive_download_url
|
|
131
|
-
"
|
|
135
|
+
"https://archive.apache.org/dist/lucene/solr/#{static_config.version}/solr-#{static_config.version}.zip"
|
|
132
136
|
end
|
|
133
137
|
|
|
134
138
|
def random_open_port
|
data/lib/solr_wrapper/version.rb
CHANGED
data/lib/solr_wrapper.rb
CHANGED
data/solr_wrapper.gemspec
CHANGED
|
@@ -28,5 +28,5 @@ Gem::Specification.new do |spec|
|
|
|
28
28
|
spec.add_development_dependency "rspec"
|
|
29
29
|
spec.add_development_dependency "simple_solr_client"
|
|
30
30
|
spec.add_development_dependency "coveralls"
|
|
31
|
-
spec.add_development_dependency "
|
|
31
|
+
spec.add_development_dependency "webmock"
|
|
32
32
|
end
|
|
@@ -5,18 +5,18 @@ describe SolrWrapper::Client do
|
|
|
5
5
|
|
|
6
6
|
describe '#exists?' do
|
|
7
7
|
it 'checks if a solrcloud collection exists' do
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
stub_request(:get, 'http://localhost:8983/solr/admin/collections?action=LIST&wt=json').to_return(body: '{ "collections": ["x", "y", "z"]}')
|
|
9
|
+
stub_request(:get, 'http://localhost:8983/solr/admin/cores?action=STATUS&wt=json&core=a').to_return(body: '{ "status": { "a": {} } }')
|
|
10
10
|
|
|
11
11
|
expect(subject.exists?('x')).to eq true
|
|
12
12
|
expect(subject.exists?('a')).to eq false
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
it 'checks if a solr core exists' do
|
|
16
|
-
|
|
16
|
+
stub_request(:get, 'http://localhost:8983/solr/admin/collections?action=LIST&wt=json').to_return(body: '{ "error": { "msg": "Solr instance is not running in SolrCloud mode."} }')
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
stub_request(:get, 'http://localhost:8983/solr/admin/cores?action=STATUS&wt=json&core=x').to_return(body: '{ "status": { "x": { "name": "x" } } }')
|
|
19
|
+
stub_request(:get, 'http://localhost:8983/solr/admin/cores?action=STATUS&wt=json&core=a').to_return(body: '{ "status": { "a": {} } }')
|
|
20
20
|
|
|
21
21
|
expect(subject.exists?('x')).to eq true
|
|
22
22
|
expect(subject.exists?('a')).to eq false
|
|
@@ -61,4 +61,26 @@ describe SolrWrapper::Configuration do
|
|
|
61
61
|
expect(config.configsets).to include(name: 'project-development-configset', dir: 'solr/config/')
|
|
62
62
|
end
|
|
63
63
|
end
|
|
64
|
+
|
|
65
|
+
describe '#version' do
|
|
66
|
+
context 'when it is a version number' do
|
|
67
|
+
let(:options) { { version: 'x.y.z' } }
|
|
68
|
+
|
|
69
|
+
it 'uses that version' do
|
|
70
|
+
expect(config.version).to eq 'x.y.z'
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
context 'when it is "latest"' do
|
|
75
|
+
let(:options) { { version: 'latest'} }
|
|
76
|
+
|
|
77
|
+
before do
|
|
78
|
+
stub_request(:get, 'https://svn.apache.org/repos/asf/lucene/cms/trunk/content/latestversion.mdtext').to_return(body: 'z.y.x')
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
it 'fetches the latest version number from apache' do
|
|
82
|
+
expect(config.version).to eq 'z.y.x'
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
64
86
|
end
|
|
@@ -151,8 +151,12 @@ describe SolrWrapper::Instance do
|
|
|
151
151
|
end
|
|
152
152
|
|
|
153
153
|
describe "#version" do
|
|
154
|
+
before do
|
|
155
|
+
allow(solr_instance.config).to receive(:version).and_return('solr-version-number')
|
|
156
|
+
end
|
|
157
|
+
|
|
154
158
|
subject { solr_instance.version }
|
|
155
|
-
it { is_expected.to eq '
|
|
159
|
+
it { is_expected.to eq 'solr-version-number' }
|
|
156
160
|
end
|
|
157
161
|
|
|
158
162
|
describe "#md5" do
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: solr_wrapper
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 1.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Chris Beer
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2017-04-27 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: faraday
|
|
@@ -123,7 +123,7 @@ dependencies:
|
|
|
123
123
|
- !ruby/object:Gem::Version
|
|
124
124
|
version: '0'
|
|
125
125
|
- !ruby/object:Gem::Dependency
|
|
126
|
-
name:
|
|
126
|
+
name: webmock
|
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
|
128
128
|
requirements:
|
|
129
129
|
- - ">="
|
|
@@ -202,7 +202,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
202
202
|
version: '0'
|
|
203
203
|
requirements: []
|
|
204
204
|
rubyforge_project:
|
|
205
|
-
rubygems_version: 2.
|
|
205
|
+
rubygems_version: 2.6.8
|
|
206
206
|
signing_key:
|
|
207
207
|
specification_version: 4
|
|
208
208
|
summary: Solr 5 service wrapper
|