I am thinking about migrating from a custom Jenkins to Travis for my Ruby on Rails application.
My application runs a Solr server with Sunspot, and queries are tested with rspec on a real Solr instance. I'm using sunspot_solr gem witch has a pre-packaged Solr distribution, and also the sunspot-rails-tester gem to launch Sunspot only when needed.
It works well on our local machines, and on our Jenkins server.
But I'm having trouble with Travis right now...
According to the logs I see on Travis, Sunspot seems to launch:
Sunspot server is starting...
Sunspot server is starting...
Sunspot server is starting...
Sunspot server took 4.10 seconds to start
But when the rspec test try to make a query, I get a 404 error from Solr:
RSolr::Error::Http:
RSolr::Error::Http - 404 Not Found
Error: Not Found
Request Data: "<?xml version=\"1.0\" encoding=\"UTF-8\"?><delete><query>*:*</query></delete>"
I have a standard config/sunspot.yml configuration:
development:
solr:
hostname: localhost
port: 8982
log_level: INFO
path: /solr/development
test:
solr:
hostname: localhost
port: 8981
log_level: WARNING
path: /solr/test
Here is my .travis.yml configuration:
language: ruby
rvm:
- "2.1.3"
cache: bundler
env:
- DB=postgresql
script:
- RAILS_ENV=test bundle exec rake db:migrate --trace
- bundle exec rake db:test:prepare
- bundle exec rake
before_script:
- "psql -c 'create database test;' -U postgres"
- cp config/database.travis.yml config/database.yml
- cp config/sunspot.travis.yml config/sunspot.yml
EDIT
I found a workaroud here: Rails app: Solr throwing RSolr::Error::Http - 404 Not Found when executing search
My sunspot.yml is now:
development:
solr:
hostname: localhost
port: 8982
log_level: INFO
path: /solr/development
test:
solr:
hostname: localhost
port: 8981
log_level: WARNING
path: /solr/test
solr_home: solr
I don't know exactly what's wrong here, and why I have to do that only for Travis...
However, when I set "solr_home: solr", solr is installed here :
/home/travis/build/myapp/web/vendor/bundle/ruby/2.1.0/gems/sunspot_solr-2.1.1/solr/solr
So I have to copy my solr/conf/schema.xml in this folder, which is very unlikely, and I end up with this travis.yml
language: ruby
rvm:
- "2.1.3"
cache: bundler
env:
- DB=postgresql
script:
- RAILS_ENV=test bundle exec rake db:migrate --trace
- bundle exec rake db:test:prepare
- bundle exec rake
before_script:
- "psql -c 'create database \"elcurator-test\";' -U postgres"
- cp config/database.travis.yml config/database.yml
- cp config/sunspot.travis.yml config/sunspot.yml
- mkdir -p /home/travis/build/myapp/web/vendor/bundle/ruby/2.1.0/gems/sunspot_solr-2.1.1/solr/solr/conf
- cp solr/conf/schema.xml /home/travis/build/myapp/web/vendor/bundle/ruby/2.1.0/gems/sunspot_solr-2.1.1/solr/solr/conf
So the main problem remains, why do I get 404 errors when I use the default solr_home (which is "#{Rails.root}/solr" ?