Skip to content
Merged
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.x.healthcheck_urls.hathiTrust = 'https://catalog.hathitrust.org/api/volumes/full/oclc/424023.json'
config.x.healthcheck_urls.whois = 'https://whois.arin.net/rest/poc/1AD-ARIN'
config.x.healthcheck_urls.berkeley_service_now = 'https://berkeley.service-now.com/kb_view.do?sysparm_article=KB0011960'

config.to_prepare do
GoodJob::JobsController.class_eval do
include AuthSupport
Expand Down
24 changes: 21 additions & 3 deletions config/initializers/okcomputer.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# frozen_string_literal: true

require 'net/smtp'
require 'berkeley_library/util/uris/head_check'

# Health check configuration

OkComputer.logger = Rails.logger
OkComputer.check_in_parallel = true

Expand Down Expand Up @@ -58,11 +58,29 @@ def check
end
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize

# Ensure SMTP can connect
OkComputer::Registry.register 'mail-connectivity', MailConnectivityCheck.new if ActionMailer::Base.delivery_method == :smtp

# Ensure Alma API is working.
OkComputer::Registry.register 'alma-patron-lookup', AlmaPatronCheck.new

# Ensure database migrations have been run.
OkComputer::Registry.register 'database-migrations', OkComputer::ActiveRecordMigrationsCheck.new

# Ensure SMTP can connect
OkComputer::Registry.register 'mail-connectivity', MailConnectivityCheck.new if ActionMailer::Base.delivery_method == :smtp
# Ensure TIND API is working.
tind_health_check_url = "#{Rails.application.config.tind_base_uri}api/v1/search?In=en"
OkComputer::Registry.register 'tind-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.x.healthcheck_urls.hathiTrust)

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

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

# 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.
16 changes: 16 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.x.healthcheck_urls.whois).to_return(status: 200)
stub_request(:head, Rails.application.config.x.healthcheck_urls.hathiTrust).to_return(status: 200)
stub_request(:head, Rails.application.config.x.healthcheck_urls.berkeley_service_now).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,11 @@
database
alma-patron-lookup
database-migrations
tind-api
whois-arin-api
paypal-payflow
hathitrust-api
berkeley-service-now
]
end
end
Expand All @@ -45,6 +56,11 @@
database
alma-patron-lookup
database-migrations
tind-api
whois-arin-api
paypal-payflow
hathitrust-api
berkeley-service-now
mail-connectivity
]
end
Expand Down