Skip to content

Commit

Permalink
log graph load failures for linked data module
Browse files Browse the repository at this point in the history
  • Loading branch information
elrayle committed Dec 16, 2019
1 parent 50b4329 commit 5e115ec
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/services/qa/linked_data/graph_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ def at_least_one_object_has_language?(objects, language)
end

def process_error(e, url)
Rails.logger.warn("******** RDF::Graph#load failure: exception=#{e.inspect}, url=#{url}")
uri = URI(url)
raise RDF::FormatError, "Unknown RDF format of results returned by #{uri}. (RDF::FormatError) You may need to include gem 'linkeddata'." if e.is_a? RDF::FormatError
response_code = ioerror_code(e)
Expand Down
15 changes: 15 additions & 0 deletions spec/controllers/linked_data_terms_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
require 'json'

describe Qa::LinkedDataTermsController, type: :controller do
let(:graph_load_failure) { /^\*\*\*\*\*\*\*\* RDF\:\:Graph\#load failure/ }
before do
@routes = Qa::Engine.routes
end
Expand Down Expand Up @@ -140,6 +141,7 @@
.to_return(status: 500)
end
it 'returns 500' do
expect(Rails.logger).to receive(:warn).with(graph_load_failure)
expect(Rails.logger).to receive(:warn).with("Internal Server Error - Search query my_query unsuccessful for authority OCLC_FAST")
get :search, params: { q: 'my_query', vocab: 'OCLC_FAST', maximumRecords: '3' }
expect(response.code).to eq('500')
Expand All @@ -154,6 +156,7 @@
end
it 'returns 500' do
msg = "RDF Format Error - Results from search query my_query for authority OCLC_FAST was not identified as a valid RDF format. You may need to include the linkeddata gem."
expect(Rails.logger).to receive(:warn).with(graph_load_failure)
expect(Rails.logger).to receive(:warn).with(msg)
get :search, params: { q: 'my_query', vocab: 'OCLC_FAST', maximumRecords: '3' }
expect(response.code).to eq('500')
Expand All @@ -166,6 +169,7 @@
.to_return(status: 501)
end
it 'returns 500' do
expect(Rails.logger).to receive(:warn).with(graph_load_failure)
expect(Rails.logger).to receive(:warn).with("Internal Server Error - Search query my_query unsuccessful for authority OCLC_FAST")
get :search, params: { q: 'my_query', vocab: 'OCLC_FAST', maximumRecords: '3' }
expect(response.code).to eq('500')
Expand All @@ -179,6 +183,7 @@
.to_return(status: 503)
end
it 'returns 503' do
expect(Rails.logger).to receive(:warn).with(graph_load_failure)
expect(Rails.logger).to receive(:warn).with("Service Unavailable - Search query my_query unsuccessful for authority OCLC_FAST")
get :search, params: { q: 'my_query', vocab: 'OCLC_FAST', maximumRecords: '3' }
expect(response.code).to eq('503')
Expand Down Expand Up @@ -355,6 +360,7 @@
stub_request(:get, 'http://id.worldcat.org/fast/530369').to_return(status: 500)
end
it 'returns 500' do
expect(Rails.logger).to receive(:warn).with(graph_load_failure)
expect(Rails.logger).to receive(:warn).with("Internal Server Error - Fetch term 530369 unsuccessful for authority OCLC_FAST")
get :show, params: { id: '530369', vocab: 'OCLC_FAST' }
expect(response.code).to eq('500')
Expand All @@ -380,6 +386,7 @@
end
it 'returns 500' do
msg = "RDF Format Error - Results from fetch term 530369 for authority OCLC_FAST was not identified as a valid RDF format. You may need to include the linkeddata gem."
expect(Rails.logger).to receive(:warn).with(graph_load_failure)
expect(Rails.logger).to receive(:warn).with(msg)
get :show, params: { id: '530369', vocab: 'OCLC_FAST' }
expect(response.code).to eq('500')
Expand All @@ -391,6 +398,7 @@
stub_request(:get, 'http://id.worldcat.org/fast/530369').to_return(status: 501)
end
it 'returns 500' do
expect(Rails.logger).to receive(:warn).with(graph_load_failure)
expect(Rails.logger).to receive(:warn).with("Internal Server Error - Fetch term 530369 unsuccessful for authority OCLC_FAST")
get :show, params: { id: '530369', vocab: 'OCLC_FAST' }
expect(response.code).to eq('500')
Expand All @@ -403,6 +411,7 @@
stub_request(:get, 'http://id.worldcat.org/fast/530369').to_return(status: 503)
end
it 'returns 503' do
expect(Rails.logger).to receive(:warn).with(graph_load_failure)
expect(Rails.logger).to receive(:warn).with("Service Unavailable - Fetch term 530369 unsuccessful for authority OCLC_FAST")
get :show, params: { id: '530369', vocab: 'OCLC_FAST' }
expect(response.code).to eq('503')
Expand All @@ -414,6 +423,7 @@
stub_request(:get, 'http://id.worldcat.org/fast/FAKE_ID').to_return(status: 404, body: '', headers: {})
end
it 'returns 404' do
expect(Rails.logger).to receive(:warn).with(graph_load_failure)
expect(Rails.logger).to receive(:warn).with('Term Not Found - Fetch term FAKE_ID unsuccessful for authority OCLC_FAST')
get :show, params: { id: 'FAKE_ID', vocab: 'OCLC_FAST' }
expect(response.code).to eq('404')
Expand Down Expand Up @@ -566,6 +576,7 @@
stub_request(:get, 'http://localhost/test_default/term?uri=http://id.worldcat.org/fast/530369').to_return(status: 500)
end
it 'returns 500' do
expect(Rails.logger).to receive(:warn).with(graph_load_failure)
expect(Rails.logger).to receive(:warn).with("Internal Server Error - Fetch term http://id.worldcat.org/fast/530369 unsuccessful for authority LOD_TERM_URI_PARAM_CONFIG")
get :fetch, params: { vocab: 'LOD_TERM_URI_PARAM_CONFIG', uri: 'http://id.worldcat.org/fast/530369' }
expect(response.code).to eq('500')
Expand All @@ -580,6 +591,7 @@
it 'returns 500' do
msg = "RDF Format Error - Results from fetch term http://id.worldcat.org/fast/530369 for authority LOD_TERM_URI_PARAM_CONFIG was not identified as a valid RDF format. " \
"You may need to include the linkeddata gem."
expect(Rails.logger).to receive(:warn).with(graph_load_failure)
expect(Rails.logger).to receive(:warn).with(msg)
get :fetch, params: { uri: 'http://id.worldcat.org/fast/530369', vocab: 'LOD_TERM_URI_PARAM_CONFIG' }
expect(response.code).to eq('500')
Expand All @@ -591,6 +603,7 @@
stub_request(:get, 'http://localhost/test_default/term?uri=http://id.worldcat.org/fast/530369').to_return(status: 501)
end
it 'returns 500' do
expect(Rails.logger).to receive(:warn).with(graph_load_failure)
expect(Rails.logger).to receive(:warn).with("Internal Server Error - Fetch term http://id.worldcat.org/fast/530369 unsuccessful for authority LOD_TERM_URI_PARAM_CONFIG")
get :fetch, params: { uri: 'http://id.worldcat.org/fast/530369', vocab: 'LOD_TERM_URI_PARAM_CONFIG' }
expect(response.code).to eq('500')
Expand All @@ -603,6 +616,7 @@
stub_request(:get, 'http://localhost/test_default/term?uri=http://id.worldcat.org/fast/530369').to_return(status: 503)
end
it 'returns 503' do
expect(Rails.logger).to receive(:warn).with(graph_load_failure)
expect(Rails.logger).to receive(:warn).with("Service Unavailable - Fetch term http://id.worldcat.org/fast/530369 unsuccessful for authority LOD_TERM_URI_PARAM_CONFIG")
get :fetch, params: { uri: 'http://id.worldcat.org/fast/530369', vocab: 'LOD_TERM_URI_PARAM_CONFIG' }
expect(response.code).to eq('503')
Expand All @@ -614,6 +628,7 @@
stub_request(:get, 'http://localhost/test_default/term?uri=http://test.org/FAKE_ID').to_return(status: 404, body: '', headers: {})
end
it 'returns 404' do
expect(Rails.logger).to receive(:warn).with(graph_load_failure)
expect(Rails.logger).to receive(:warn).with('Term Not Found - Fetch term http://test.org/FAKE_ID unsuccessful for authority LOD_TERM_URI_PARAM_CONFIG')
get :fetch, params: { uri: 'http://test.org/FAKE_ID', vocab: 'LOD_TERM_URI_PARAM_CONFIG' }
expect(response.code).to eq('404')
Expand Down

0 comments on commit 5e115ec

Please sign in to comment.