Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ gem 'berkeley_library-location', '~> 4.2.0'
gem 'berkeley_library-logging', '~> 0.2', '>= 0.2.7'
gem 'berkeley_library-marc', '~> 0.3.1'
gem 'berkeley_library-tind', '~> 0.8.0'
gem 'berkeley_library-util', '~> 0.2.0'
gem 'berkeley_library-util', '~> 0.3'
gem 'bootstrap'
gem 'dotenv-rails', '~> 2.8.1', require: 'dotenv/rails-now'
gem 'faraday'
Expand Down
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ GEM
rest-client (~> 2.1)
rubyzip (~> 2.3, < 3.0)
typesafe_enum (~> 0.3)
berkeley_library-util (0.2.0)
berkeley_library-util (0.3.0)
berkeley_library-logging (~> 0.3)
rest-client (~> 2.1)
typesafe_enum (~> 0.3)
Expand Down Expand Up @@ -511,7 +511,7 @@ DEPENDENCIES
berkeley_library-logging (~> 0.2, >= 0.2.7)
berkeley_library-marc (~> 0.3.1)
berkeley_library-tind (~> 0.8.0)
berkeley_library-util (~> 0.2.0)
berkeley_library-util (~> 0.3)
bootstrap
brakeman
bundle-audit
Expand Down
4 changes: 4 additions & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ def log_active_storage_root!(active_storage_root)
config.tind_base_uri = config.altmedia['tind_base_uri']
config.tind_api_key = config.altmedia['tind_api_key']

config.hathiTrust_health_check_url = 'https://catalog.hathitrust.org/api/volumes/full/oclc/424023.json'
config.whois_health_check_url = 'https://whois.arin.net/rest/poc/1AD-ARIN'
config.berkeley_service_now_health_check_url = 'https://berkeley.service-now.com/kb_view.do?sysparm_article=KB0011960'

config.to_prepare do
GoodJob::JobsController.class_eval do
include AuthSupport
Expand Down
21 changes: 21 additions & 0 deletions config/initializers/okcomputer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
require 'net/smtp'

# Health check configuration
require 'berkeley_library/util/uris/head_check'

OkComputer.logger = Rails.logger
OkComputer.check_in_parallel = true
Expand Down Expand Up @@ -64,5 +65,25 @@ def check
# Ensure database migrations have been run.
OkComputer::Registry.register 'database-migrations', OkComputer::ActiveRecordMigrationsCheck.new

# Ensure connectivity to the mail system.
OkComputer::Registry.register 'action-mailer', OkComputer::ActionMailerCheck.new

# Ensure TIND API is working.
tind_health_check_url = "#{Rails.application.config.tind_base_uri}api/v1/search?In=en"
OkComputer::Registry.register 'thind-api', BerkeleyLibrary::Util::HeadCheck.new(tind_health_check_url)

# Ensure HathiTrust API is working.
OkComputer::Registry.register 'hathitrust-api', BerkeleyLibrary::Util::HeadCheck.new(Rails.application.config.hathiTrust_health_check_url)

# Ensure ARIN Whois API is working.
OkComputer::Registry.register 'whois-arin-api', BerkeleyLibrary::Util::HeadCheck.new(Rails.application.config.whois_health_check_url)

# Ensure Berkeley ServiceNow is accessible.
OkComputer::Registry.register 'berkeley-service-now', BerkeleyLibrary::Util::HeadCheck.new(Rails.application.config.berkeley_service_now_health_check_url)

# Ensure PayPal Payflow is accessible.
OkComputer::Registry.register 'paypal-payflow', OkComputer::HttpCheck.new(Rails.application.config.paypal_payflow_url)

# Since the WorldCat API service requests dynamically generated OCLC tokens, we are not doing a health check for it.
# Ensure SMTP can connect
OkComputer::Registry.register 'mail-connectivity', MailConnectivityCheck.new if ActionMailer::Base.delivery_method == :smtp
18 changes: 18 additions & 0 deletions spec/request/okcomputer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
RSpec.describe 'OKComputer', type: :request do
before do
allow(Alma::User).to receive(:find).and_return(Alma::User.new)
tind_health_check_url = "#{Rails.application.config.tind_base_uri}api/v1/search?In=en"
stub_request(:head, tind_health_check_url).to_return(status: 200)
stub_request(:head, Rails.application.config.whois_health_check_url).to_return(status: 200)
stub_request(:head, Rails.application.config.hathiTrust_health_check_url).to_return(status: 200)
stub_request(:head, Rails.application.config.berkeley_service_now_health_check_url).to_return(status: 200)
stub_request(:get, Rails.application.config.paypal_payflow_url).to_return(status: 200)
end

it 'is mounted at /okcomputer' do
Expand All @@ -25,6 +31,12 @@
database
alma-patron-lookup
database-migrations
thind-api
whois-arin-api
paypal-payflow
hathitrust-api
berkeley-service-now
action-mailer
]
end
end
Expand All @@ -45,7 +57,13 @@
database
alma-patron-lookup
database-migrations
thind-api
whois-arin-api
paypal-payflow
hathitrust-api
berkeley-service-now
mail-connectivity
action-mailer
]
end
end
Expand Down