collectiveidea / sunspot_test Goto Github PK
View Code? Open in Web Editor NEWAuto-starts solr for your tests
License: MIT License
Auto-starts solr for your tests
License: MIT License
Tests are failing after ruby-2.4.1 update with:
SunspotTest::TimeOutError: Solr failed to start after 60 seconds
sunspot_test/lib/sunspot_test/cucumber.rb is using a cucumber old style tag expressions. the ~
for negative tags was removed in the version 4 , so according to cucumber documentation, it should be not @search
instead of ~@search
Hi I really don't know who is the responsible of this error (RSolr, sunspot or sunspot_test so I corss-post with sunspot)
Failure/Error: Unable to find matching line from backtrace
RSolr::Error::InvalidRubyResponse:
RSolr::Error::InvalidRubyResponse - 200 OK
Request Data:
<?xml version=\"1.0\" encoding=\"UTF-8\"?><delete><query>*:*</query></delete>
Backtrace: /Users/mauroasprea/.rvm/gems/ruby-1.9.3-p0/gems/rsolr-1.0.6/lib/rsolr/client.rb:256:in `rescue in evaluate_ruby_response' /Users/mauroasprea/.rvm/gems/ruby-1.9.3-p0/gems/rsolr-1.0.6/lib/rsolr/client.rb:253:in `evaluate_ruby_response' /Users/mauroasprea/.rvm/gems/ruby-1.9.3-p0/gems/rsolr-1.0.6/lib/rsolr/client.rb:228:in `adapt_response' /Users/mauroasprea/.rvm/gems/ruby-1.9.3-p0/gems/rsolr-1.0.6/lib/rsolr/client.rb:164:in `execute' /Users/mauroasprea/.rvm/gems/ruby-1.9.3-p0/gems/rsolr-1.0.6/lib/rsolr/client.rb:158:in `send_and_receive' (eval):2:in `post' /Users/mauroasprea/.rvm/gems/ruby-1.9.3-p0/gems/rsolr-1.0.6/lib/rsolr/client.rb:67:in `update' /Users/mauroasprea/.rvm/gems/ruby-1.9.3-p0/gems/rsolr-1.0.6/lib/rsolr/client.rb:131:in `delete_by_query' /Users/mauroasprea/.rvm/gems/ruby-1.9.3-p0/gems/sunspot-1.3.0/lib/sunspot/indexer.rb:57:in `remove_all' /Users/mauroasprea/.rvm/gems/ruby-1.9.3-p0/gems/sunspot-1.3.0/lib/sunspot/session.rb:178:in `remove_all' /Users/mauroasprea/.rvm/gems/ruby-1.9.3-p0/gems/sunspot-1.3.0/lib/sunspot/session.rb:189:in `remove_all!'
I'm getting this when running a rails integration_test of my search controller. In my gemfile I have the following gems:
rsolr (1.0.6)
sunspot (1.3.0)
rspec (2.7.0)
sunspot_test (0.4.0)
guard (0.9.4)
database_cleaner (0.7.0)
vcr (2.0.0.rc1)
I am trying to pass a simple test that saves a model instance (using Factory girl), with its corresponding search block and it searches it later.
Help please?
I'm trying to use sunspot_test in a regular rspec project. Not a Rails project.
The server fails to start because Rails is not loaded:
sunspot_rails-1.2.1/lib/sunspot/rails/configuration.rb:277:in user_configuration': uninitialized constant Rails (NameError) from sunspot_rails-1.2.1/lib/sunspot/rails/configuration.rb:261:in
user_configuration_from_key'
from sunspot_rails-1.2.1/lib/sunspot/rails/configuration.rb:211:in solr_home' from sunspot_rails-1.2.1/lib/sunspot/rails/server.rb:69:in
solr_home'
from sunspot_rails-1.2.1/lib/sunspot/rails/server.rb:150:in install_solr_home' from sunspot_rails-1.2.1/lib/sunspot/rails/server.rb:28:in
bootstrap'
from sunspot_rails-1.2.1/lib/sunspot/rails/server.rb:14:in run' from sunspot_test-0.4.0/lib/sunspot_test.rb:29:in
start_sunspot_server'
from sunspot_test-0.4.0/lib/sunspot_test.rb:26:in fork' from sunspot_test-0.4.0/lib/sunspot_test.rb:26:in
start_sunspot_server'
from sunspot_test-0.4.0/lib/sunspot_test.rb:17:in setup_solr' from sunspot_test-0.4.0/lib/sunspot_test/rspec.rb:9 from rspec-core-2.6.4/lib/rspec/core/hooks.rb:35:in
instance_eval'
from rspec-core-2.6.4/lib/rspec/core/hooks.rb:35:in run_in' from rspec-core-2.6.4/lib/rspec/core/hooks.rb:70:in
run_all'
from rspec-core-2.6.4/lib/rspec/core/hooks.rb:70:in each' from rspec-core-2.6.4/lib/rspec/core/hooks.rb:70:in
run_all'
from rspec-core-2.6.4/lib/rspec/core/hooks.rb:126:in run_hook_filtered' from rspec-core-2.6.4/lib/rspec/core/example_group.rb:206:in
eval_before_alls'
from rspec-core-2.6.4/lib/rspec/core/example_group.rb:261:in run' from rspec-core-2.6.4/lib/rspec/core/command_line.rb:24:in
run'
from rspec-core-2.6.4/lib/rspec/core/command_line.rb:24:in map' from rspec-core-2.6.4/lib/rspec/core/command_line.rb:24:in
run'
from rspec-core-2.6.4/lib/rspec/core/reporter.rb:12:in report' from rspec-core-2.6.4/lib/rspec/core/command_line.rb:21:in
run'
from rspec-core-2.6.4/lib/rspec/core/runner.rb:80:in run_in_process' from rspec-core-2.6.4/lib/rspec/core/runner.rb:69:in
run'
from rspec-core-2.6.4/lib/rspec/core/runner.rb:11:in `autorun'
from rspec:19
The v0.4.0 tag predates the change in 89a9ae7 that modifies how before blocks are managed for specs tagged search: true
.
Can a new version of this gem be published?
With c4ee8e0 the Ping URL changed from /admin/ping
back to /ping
[2] pry(SunspotTest)> Net::HTTP.get_response(URI.parse("#{Sunspot.session.config.solr.url}/admin/ping"))
=> #<Net::HTTPOK 200 OK readbody=true>
[3] pry(SunspotTest)> Net::HTTP.get_response(URI.parse("#{Sunspot.session.config.solr.url}/ping"))
=> #<Net::HTTPNotFound 404 Not Found readbody=true>
They both somehow work put /admin/ping
is the correct ping URL and is also used by sunspot
https://github.com/sunspot/sunspot/blob/master/ci/travis.sh#L9
solr_responding() {
port=$1
curl -o /dev/null "http://localhost:$port/solr/admin/ping" > /dev/null 2>&1
}
https://lucene.apache.org/solr/4_2_0/solr-core/org/apache/solr/handler/PingRequestHandler.html
Hi @asheren,
thanks for taking over this gem.
We updated sunspot_rails from 2.1
to 2.2
and had the following error while running the tests.
RSolr::Error::Http - 503 Service Unavailable
Error: {msg=SolrCore is loading,code=503}
The commit 3b08139 fixed the problem but it's only on the master branch and not yet released.
Would it be possible to release a new version for this gem?
See also #21
Cheers,
Jonas
I'm using sunspot_test with Test::Unit and Shoulda and experience, that Solr gets terminated before the tests run. This does not happen when I comment out the at_exit
call in start_sunspot_server
.
From #13:
Any records created between the running of the Before hooks and the running of the sunspot search will not be added to the Solr index.
I'm not sure what the best way to handle this would be, but it would be nice if the README was clearer about at what stage Sunspot.commit is run, and how that changes the use of the library in testing.
I'm re-creating this now because I just discovered this after hours of debugging.
After I run my tests the sunspot_solr is still alive.
at_exit { Process.kill("TERM", pid) }
does not run the ./solr stop
.
server.start
and server.stop
can be used to workaround this.
I would be happy to provide a PR if someone is going to merge it.
sunspot_test/lib/sunspot_test.rb
Line 32 in 45a2b31
$ ps aux | grep java
xxx 52735 0,1 0,3 4509468 53744 s001 S 2:11pm 0:21.76 /usr/bin/java -server -Xss256k -Xms512m -Xmx512m -XX:NewRatio=3 -XX:SurvivorRatio=4 -XX:TargetSurvivorRatio=90 -XX:MaxTenuringThreshold=8 -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:ConcGCThreads=4 -XX:ParallelGCThreads=4 -XX:+CMSScavengeBeforeRemark -XX:PretenureSizeThreshold=64m -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=50 -XX:CMSMaxAbortablePrecleanTime=6000 -XX:+CMSParallelRemarkEnabled -XX:+ParallelRefProcEnabled -verbose:gc -XX:+PrintHeapAtGC -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -XX:+PrintTenuringDistribution -XX:+PrintGCApplicationStoppedTime -Xloggc:/Users/xxx/.rvm/gems/ruby-2.2.7@yyy/gems/sunspot_solr-2.2.7/solr/server/logs/solr_gc.log -Djetty.port=50176 -DSTOP.PORT=49176 -DSTOP.KEY=solrrocks -Duser.timezone=UTC -Djetty.home=/Users/xxx/.rvm/gems/ruby-2.2.7@yyy/gems/sunspot_solr-2.2.7/solr/server -Dsolr.solr.home=/Users/xxx/rails/develop/project/solr -Dsolr.install.dir=/Users/xxx/.rvm/gems/ruby-2.2.7@yyy/gems/sunspot_solr-2.2.7/solr -jar start.jar --module=http
Update:
The issue in sunspot has been fixed.
sunspot/sunspot#843
Note there is a Problem with server.stop
so we should use at_exit { fork { server.stop } }
I'm using Rails 3.1.0, sunspot 1.2.1 and sunspot_test 0.4.0 with RSpec 2.6.0.
After setting up the environment and launching a test I get the the following error:
Failure/Error: Unable to find matching line from backtrace
SunspotTest::TimeOutError:
Solr failed to start after 15 seconds
# /usr/lib/ruby/gems/1.9.2/gems/sunspot_test-0.4.0/lib/sunspot_test.rb:65:in `wait_until_solr_starts'
# /usr/lib/ruby/gems/1.9.2/gems/sunspot_test-0.4.0/lib/sunspot_test.rb:34:in `start_sunspot_server'
# /usr/lib/ruby/gems/1.9.2/gems/sunspot_test-0.4.0/lib/sunspot_test.rb:17:in `setup_solr'
# /usr/lib/ruby/gems/1.9.2/gems/sunspot_test-0.4.0/lib/sunspot_test/rspec.rb:9:in `block (2 levels) in <top (required)>'
# /usr/lib/ruby/gems/1.9.2/gems/rspec-core-2.6.4/lib/rspec/core/hooks.rb:35:in `instance_eval'
# /usr/lib/ruby/gems/1.9.2/gems/rspec-core-2.6.4/lib/rspec/core/hooks.rb:35:in `run_in'
# /usr/lib/ruby/gems/1.9.2/gems/rspec-core-2.6.4/lib/rspec/core/hooks.rb:70:in `block in run_all'
# /usr/lib/ruby/gems/1.9.2/gems/rspec-core-2.6.4/lib/rspec/core/hooks.rb:70:in `each'
# /usr/lib/ruby/gems/1.9.2/gems/rspec-core-2.6.4/lib/rspec/core/hooks.rb:70:in `run_all'
# /usr/lib/ruby/gems/1.9.2/gems/rspec-core-2.6.4/lib/rspec/core/hooks.rb:126:in `run_hook_filtered'
# /usr/lib/ruby/gems/1.9.2/gems/rspec-core-2.6.4/lib/rspec/core/example_group.rb:206:in `eval_before_alls'
# /usr/lib/ruby/gems/1.9.2/gems/rspec-core-2.6.4/lib/rspec/core/example_group.rb:261:in `run'
# /usr/lib/ruby/gems/1.9.2/gems/rspec-core-2.6.4/lib/rspec/core/example_group.rb:263:in `block in run'
# /usr/lib/ruby/gems/1.9.2/gems/rspec-core-2.6.4/lib/rspec/core/example_group.rb:263:in `map'
# /usr/lib/ruby/gems/1.9.2/gems/rspec-core-2.6.4/lib/rspec/core/example_group.rb:263:in `run'
# /usr/lib/ruby/gems/1.9.2/gems/rspec-core-2.6.4/lib/rspec/core/example_group.rb:263:in `block in run'
# /usr/lib/ruby/gems/1.9.2/gems/rspec-core-2.6.4/lib/rspec/core/example_group.rb:263:in `map'
# /usr/lib/ruby/gems/1.9.2/gems/rspec-core-2.6.4/lib/rspec/core/example_group.rb:263:in `run'
# /usr/lib/ruby/gems/1.9.2/gems/rspec-core-2.6.4/lib/rspec/core/command_line.rb:24:in `block (2 levels) in run'
# /usr/lib/ruby/gems/1.9.2/gems/rspec-core-2.6.4/lib/rspec/core/command_line.rb:24:in `map'
# /usr/lib/ruby/gems/1.9.2/gems/rspec-core-2.6.4/lib/rspec/core/command_line.rb:24:in `block in run'
# /usr/lib/ruby/gems/1.9.2/gems/rspec-core-2.6.4/lib/rspec/core/reporter.rb:12:in `report'
# /usr/lib/ruby/gems/1.9.2/gems/rspec-core-2.6.4/lib/rspec/core/command_line.rb:21:in `run'
# /usr/lib/ruby/gems/1.9.2/gems/rspec-core-2.6.4/lib/rspec/core/runner.rb:80:in `run_in_process'
# /usr/lib/ruby/gems/1.9.2/gems/rspec-core-2.6.4/lib/rspec/core/runner.rb:66:in `rescue in run'
# /usr/lib/ruby/gems/1.9.2/gems/rspec-core-2.6.4/lib/rspec/core/runner.rb:62:in `run'
# /usr/lib/ruby/gems/1.9.2/gems/rspec-core-2.6.4/lib/rspec/core/runner.rb:11:in `block in autorun'
It seems that the test runner does not ping the right server because i see solr start in the list of processes
Any records created between the running of the Before hooks and the running of the sunspot search will not be added to the Solr index.
I'm not sure what the best way to handle this would be, but it would be nice if the README was clearer about at what stage Sunspot.commit is run, and how that changes the use of the library in testing.
Recently the sunspot_rails version requirement was tightened up from >=1.2.1
to ~>1.2.1
3bd1fc0
sunspot_rails is in 2.x
now and we've been using sunspot_test
with 2.1.0 successfully.
After upgrading to rsolr 2.0.2, tests on my Jenkins server are failing (yet are succeeding locally). Any test using @search
results in
RSolr::Error::Http - 503 Service Unavailable
Error: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html><head>
<meta http-equiv="Content-Type" CONTENT="text/html; charset=utf-8">
<title>ERROR: The requested URL could not be retrieved</title>
<style type="text/css"><!--
/*
Stylesheet for Squid Error pages
Adapted from design by Free CSS Templates
http://www.freecsstemplates.org
Released for free under a Creative Commons Attribution 2.5 License
*/
URI: http://localhost:8983/solr/test/update?wt=json
Request Headers: {"Content-Type"=>"application/json"}
Request Data: "{\"delete\":{\"query\":\"*:*\"}}"
Backtrace: (eval):2:in `post' (RSolr::Error::Http)
(eval):2:in `post'
Reverting to rsolr 1.1.2 works. Using the latest from the sunspot_test master branch does not work. solr.log shows no errors, but only shows the requests to /admin/ping.
I have tried clearing out the solr directory and copying from sunspot_solr-2.2.7/solr/solr/. I have also tried patching wait_until_solr_starts to sleep for 5 seconds first.
Hi there,
I have a number of tests in both RSpec and Cucumber that are displaying the same behaviour.
When records are added, they show up in the DB, but for some reason no results are found in Sunspot. When I repeat the test manually everything works, so I'm happy that the code is ok. It would still be nice to get the tests working though!
As per the instructions, I am calling Sunspot.commit, but it doesn't seem to make any difference. I've checked and the Sunspot instance in definitely starting when the tests are running as it should.
It's hard to debug this one as there aren't any error messages, it just doesn't give the expected result.
A very abbreviated version of my Gemfile is below
gem "rails", "~> 3.1.1"
gem 'mysql2'
gem 'sunspot', '1.2.1'
gem 'sunspot_rails'
gem 'sunspot_test'
group :development, :test do
gem "mongrel"
gem "rspec-rails"
gem "capybara"
gem 'ruby-debug'
gem 'database_cleaner'
gem 'factory_girl_rails'
gem 'cucumber-rails'
gem 'ci_reporter'
gem 'autotest-rails'
gem 'launchy'
gem 'email_spec'
gem 'shoulda-matchers'
end
And below is an example of a failing test.
Background:
Given I am an anonymous user
And I am on the home page
And there is 1 private article in the database
And the sunspot index is up to date
Scenario: Searching for public article
Given there is 1 public article in the database
And the sunspot index is up to date
When I fill in "search" with "Public"
And I press "search_submit"
Then there should be 2 articles in the database
And there should be 1 public article in the database
Then I should see "Found 1 result"
And I should see "Public"
The test fails on the "Found 1 result" line.
Cheers,
Graeme
Hi, why do you need to invoke Sunspot.commit
after Sunspot.remove_all!
?
remove_all!
will invoke commit
https://github.com/sunspot/sunspot/blob/ec64df6a526d738f9f77c039679b344f908d3298/sunspot/lib/sunspot/session.rb#L188
Hi all,
I use cucumber to test solr search by using sunspot_test. I have a problem.
On local: I passed all the tests.
On CircleCI: I got this error with every feature using @search
tag of sunspot_test
@search
Feature: Pagination
In order to browse books and view searching results with a particular amount
As a user
I want to have a feature that I can choose number of books to be displayed
Scenario: user see pagination feature on browsing books page # features/pagination.feature:7
RSolr::Error::Http - 404 Not Found
Error: Not Found
Request Data: "<?xml version=\"1.0\" encoding=\"UTF-8\"?><delete><query>*:*</query></delete>"
How do I fix it? Thanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.