Skip to content

Commit

Permalink
Consider a 503 response as Solr not running
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason Barnabe authored and gaffneyc committed Sep 29, 2016
1 parent 50aca9a commit abae5bf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/sunspot_test.rb
Expand Up @@ -68,8 +68,9 @@ def wait_until_solr_starts
def solr_running?
begin
solr_ping_uri = URI.parse("#{Sunspot.session.config.solr.url}/ping")
Net::HTTP.get(solr_ping_uri)
true # Solr Running
res = Net::HTTP.get_response(solr_ping_uri)
# Solr will return 503 codes when it's starting up
res.code != '503'
rescue
false # Solr Not Running
end
Expand Down
11 changes: 11 additions & 0 deletions spec/sunspot_test_spec.rb
Expand Up @@ -149,6 +149,17 @@
expect(SunspotTest.send(:solr_running?)).to eq(false)
end
end

context "if solr is starting up" do
before do
Net::HTTP.stub(get_response:double(code: '503'))
end

it "returns false" do
expect(SunspotTest.send(:solr_running?)).to eq(false)
end
end

end

describe ".wait_until_solr_starts" do
Expand Down

0 comments on commit abae5bf

Please sign in to comment.