Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prefer docker for starting solr #3209

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 33 additions & 6 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ end
Bundler::GemHelper.install_tasks

require 'solr_wrapper'
require 'open3'

require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)
Expand All @@ -30,16 +31,42 @@ require 'engine_cart/rake_task'

require 'spotlight/version'

def system_with_error_handling(*args)
Open3.popen3(*args) do |_stdin, stdout, stderr, thread|
puts stdout.read
raise "Unable to run #{args.inspect}: #{stderr.read}" unless thread.value.success?
end
end

def with_solr(&block) # rubocop:disable Metrics/MethodLength
# We're being invoked by the app entrypoint script and solr is already up via docker compose
if ENV['SOLR_ENV'] == 'docker-compose'
yield
elsif system('docker compose version')
# We're not running `docker compose up' but still want to use a docker instance of solr.
begin
puts 'Starting Solr'
system_with_error_handling 'docker compose up -d solr'
yield
ensure
puts 'Stopping Solr'
system_with_error_handling 'docker compose stop solr'
end
else
SolrWrapper.wrap do |solr|
solr.with_collection(&block)
end
end
end

task ci: ['engine_cart:generate'] do
ENV['environment'] = 'test'

SolrWrapper.wrap(port: '8983') do |solr|
solr.with_collection(name: 'blacklight-core', dir: 'lib/generators/spotlight/templates/solr/conf') do
Rake::Task['spotlight:fixtures'].invoke
with_solr do
Rake::Task['spotlight:fixtures'].invoke

# run the tests
Rake::Task['spec'].invoke
end
# run the tests
Rake::Task['spec'].invoke
end
end

Expand Down