Skip to content

Commit

Permalink
Merge pull request #151 from cbeer/solr-check
Browse files Browse the repository at this point in the history
Update the built-in SolrCheck for compatibility with Solr 7+
  • Loading branch information
Andy Fleener committed Sep 19, 2018
2 parents e02f298 + 06c7bcd commit a36626b
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 20 deletions.
2 changes: 1 addition & 1 deletion lib/ok_computer/built_in_checks/solr_check.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def check
# Public: Returns true if Solr's ping returned OK, otherwise false
def ping?
response = perform_request
!!(response =~ %r(<str name="status">OK</str>))
!!(response =~ Regexp.union(%r(<str name="status">OK</str>), %r("status":"OK")))
end
end
end
59 changes: 40 additions & 19 deletions spec/ok_computer/built_in_checks/solr_check_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,27 +70,48 @@ module OkComputer
end

context "when the status is OK" do
let(:response) do
%q(
<?xml version="1.0" ?>
<response>
<lst name="responseHeader">
<int name="status">0</int>
<int name="QTime">2</int>
<lst name="params">
<str name="echoParams">all</str>
<str name="q">solrpingquery</str>
<str name="qt">standard</str>
<str name="echoParams">all</str>
</lst>
</lst>
<str name="status">OK</str>
</response>
)
context "with an XML response body" do
let(:response) do
%q(
<?xml version="1.0" ?>
<response>
<lst name="responseHeader">
<int name="status">0</int>
<int name="QTime">2</int>
<lst name="params">
<str name="echoParams">all</str>
<str name="q">solrpingquery</str>
<str name="qt">standard</str>
<str name="echoParams">all</str>
</lst>
</lst>
<str name="status">OK</str>
</response>
)
end

it "returns true" do
expect(subject.ping?).to be true
end
end

it "returns true" do
expect(subject.ping?).to be true
context "with a JSON response body" do
let(:response) do
%q(
{
"responseHeader":{
"zkConnected":true,
"status":0,
"QTime":17279,
},
"status":"OK"
}
)
end

it "returns true" do
expect(subject.ping?).to be true
end
end
end

Expand Down

0 comments on commit a36626b

Please sign in to comment.