Specs for Rails app cannot connect to Sunspot Solr instance


Hey all. I’m setting up a new Rails app on Circle. It’s pretty vanilla, except that it uses Solr via the Sunspot gem.

According to the docs (https://circleci.com/docs/test-with-solr) I think the default configuration should Just Work. You can see in the snippets below that it appears to be trying to connect to the right port. But all my specs that involve Solr are getting 404 errors.

The build runs fine locally, and my sunspot.yml is the same, except that I don’t specify a path (though /solr is the default, AFAIK).

Any suggestions?

in Generate sunspot.yml:
mkdir -p config echo "test: solr: hostname: localhost port: 8981 path: /solr "> config/sunspot.yml

in the rake logs for the build:
** Invoke sunspot:solr:start (first_time) ** Invoke environment ** Execute sunspot:solr:start Copying /home/ubuntu ... [snip] Successfully started Solr ...

All my solr-based specs appear to be failing with the same basic 404 error:
Failure/Error: Item.reindex RSolr::Error::Http: RSolr::Error::Http - 404 Not Found Error: Not Found URI: http://localhost:8981/solr/update?wt=ruby


Can you please try hashing # path
hostname: localhost
port: 8981
log_level: WARNING
#path: /solr/production
# read_timeout: 2
# open_timeout: 0.5


Thanks Devendra. I also started to suspect this is the problem. But how do I do this?

I’ve tried using this circleci.yml file, but it does not affect the inferred “Generate circleci.yml” task in the build. The build still generates the sunspot.yml with the path attribute.

(this forum makes it very difficult to share properly format code, so posting a Gist)


OK, so I’ve found a configuration that works. After reading the docs again, it isn’t clear to me whether I should be able to only override the way that sunspot.yml is generated. But this is the circle.yml I ended up with. I created sunspot.ci.yml and database.ci.yml files, so the configuration copies them and runs the rake tasks.

Is there any way to ONLY override the way the sunspot.yml is generated?


Hi I am getting same error but suggested configuration does not work me:

Stack in use:
Ruby on Rails

Exact error message:
Failure/Error: raise RSolr::Error::Http.new request, response unless [200,302].include? response[:status]
RSolr::Error::Http - 404 Not Found
Error: Not Found

Which troubleshooting steps you’ve already taken:
Used below configuration:
hostname: localhost
port: 8981
log_level: WARNING
path: /solr/test

Any recent changes either in the codebase or the stack:
Previous version:
sunspot_solr (2.2.0)

Current Version:
sunspot_solr (2.2.7)

What happens when you run the tests locally
All specs pass

I would appreciate any help.