Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use custom Solr docker image and remove solr_wrapper #2609

Merged
merged 8 commits into from
Aug 4, 2021
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
141 changes: 85 additions & 56 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,56 @@
version: 2
jobs:
build:
# Primary command image where all commands run
---
version: 2.1
executors:
orangelight-executor:
docker:
- image: circleci/ruby:2.6-node-browsers
environment:
RAILS_ENV: test
ORANGELIGHT_HOST: localhost
ORANGELIGHT_USER: postgres
SOLR_URL: http://solr:SolrRocks@localhost:8983/solr/orangelight-core-test
NVM_HOME: ~/.nvm

# Service container image available at 'host: localhost'
- image: postgres:10
environment:
POSTGRES_USER: orangelight
POSTGRES_DB: orangelight_test
POSTGRES_HOST_AUTH_METHOD: trust
- image: pulibrary/orangelight-solr:8.4
command: server/scripts/ci-start.sh
working_directory: ~/orangelight
basic-executor:
docker:
- image: circleci/ruby:2.6-node-browsers
environment:
RAILS_ENV: test
NVM_HOME: ~/.nvm
working_directory: ~/orangelight

commands:
setup-bundler:
steps:
- run: gem install bundler -v '2.2.14'
# Restore bundle cache
- restore_cache:
keys:
- orangelight-{{ checksum "Gemfile.lock" }}
- orangelight-
# Bundle install dependencies
- run:
name: Install dependencies
command: bundle check --path=vendor/bundle || bundle install --path=vendor/bundle --jobs 4 --retry 3
- save_cache:
key: orangelight-{{ checksum "Gemfile.lock" }}
paths:
- ./vendor/bundle
jobs:
build:
executor: basic-executor
steps:
- attach_workspace:
at: '~/orangelight'
- checkout
- setup-bundler
- run:
name: Install the NVM
command: |
Expand All @@ -37,43 +69,6 @@ jobs:
command: |
source ~/.nvm/nvm.sh
curl -o- -L https://yarnpkg.com/install.sh | bash
- run:
name: Install Java 8
command: |
sudo apt update
sudo apt install software-properties-common apt-transport-https
wget -qO - https://adoptopenjdk.jfrog.io/adoptopenjdk/api/gpg/key/public | sudo apt-key add -
sudo add-apt-repository --yes https://adoptopenjdk.jfrog.io/adoptopenjdk/deb/
sudo apt update
sudo apt install adoptopenjdk-8-hotspot
sudo update-alternatives --set java /usr/lib/jvm/adoptopenjdk-8-hotspot-amd64/bin/java
#set timezone to est
- run:
name: Set Timezone to EST
command: echo 'America/New_York' = /etc/timezone
# Install Bundler
- run: gem install bundler -v '2.2.14'
# Restore bundle cache
- restore_cache:
keys:
- orangelight-{{ checksum "Gemfile.lock" }}
- orangelight-
# Bundle install dependencies
- run:
name: Install dependencies
command: bundle check --path=vendor/bundle || bundle install --path=vendor/bundle --jobs 4 --retry 3
- run:
name: Install Chrome
command: |
wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
sudo sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
sudo apt-get update
sudo apt-get -y install google-chrome-stable
- run: sudo apt install postgresql-client
- save_cache:
key: orangelight-{{ checksum "Gemfile.lock" }}
paths:
- ./vendor/bundle
# Only necessary if app uses webpacker or yarn in some other way
- restore_cache:
keys:
Expand All @@ -89,32 +84,66 @@ jobs:
key: orangelight-{{ checksum "yarn.lock" }}
paths:
- ~/.cache/yarn
- run:
name: Start Solr test instance
command: bundle exec rake server:test
background: true
- run: bin/jetty_wait
- run:
name: npm install
command: npm install
- persist_to_workspace:
root: '~/orangelight'
paths: '*'

test:
executor: orangelight-executor
steps:
- attach_workspace:
at: '~/orangelight'
- setup-bundler
- run:
name: Wait for DB
command: dockerize -wait tcp://localhost:5432 -timeout 1m
- run: sudo apt install postgresql-client
- run:
name: Database setup
command: bundle exec rake db:setup
#set timezone to est
- run:
name: Run rubocop
command: bundle exec rake rubocop
name: Set Timezone to EST
command: echo 'America/New_York' = /etc/timezone
- run:
name: Install Chrome
command: |
wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
sudo sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
sudo apt-get update
sudo apt-get -y install google-chrome-stable
- run:
name: Load config into solr
command: |
cd solr/conf
zip -1 -r solr_config.zip ./*
curl -H "Content-type:application/octet-stream" --data-binary @solr_config.zip "http://solr:[email protected]:8983/solr/admin/configs?action=UPLOAD&name=orangelight"
curl -H 'Content-type: application/json' http://solr:[email protected]:8983/api/collections/ -d '{create: {name: orangelight-core-test, config: orangelight, numShards: 1}}'
- run:
name: Index Test Data
command: bundle exec rake pulsearch:solr:index
- run:
name: Run Rspec
command: bundle exec rspec spec
- run:
name: Run JS unit tests
command: bundle exec yarn test

rubocop:
executor: basic-executor
steps:
- attach_workspace:
at: '~/orangelight'
- setup-bundler
- run: bundle exec rubocop

workflows:
version: 2
build_accept_deploy:
build_accept:
jobs:
- build

- rubocop:
requires:
- build
- test:
requires:
- build
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ coverage/
.byebug_history
# Ignore dreaded .DS_Store
.DS_Store
# Ignore sorl config and libs downloaded from https://github.com/pulibrary/pul_solr/
solr/conf/*.txt
solr/conf/*.xml
solr/conf/*.jar

/public/packs
/public/packs-test
/node_modules
Expand Down
10 changes: 8 additions & 2 deletions .lando.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
name: orangelight
services:
orangelight_test_solr:
type: solr:8.4
type: solr:custom
overrides:
image: pulibrary/orangelight-solr:8.4
command: server/scripts/lando-start.sh
portforward: true
core: orangelight-core-test
config:
dir: "solr/conf"
orangelight_development_solr:
type: solr:8.4
type: solr:custom
overrides:
image: pulibrary/orangelight-solr:8.4
command: server/scripts/lando-start.sh
portforward: true
core: orangelight-core-dev
config:
Expand Down
1 change: 0 additions & 1 deletion .solr_wrapper

This file was deleted.

1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ gem 'faraday', '~> 0.17'
gem 'faraday-cookie_jar'
gem 'global'
gem 'omniauth-cas'
gem 'solr_wrapper', '~> 2.0'
gem 'yajl-ruby', '>= 1.3.1', require: 'yajl'

gem 'babel-transpiler'
Expand Down
7 changes: 0 additions & 7 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,6 @@ GEM
responders (3.0.1)
actionpack (>= 5.0)
railties (>= 5.0)
retriable (3.1.2)
reverse_markdown (1.4.0)
nokogiri
rsolr (2.2.1)
Expand Down Expand Up @@ -494,11 +493,6 @@ GEM
thor (~> 0.19, >= 0.19.4)
tilt (~> 2.0)
yard (~> 0.9)
solr_wrapper (2.2.0)
faraday
retriable
ruby-progressbar
rubyzip
spring (2.1.0)
sprockets (3.7.2)
concurrent-ruby (~> 1.0)
Expand Down Expand Up @@ -628,7 +622,6 @@ DEPENDENCIES
sitemap_generator (~> 6.0)
sneakers
solargraph
solr_wrapper (~> 2.0)
spring
sprockets-es6
string_rtl
Expand Down
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,14 @@ it to the bottom of `spec/fixtures/current_fixtures.json`. Note that file
contains a list so you have to make sure you add a comma to the end of the last
record and keep the closing bracket at the end of the file. Then run `rake pulsearch:solr:index` for both the dev and the test environment, as specified above.

## Update Solr configuration

Run the following command to update pull in Solr configuration updates from the pul_solr repo:

```bash
rake pulsearch:solr:update
```

## Local development with Figgy

Orangelight is configured to use two environment variables in order to query and retrieve [IIIF Manifests](https://iiif.io/api/presentation/2.1/#manifest) for resources linked to catalog records in the [Figgy digital object repository](https://github.com/pulibrary/figgy). By default, these are provided with the following values:
Expand All @@ -110,7 +118,7 @@ GRAPHQL_API_URL=https://figgy-staging.princeton.edu/graphql FIGGY_URL=https://fi

To start up a copy of the project with a solr index of fixture data
```bash
bundle exec rake server
rake servers:start
```
Then, in another terminal window build browse index csv files in /tmp:
```bash
Expand Down
4 changes: 0 additions & 4 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
require File.expand_path('../config/application', __FILE__)

require 'rubocop/rake_task' if Rails.env.development? || Rails.env.test?
require 'solr_wrapper/rake_task'
require 'honeybadger/init/ruby'
require 'sneakers/tasks'

Expand All @@ -19,6 +18,3 @@ if defined? RuboCop
desc 'Run test suite and style checker'
task spec: :rubocop
end

Rake::Task[:default].clear
task default: :ci
2 changes: 1 addition & 1 deletion config/blacklight.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ development:
url: <%= ENV['SOLR_URL'] || "http://#{ENV["lando_orangelight_development_solr_conn_host"] || "127.0.0.1"}:#{ENV["lando_orangelight_development_solr_conn_port"] || 8983}/solr/orangelight-core-dev" %>
test: &test
adapter: solr
url: <%= "http://#{ENV["lando_orangelight_test_solr_conn_host"] || "127.0.0.1"}:#{ENV['SOLR_TEST_PORT'] || ENV["lando_orangelight_test_solr_conn_port"] || 8888}/solr/orangelight-core-test" %>
url: <%= ENV['SOLR_URL'] || "http://#{ENV["lando_orangelight_test_solr_conn_host"] || "127.0.0.1"}:#{ENV['SOLR_TEST_PORT'] || ENV["lando_orangelight_test_solr_conn_port"] || 8888}/solr/orangelight-core-test" %>
staging:
adapter: solr
url: <%= ENV['SOLR_URL'] || "http://127.0.0.1:8983/solr/blacklight-core" %>
Expand Down
30 changes: 24 additions & 6 deletions lib/orangelight/browse_lists.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,44 @@ def connection
port = config['port']
sql_command = "PGPASSWORD=#{password} psql -U #{dbuser} -h #{dbhost} -p #{port} #{dbname} -c"

# changes for different facet queries
facet_request = "#{core_url}select?q=*%3A*&fl=id&wt=json&indent=true&defType=edismax&facet.sort=asc&facet.limit=-1&facet.field="
solr_url = Blacklight.connection_config[:url]

conn = Faraday.new(url: solr_url) do |faraday|
conn = Faraday.new(url: solr_connection.to_s) do |faraday|
faraday.options[:open_timeout] = 2000
faraday.options[:timeout] = 2000
faraday.request :url_encoded # form-encode POST params
faraday.response :logger # log requests to STDOUT
faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
faraday.basic_auth(solr_user, solr_password) if basic_auth? # enable Solr auth
end

[sql_command, facet_request, conn]
end

def facet_request
"#{core_url}select?q=*%3A*&fl=id&wt=json&indent=true&defType=edismax&facet.sort=asc&facet.limit=-1&facet.field="
end

def solr_connection
Blacklight.default_index.connection.uri
end

def solr_user
solr_connection.user
end

def solr_password
solr_connection.password
end

def basic_auth?
solr_user && solr_password
end

def output_root
Pathname.new('/tmp')
end

def core_url
Blacklight.default_index.connection.uri.to_s.gsub(%r{^.*\/solr}, '/solr')
solr_connection.to_s.gsub(%r{^.*\/solr}, '/solr')
end

def browse_facet(_sql_command, facet_request, conn, facet_field, table_name)
Expand Down
Loading