From 41fa055544709b2a3bea9b31d3dac7065d9b58a1 Mon Sep 17 00:00:00 2001 From: Chris Beer Date: Wed, 4 Mar 2026 08:34:56 -0800 Subject: [PATCH 1/7] Support Solr 10 --- lib/solr_wrapper/checksum_validator.rb | 2 +- lib/solr_wrapper/configuration.rb | 2 +- lib/solr_wrapper/instance.rb | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/solr_wrapper/checksum_validator.rb b/lib/solr_wrapper/checksum_validator.rb index df74be8..a0bc243 100644 --- a/lib/solr_wrapper/checksum_validator.rb +++ b/lib/solr_wrapper/checksum_validator.rb @@ -61,7 +61,7 @@ def checksumfile(alg) def algorithm return config.static_config.algorithm if config.static_config.algorithm - return 'sha1' if config.static_config.version =~ /^[1-6]/ || config.static_config.version =~ /^[7]\.[0-4]/ + return 'sha1' if config.static_config.version =~ /^[1-6]\./ || config.static_config.version =~ /^[7]\.[0-4]/ 'sha512' end diff --git a/lib/solr_wrapper/configuration.rb b/lib/solr_wrapper/configuration.rb index 7fbb60e..97a0860 100644 --- a/lib/solr_wrapper/configuration.rb +++ b/lib/solr_wrapper/configuration.rb @@ -101,7 +101,7 @@ def version end def mirror_artifact_path - if version > '9' + if version > '9' || version.start_with?(/1\d/) "solr/solr/#{version}/solr-#{version}.tgz" else "lucene/solr/#{version}/solr-#{version}.tgz" diff --git a/lib/solr_wrapper/instance.rb b/lib/solr_wrapper/instance.rb index f91ccfe..13104d8 100644 --- a/lib/solr_wrapper/instance.rb +++ b/lib/solr_wrapper/instance.rb @@ -72,7 +72,7 @@ def wrap(&_block) def start extract_and_configure if managed? - exec('start', p: port, c: config.cloud) + exec('start', p: port, **(extracted_version.start_with?(/1\d/) ? {} : { c: config.cloud })) @started = true @@ -98,7 +98,7 @@ def stop # Stop Solr and wait for it to finish exiting def restart if managed? && started? - exec('restart', p: port, c: config.cloud) + exec('restart', p: port, **(extracted_version.start_with?(/1\d/) ? {} : { c: config.cloud })) end end From 19313761044cb01c06b6b9acead0299a35e33655 Mon Sep 17 00:00:00 2001 From: Chris Beer Date: Wed, 4 Mar 2026 10:40:36 -0800 Subject: [PATCH 2/7] Test with java 21. --- .github/workflows/ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a144f38..9963450 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,6 +25,10 @@ jobs: SOLR_WRAPPER_SOLR_VERSION: ${{ matrix.solr_version }} steps: - uses: actions/checkout@v3 + - uses: actions/setup-java@v5 + with: + distribution: 'temurin' + java-version: '21' - name: Set up Ruby uses: ruby/setup-ruby@v1 with: From e64f787dc8cdf181d74c50c3b5d95ddd20f58ed6 Mon Sep 17 00:00:00 2001 From: Chris Beer Date: Wed, 4 Mar 2026 15:45:15 -0800 Subject: [PATCH 3/7] Update test schema. --- spec/fixtures/basic_configs/schema.xml | 531 ++++++++++--------------- 1 file changed, 204 insertions(+), 327 deletions(-) diff --git a/spec/fixtures/basic_configs/schema.xml b/spec/fixtures/basic_configs/schema.xml index d7f86b7..f8aed3d 100644 --- a/spec/fixtures/basic_configs/schema.xml +++ b/spec/fixtures/basic_configs/schema.xml @@ -17,20 +17,29 @@ --> - - - + 1.6: useDocValuesAsStored defaults to true. + 1.7: docValues defaults to true, uninvertible defaults to false. + --> - + --> - + --> + + - - + + + - - + + + + + - - + - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - id + --> + id - + + + --> - - - - - - - + + - These fields support doc values, but they require the field to be - single-valued and either be required or have a default value. - --> - - - - + + + - - - - + + + + + + + + + + + + + - - - - - + + + - - + + + - + - - - - - - - - - - - - - - - - - + removes stop words from case-insensitive "stopwords.txt" + (empty by default), and down cases. At query time only, it + also applies synonyms. + --> + - + - - - - - - - + - - - - - - - - + + - - - - - - - - - - - - - - - - - - - - + + + + + - - + + + - - - - - - - - - + + - - + + + - - - - + - - - - + - - - - - - - - - - - + + + + + - - - - - - - + + - - - + - + + + - - - - - - - + geo="true" distErrPct="0.025" maxDistErr="0.001" distanceUnits="kilometers" /> + + + + + + + + + + + + + + + + + + + From 78e05b59ec01deb627e2b5c430d04ab7d33d7826 Mon Sep 17 00:00:00 2001 From: Chris Beer Date: Thu, 5 Mar 2026 14:03:08 -0800 Subject: [PATCH 4/7] Update faraday --- lib/solr_wrapper/configuration.rb | 2 +- lib/solr_wrapper/downloader.rb | 2 +- solr_wrapper.gemspec | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/solr_wrapper/configuration.rb b/lib/solr_wrapper/configuration.rb index 97a0860..3b41d9b 100644 --- a/lib/solr_wrapper/configuration.rb +++ b/lib/solr_wrapper/configuration.rb @@ -118,7 +118,7 @@ def mirror_url else begin client = Faraday.new(closest_mirror_url) do |faraday| - faraday.use Faraday::FollowRedirects::Middleware + faraday.response :follow_redirects faraday.adapter Faraday.default_adapter end diff --git a/lib/solr_wrapper/downloader.rb b/lib/solr_wrapper/downloader.rb index b9074a0..f81a7c4 100644 --- a/lib/solr_wrapper/downloader.rb +++ b/lib/solr_wrapper/downloader.rb @@ -8,7 +8,7 @@ def self.fetch_with_progressbar(url, output) pbar = SafeProgressBar.new(title: File.basename(url), total: nil, format: '%t: |%B| %p%% (%e )') client = Faraday.new(url) do |faraday| - faraday.use Faraday::FollowRedirects::Middleware + faraday.response :follow_redirects faraday.adapter Faraday.default_adapter end diff --git a/solr_wrapper.gemspec b/solr_wrapper.gemspec index d2d92c1..0254649 100644 --- a/solr_wrapper.gemspec +++ b/solr_wrapper.gemspec @@ -18,7 +18,7 @@ Gem::Specification.new do |spec| spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"] - spec.add_dependency "faraday", ">= 1.0", "< 3" + spec.add_dependency "faraday", '~> 2.0' spec.add_dependency "faraday-follow_redirects" spec.add_dependency "minitar" spec.add_dependency "ruby-progressbar" From b831de6fa5190c71066a70f7c4317f1c53fb6165 Mon Sep 17 00:00:00 2001 From: Chris Beer Date: Thu, 5 Mar 2026 14:03:28 -0800 Subject: [PATCH 5/7] Rewrite tests to use an HTTP client directly. --- lib/solr_wrapper/client.rb | 20 +++++++++++++++----- solr_wrapper.gemspec | 1 - spec/lib/solr_wrapper/client_spec.rb | 2 ++ spec/lib/solr_wrapper/instance_spec.rb | 16 +++++----------- spec/spec_helper.rb | 1 - 5 files changed, 22 insertions(+), 18 deletions(-) diff --git a/lib/solr_wrapper/client.rb b/lib/solr_wrapper/client.rb index 3cbda6e..efc0b97 100644 --- a/lib/solr_wrapper/client.rb +++ b/lib/solr_wrapper/client.rb @@ -18,16 +18,26 @@ def exists?(core_or_collection_name) private def collection?(name) - response = Faraday.get("#{url}admin/collections?action=LIST&wt=json") - data = JSON.parse(response.body) - return if data['error'] && data['error']['msg'] == 'Solr instance is not running in SolrCloud mode.' + response = http.get("/v2/collections") + + if response.success? + JSON.parse(response.body)['collections'].include? name + else + response = http.get("/solr/admin/collections?action=LIST&wt=json") + data = JSON.parse(response.body) + return if data['error'] && data['error']['msg'] == 'Solr instance is not running in SolrCloud mode.' + data['collections'].include? name + end - data['collections'].include? name end def core?(name) - response = Faraday.get("#{url}admin/cores?action=STATUS&wt=json&core=#{name}") + response = http.get("/solr/admin/cores?action=STATUS&wt=json&core=#{name}") !JSON.parse(response.body)['status'][name].empty? end + + def http + @http ||= Faraday.new(url) + end end end diff --git a/solr_wrapper.gemspec b/solr_wrapper.gemspec index 0254649..84cc70f 100644 --- a/solr_wrapper.gemspec +++ b/solr_wrapper.gemspec @@ -29,6 +29,5 @@ Gem::Specification.new do |spec| spec.add_development_dependency "rake", ">= 12.2", "< 14" spec.add_development_dependency "rspec" - spec.add_development_dependency "simple_solr_client", "= 0.2.0" # 0.2.1 removed support for schema retrieval spec.add_development_dependency "webmock" end diff --git a/spec/lib/solr_wrapper/client_spec.rb b/spec/lib/solr_wrapper/client_spec.rb index 40dc628..cc3a24e 100644 --- a/spec/lib/solr_wrapper/client_spec.rb +++ b/spec/lib/solr_wrapper/client_spec.rb @@ -5,6 +5,7 @@ describe '#exists?' do it 'checks if a solrcloud collection exists' do + stub_request(:get, 'http://localhost:8983/v2/collections').to_return(status: 404) stub_request(:get, 'http://localhost:8983/solr/admin/collections?action=LIST&wt=json').to_return(body: '{ "collections": ["x", "y", "z"]}') stub_request(:get, 'http://localhost:8983/solr/admin/cores?action=STATUS&wt=json&core=a').to_return(body: '{ "status": { "a": {} } }') @@ -13,6 +14,7 @@ end it 'checks if a solr core exists' do + stub_request(:get, 'http://localhost:8983/v2/collections').to_return(status: 404) 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."} }') stub_request(:get, 'http://localhost:8983/solr/admin/cores?action=STATUS&wt=json&core=x').to_return(body: '{ "status": { "x": { "name": "x" } } }') diff --git a/spec/lib/solr_wrapper/instance_spec.rb b/spec/lib/solr_wrapper/instance_spec.rb index a30eee3..f5625e5 100644 --- a/spec/lib/solr_wrapper/instance_spec.rb +++ b/spec/lib/solr_wrapper/instance_spec.rb @@ -13,7 +13,9 @@ let(:options) { {} } let(:solr_instance) { SolrWrapper::Instance.new(options) } subject { solr_instance } - let(:client) { SimpleSolrClient::Client.new(subject.url) } + let(:client) do + SolrWrapper::Client.new(subject.url) + end describe "#with_collection" do let(:options) { { cloud: false } } @@ -21,11 +23,7 @@ it "creates a new anonymous collection" do subject.wrap do |solr| solr.with_collection(dir: File.join(FIXTURES_DIR, "basic_configs")) do |collection_name| - core = client.core(collection_name) - unless defined? JRUBY_VERSION - expect(core.schema.field('id').name).to eq 'id' - expect(core.schema.field('id').stored).to eq true - end + expect(client.exists?(collection_name)).to be true end end end @@ -92,11 +90,7 @@ solr.downconfig name: config_name, dir: dir end solr.with_collection(config_name: config_name) do |collection_name| - core_name = client.cores.select { |x| x =~ /^#{collection_name}/ }.first - core = client.core(core_name) - unless defined? JRUBY_VERSION - expect(core.all.size).to eq 0 - end + client.exists? collection_name end end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 0c84e73..f0b3444 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,5 +1,4 @@ require 'solr_wrapper' -require 'simple_solr_client' require 'rspec' require 'webmock/rspec' From 0c61919af65f06c4d97be4c46e560ae08a02b02b Mon Sep 17 00:00:00 2001 From: Chris Beer Date: Thu, 5 Mar 2026 14:32:10 -0800 Subject: [PATCH 6/7] help is no longer a flag in solr 10? --- spec/lib/solr_wrapper/instance_spec.rb | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/spec/lib/solr_wrapper/instance_spec.rb b/spec/lib/solr_wrapper/instance_spec.rb index f5625e5..0c40bd4 100644 --- a/spec/lib/solr_wrapper/instance_spec.rb +++ b/spec/lib/solr_wrapper/instance_spec.rb @@ -114,16 +114,8 @@ describe 'exec' do let(:cmd) { 'start' } - let(:options) { { p: '4098', help: true } } + let(:options) { { p: '4098' } } subject { solr_instance.send(:exec, cmd, options) } - it 'runs the command' do - result_io = subject - expect(result_io.read).to include('Usage: solr start') - end - it 'accepts boolean flags' do - result_io = solr_instance.send(:exec, 'start', p: '4098', help: true) - expect(result_io.read).to include('Usage: solr start') - end describe 'when something goes wrong' do let(:cmd) { 'healthcheck' } From 82c83c9edfb25814e65d91bf8c5b30851d444565 Mon Sep 17 00:00:00 2001 From: Chris Beer Date: Sat, 14 Mar 2026 07:41:01 -0700 Subject: [PATCH 7/7] Use different test configs for solr 10 --- .../_rest_managed.json | 0 .../currency.xml | 0 .../lang/stopwords_en.txt | 0 .../protwords.txt | 0 .../schema.xml | 0 .../solrconfig.xml | 0 .../stopwords.txt | 0 .../synonyms.txt | 0 .../basic_configs_v9/_rest_managed.json | 1 + spec/fixtures/basic_configs_v9/currency.xml | 67 ++ .../basic_configs_v9/lang/stopwords_en.txt | 54 ++ spec/fixtures/basic_configs_v9/protwords.txt | 21 + spec/fixtures/basic_configs_v9/schema.xml | 525 ++++++++++++++++ spec/fixtures/basic_configs_v9/solrconfig.xml | 572 ++++++++++++++++++ spec/fixtures/basic_configs_v9/stopwords.txt | 14 + spec/fixtures/basic_configs_v9/synonyms.txt | 29 + spec/lib/solr_wrapper/instance_spec.rb | 18 +- 17 files changed, 1295 insertions(+), 6 deletions(-) rename spec/fixtures/{basic_configs => basic_configs_v10}/_rest_managed.json (100%) rename spec/fixtures/{basic_configs => basic_configs_v10}/currency.xml (100%) rename spec/fixtures/{basic_configs => basic_configs_v10}/lang/stopwords_en.txt (100%) rename spec/fixtures/{basic_configs => basic_configs_v10}/protwords.txt (100%) rename spec/fixtures/{basic_configs => basic_configs_v10}/schema.xml (100%) rename spec/fixtures/{basic_configs => basic_configs_v10}/solrconfig.xml (100%) rename spec/fixtures/{basic_configs => basic_configs_v10}/stopwords.txt (100%) rename spec/fixtures/{basic_configs => basic_configs_v10}/synonyms.txt (100%) create mode 100644 spec/fixtures/basic_configs_v9/_rest_managed.json create mode 100644 spec/fixtures/basic_configs_v9/currency.xml create mode 100644 spec/fixtures/basic_configs_v9/lang/stopwords_en.txt create mode 100644 spec/fixtures/basic_configs_v9/protwords.txt create mode 100644 spec/fixtures/basic_configs_v9/schema.xml create mode 100644 spec/fixtures/basic_configs_v9/solrconfig.xml create mode 100644 spec/fixtures/basic_configs_v9/stopwords.txt create mode 100644 spec/fixtures/basic_configs_v9/synonyms.txt diff --git a/spec/fixtures/basic_configs/_rest_managed.json b/spec/fixtures/basic_configs_v10/_rest_managed.json similarity index 100% rename from spec/fixtures/basic_configs/_rest_managed.json rename to spec/fixtures/basic_configs_v10/_rest_managed.json diff --git a/spec/fixtures/basic_configs/currency.xml b/spec/fixtures/basic_configs_v10/currency.xml similarity index 100% rename from spec/fixtures/basic_configs/currency.xml rename to spec/fixtures/basic_configs_v10/currency.xml diff --git a/spec/fixtures/basic_configs/lang/stopwords_en.txt b/spec/fixtures/basic_configs_v10/lang/stopwords_en.txt similarity index 100% rename from spec/fixtures/basic_configs/lang/stopwords_en.txt rename to spec/fixtures/basic_configs_v10/lang/stopwords_en.txt diff --git a/spec/fixtures/basic_configs/protwords.txt b/spec/fixtures/basic_configs_v10/protwords.txt similarity index 100% rename from spec/fixtures/basic_configs/protwords.txt rename to spec/fixtures/basic_configs_v10/protwords.txt diff --git a/spec/fixtures/basic_configs/schema.xml b/spec/fixtures/basic_configs_v10/schema.xml similarity index 100% rename from spec/fixtures/basic_configs/schema.xml rename to spec/fixtures/basic_configs_v10/schema.xml diff --git a/spec/fixtures/basic_configs/solrconfig.xml b/spec/fixtures/basic_configs_v10/solrconfig.xml similarity index 100% rename from spec/fixtures/basic_configs/solrconfig.xml rename to spec/fixtures/basic_configs_v10/solrconfig.xml diff --git a/spec/fixtures/basic_configs/stopwords.txt b/spec/fixtures/basic_configs_v10/stopwords.txt similarity index 100% rename from spec/fixtures/basic_configs/stopwords.txt rename to spec/fixtures/basic_configs_v10/stopwords.txt diff --git a/spec/fixtures/basic_configs/synonyms.txt b/spec/fixtures/basic_configs_v10/synonyms.txt similarity index 100% rename from spec/fixtures/basic_configs/synonyms.txt rename to spec/fixtures/basic_configs_v10/synonyms.txt diff --git a/spec/fixtures/basic_configs_v9/_rest_managed.json b/spec/fixtures/basic_configs_v9/_rest_managed.json new file mode 100644 index 0000000..6a4aec3 --- /dev/null +++ b/spec/fixtures/basic_configs_v9/_rest_managed.json @@ -0,0 +1 @@ +{"initArgs":{},"managedList":[]} diff --git a/spec/fixtures/basic_configs_v9/currency.xml b/spec/fixtures/basic_configs_v9/currency.xml new file mode 100644 index 0000000..3a9c58a --- /dev/null +++ b/spec/fixtures/basic_configs_v9/currency.xml @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spec/fixtures/basic_configs_v9/lang/stopwords_en.txt b/spec/fixtures/basic_configs_v9/lang/stopwords_en.txt new file mode 100644 index 0000000..2c164c0 --- /dev/null +++ b/spec/fixtures/basic_configs_v9/lang/stopwords_en.txt @@ -0,0 +1,54 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# a couple of test stopwords to test that the words are really being +# configured from this file: +stopworda +stopwordb + +# Standard english stop words taken from Lucene's StopAnalyzer +a +an +and +are +as +at +be +but +by +for +if +in +into +is +it +no +not +of +on +or +such +that +the +their +then +there +these +they +this +to +was +will +with diff --git a/spec/fixtures/basic_configs_v9/protwords.txt b/spec/fixtures/basic_configs_v9/protwords.txt new file mode 100644 index 0000000..1dfc0ab --- /dev/null +++ b/spec/fixtures/basic_configs_v9/protwords.txt @@ -0,0 +1,21 @@ +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#----------------------------------------------------------------------- +# Use a protected word file to protect against the stemmer reducing two +# unrelated words to the same base word. + +# Some non-words that normally won't be encountered, +# just to test that they won't be stemmed. +dontstems +zwhacky + diff --git a/spec/fixtures/basic_configs_v9/schema.xml b/spec/fixtures/basic_configs_v9/schema.xml new file mode 100644 index 0000000..d7f86b7 --- /dev/null +++ b/spec/fixtures/basic_configs_v9/schema.xml @@ -0,0 +1,525 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + id + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spec/fixtures/basic_configs_v9/solrconfig.xml b/spec/fixtures/basic_configs_v9/solrconfig.xml new file mode 100644 index 0000000..f6a3954 --- /dev/null +++ b/spec/fixtures/basic_configs_v9/solrconfig.xml @@ -0,0 +1,572 @@ + + + + + + + + + 5.0.0 + + + ${solr.data.dir:} + + + + + + + + + + + + + + + + ${solr.lock.type:native} + + + true + + + + + + + + + + + + + + + + ${solr.ulog.dir:} + + + + + ${solr.autoCommit.maxTime:15000} + false + + + + + ${solr.autoSoftCommit.maxTime:-1} + + + + + + + + 1024 + + + + + + + + + + + + + + + + + + true + + + 20 + + + 200 + + + false + + + 2 + + + + + + + + + + + + + + + + + + + + explicit + 10 + + + + + + + + explicit + json + true + text + + + + + + + {!xport} + xsort + false + + + + query + + + + + + + text + + + + + + + + + + + + + + explicit + true + + + + + + + + + + + + + + true + false + + + terms + + + + + + *:* + + + diff --git a/spec/fixtures/basic_configs_v9/stopwords.txt b/spec/fixtures/basic_configs_v9/stopwords.txt new file mode 100644 index 0000000..ae1e83e --- /dev/null +++ b/spec/fixtures/basic_configs_v9/stopwords.txt @@ -0,0 +1,14 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. diff --git a/spec/fixtures/basic_configs_v9/synonyms.txt b/spec/fixtures/basic_configs_v9/synonyms.txt new file mode 100644 index 0000000..7f72128 --- /dev/null +++ b/spec/fixtures/basic_configs_v9/synonyms.txt @@ -0,0 +1,29 @@ +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#----------------------------------------------------------------------- +#some test synonym mappings unlikely to appear in real input text +aaafoo => aaabar +bbbfoo => bbbfoo bbbbar +cccfoo => cccbar cccbaz +fooaaa,baraaa,bazaaa + +# Some synonym groups specific to this example +GB,gib,gigabyte,gigabytes +MB,mib,megabyte,megabytes +Television, Televisions, TV, TVs +#notice we use "gib" instead of "GiB" so any WordDelimiterFilter coming +#after us won't split it into two words. + +# Synonym mappings can be used for spelling correction too +pixima => pixma + diff --git a/spec/lib/solr_wrapper/instance_spec.rb b/spec/lib/solr_wrapper/instance_spec.rb index 0c40bd4..029d604 100644 --- a/spec/lib/solr_wrapper/instance_spec.rb +++ b/spec/lib/solr_wrapper/instance_spec.rb @@ -17,12 +17,18 @@ SolrWrapper::Client.new(subject.url) end + let(:config_dir) do + version = solr_instance.config.version + + version.start_with?(/1\d/) ? File.join(FIXTURES_DIR, 'basic_configs_v10') : File.join(FIXTURES_DIR, 'basic_configs_v9') + end + describe "#with_collection" do let(:options) { { cloud: false } } context "without a name" do it "creates a new anonymous collection" do subject.wrap do |solr| - solr.with_collection(dir: File.join(FIXTURES_DIR, "basic_configs")) do |collection_name| + solr.with_collection(dir: config_dir) do |collection_name| expect(client.exists?(collection_name)).to be true end end @@ -38,7 +44,7 @@ it "creates a new collection with options from the config" do expect(solr_instance).to receive(:create).with( hash_including(name: "project-development", dir: anything)) - solr_instance.with_collection(dir: File.join(FIXTURES_DIR, "basic_configs")) {} + solr_instance.with_collection(dir: config_dir) {} end end @@ -53,11 +59,11 @@ describe 'single solr node' do it 'allows persistent collection on restart' do subject.wrap do |solr| - solr.with_collection(name: 'solr-node-persistent-core', dir: File.join(FIXTURES_DIR, 'basic_configs'), persist: true) {} + solr.with_collection(name: 'solr-node-persistent-core', dir: config_dir, persist: true) {} end subject.wrap do |solr| - solr.with_collection(name: 'solr-node-persistent-core', dir: File.join(FIXTURES_DIR, 'basic_configs'), persist: true) {} + solr.with_collection(name: 'solr-node-persistent-core', dir: config_dir, persist: true) {} solr.delete 'solr-node-persistent-core' end end @@ -68,7 +74,7 @@ it 'allows persistent collection on restart' do subject.wrap do |solr| - config_name = solr.upconfig dir: File.join(FIXTURES_DIR, 'basic_configs') + config_name = solr.upconfig dir: config_dir solr.with_collection(name: 'solr-cloud-persistent-collection', config_name: config_name, persist: true) {} end @@ -85,7 +91,7 @@ let(:options) { { cloud: true } } it 'can upload configurations' do subject.wrap do |solr| - config_name = solr.upconfig dir: File.join(FIXTURES_DIR, 'basic_configs') + config_name = solr.upconfig dir: config_dir Dir.mktmpdir do |dir| solr.downconfig name: config_name, dir: dir end