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

Json-canonicalization test build #6501

Draft
wants to merge 8 commits into
base: 4.x-stable
Choose a base branch
from
Draft
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
372 changes: 162 additions & 210 deletions .circleci/config.yml

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion .dassie/.env
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ HYRAX_DERIVATIVES_PATH=/app/samvera/hyrax-webapp/derivatives/
HYRAX_ENGINE_PATH=/app/samvera/hyrax-engine
HYRAX_UPLOAD_PATH=/app/samvera/hyrax-webapp/uploads/
IN_DOCKER=true
KARMA_BROWSER=ChromiumHeadlessCustom
KARMA_BROWSER=remote-chromium
KARMA_HOSTNAME=app
MEMCACHED_HOST=memcached
RACK_ENV=development
RAILS_ENV=development
Expand Down
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ chart/*

Gemfile.lock
.dassie/Gemfile.lock

node_modules/*
yarn.lock
2 changes: 2 additions & 0 deletions .koppie/.env
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ HYRAX_ENGINE_PATH=/app/samvera/hyrax-engine
HYRAX_UPLOAD_PATH=/app/samvera/hyrax-webapp/uploads/
HYRAX_VALKYRIE=true
IN_DOCKER=true
KARMA_BROWSER=remote-chromium
KARMA_HOSTNAME=app
METADATA_DATABASE_NAME=koppie_metadata_development
POSTGRES_DB=koppie
POSTGRES_HOST_AUTH_METHOD=trust
Expand Down
8 changes: 5 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,17 @@ services:
- hyrax

chrome:
image: selenium/standalone-chrome:3.141
image: seleniarm/standalone-chromium:114.0
environment:
- START_XVFB=false
logging:
driver: none
volumes:
- /dev/shm:/dev/shm
shm_size: 2G
ports:
- "4444:4444"
- "5959:5900"
- "4445:4444"
- "5960:5900"
networks:
- hyrax

Expand Down
1 change: 0 additions & 1 deletion hyrax.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,5 @@ SUMMARY
spec.add_development_dependency 'bixby', '~> 5.0', '>= 5.0.2' # bixby 5 briefly dropped Ruby 2.5
spec.add_development_dependency 'shoulda-callback-matchers', '~> 1.1.1'
spec.add_development_dependency 'shoulda-matchers', '~> 3.1'
spec.add_development_dependency 'webdrivers', '~> 4.4'
spec.add_development_dependency 'webmock'
end
19 changes: 9 additions & 10 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module.exports = function(config) {
},

// list of files / patterns to load in the browser
// uses dotenv to allow for .internal_test_app or .dassie as the Rails root
// uses dotenv to allow for .dassie as the Rails root

files: [
{pattern: 'spec/javascripts/fixtures/*.html', watched: true, included: false, served: true},
Expand Down Expand Up @@ -66,6 +66,7 @@ module.exports = function(config) {
},

// web server port
hostname: process.env.KARMA_HOSTNAME || 'localhost', // This is the host the remote browser connects to
port: 9876,

// enable / disable colors in the output (reporters and logs)
Expand All @@ -80,16 +81,14 @@ module.exports = function(config) {

// start these browsers
// available browser launchers: https://www.npmjs.com/search?q=keywords:karma-launcher
browsers: [process.env.KARMA_BROWSER],
browsers: [process.env.KARMA_BROWSER || 'ChromiumHeadless'],

customLaunchers: {
ChromiumHeadlessCustom: {
base: 'ChromiumHeadless',
flags: ['--no-sandbox']
},
ChromeHeadlessCustom: {
base: 'ChromeHeadless',
flags: ['--no-sandbox']
'remote-chromium': {
base: 'SeleniumGrid',
gridUrl: process.env.HUB_URL || 'http://localhost:4444/wd/hub',
browserName: 'chrome',
arguments: [ '--headless=new']
}
},

Expand All @@ -99,6 +98,6 @@ module.exports = function(config) {

// Concurrency level
// how many browser instances should be started simultaneously
concurrency: 4
concurrency: 1
})
}
63 changes: 26 additions & 37 deletions lib/hyrax/specs/capybara.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,54 +15,43 @@ def after_teardown
require 'capybara/rails'
require 'capybara-screenshot/rspec'
require 'selenium-webdriver'
require 'webdrivers' unless ENV['IN_DOCKER'].present? || ENV['HUB_URL'].present?

Capybara.save_path = ENV['CI'] ? "/tmp/test-results" : Rails.root.join('tmp', 'capybara')

if ENV['IN_DOCKER'].present? || ENV['HUB_URL'].present?
args = %w[disable-gpu no-sandbox whitelisted-ips window-size=1400,1400]
args.push('headless') if ActiveModel::Type::Boolean.new.cast(ENV['CHROME_HEADLESS_MODE'])

options = Selenium::WebDriver::Options.chrome("goog:chromeOptions" => { args: args })

Capybara.register_driver :selenium_chrome_headless_sandboxless do |app|
driver = Capybara::Selenium::Driver.new(app,
browser: :remote,
capabilities: options,
url: ENV['HUB_URL'])
options = Selenium::WebDriver::Chrome::Options.new.tap do |opts|
opts.add_argument("--headless") if ENV["CHROME_HEADLESS_MODE"]
opts.add_argument("--disable-gpu") if Gem.win_platform?
# Workaround https://bugs.chromium.org/p/chromedriver/issues/detail?id=2650&q=load&sort=-id&colspec=ID%20Status%20Pri%20Owner%20Summary
opts.add_argument("--disable-site-isolation-trials")
opts.add_argument("--window-size=1440,1440")
opts.add_argument("--enable-features=NetworkService,NetworkServiceInProcess")
opts.add_argument("--disable-features=VizDisplayCompositor")
end

# Fix for capybara vs remote files. Selenium handles this for us
driver.browser.file_detector = lambda do |args|
str = args.first.to_s
str if File.exist?(str)
end
Capybara.register_driver :selenium_chrome_headless_sandboxless do |app|
driver = Capybara::Selenium::Driver.new(app,
browser: :remote,
capabilities: options,
url: ENV['HUB_URL'])

driver
# Fix for capybara vs remote files. Selenium handles this for us
driver.browser.file_detector = lambda do |args|
str = args.first.to_s
str if File.exist?(str)
end

Capybara.server_host = '0.0.0.0'
Capybara.server_port = 3010

ip = IPSocket.getaddress(Socket.gethostname)
Capybara.app_host = "http://#{ip}:#{Capybara.server_port}"
else
TEST_HOST = 'localhost:3000'.freeze
# @note In January 2018, TravisCI disabled Chrome sandboxing in its Linux
# container build environments to mitigate Meltdown/Spectre
# vulnerabilities, at which point Hyrax could no longer use the
# Capybara-provided :selenium_chrome_headless driver (which does not
# include the `--no-sandbox` argument).
Capybara.register_driver :selenium_chrome_headless_sandboxless do |app|
browser_options = ::Selenium::WebDriver::Chrome::Options.new
browser_options.args << '--headless'
browser_options.args << '--disable-gpu'
browser_options.args << '--no-sandbox'
Capybara::Selenium::Driver.new(app, browser: :chrome, options: browser_options)
end
driver
end

Capybara.server_host = '0.0.0.0'
Capybara.server_port = 3010

ip = IPSocket.getaddress(Socket.gethostname)
Capybara.app_host = "http://#{ip}:#{Capybara.server_port}"

Capybara.default_driver = :rack_test # This is a faster driver
Capybara.javascript_driver = :selenium_chrome_headless_sandboxless # This is slower
Capybara.disable_animation = true
Capybara.default_max_wait_time = ENV.fetch('CAPYBARA_WAIT_TIME', 10) # We may have a slow application, let's give it some time.

Capybara::Screenshot.register_driver(:selenium_chrome_headless_sandboxless) do |driver, path|
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
"karma-chrome-launcher": "^3.1.1",
"karma-coffee-preprocessor": "^1.0.1",
"karma-jasmine": "^4.0.2",
"karma-spec-reporter": "^0.0.34"
"karma-selenium-grid-launcher": "^0.3.0",
"karma-spec-reporter": "^0.0.34",
"selenium-webdriver": "^4.10.0"
}
}
2 changes: 1 addition & 1 deletion spec/features/create_work_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
# puts "Agreement : #{page.evaluate_script(%{$('#form-progress').data('save_work_control').depositAgreement.isAccepted})}"
click_on('Save')
expect(page).to have_content('My Test Work')
expect(page).to have_content "Your files are being processed by Hyrax in the background."
expect(page).to have_content "Your files are being processed by #{I18n.t('hyrax.product_name')} in the background."
end
end

Expand Down
10 changes: 3 additions & 7 deletions spec/javascripts/jasmine_spec.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
# frozen_string_literal: true
require 'English'
require 'rake'

# Run the jasmine tests by running the karma javascript test framework
# The spec will fail if any jasmine tests fails.
RSpec.describe "Jasmine" do
before do
Rails.application.load_tasks
Rake::Task["assets:clobber"].invoke
Rake::Task["assets:precompile"].invoke
end

it "expects all jasmine tests to pass" do
# Ensure capybara is not using the remote browser
Capybara.using_driver(Capybara.javascript_driver) { Capybara.current_session.quit }

jasmine_out = `node_modules/karma/bin/karma start`

if $CHILD_STATUS.exitstatus == 0
Expand Down
6 changes: 2 additions & 4 deletions spec/jobs/valkyrie_ingest_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,11 @@
# programatically for a spec.
context "when in Valkyrie mode" do
it 'runs derivatives', index_adapter: :solr_index, perform_enqueued: true do
allow(ValkyrieCreateDerivativesJob).to receive(:perform_later).and_call_original
allow(Hyrax::ValkyrieUpload).to receive(:file).and_call_original
expect(Hyrax::ValkyrieUpload).to receive(:file).and_call_original
expect(ValkyrieCreateDerivativesJob).to receive(:perform_later)

described_class.perform_now(upload)

expect(Hyrax::ValkyrieUpload).to have_received(:file)
expect(ValkyrieCreateDerivativesJob).to have_received(:perform_later)
solr_doc = Hyrax.index_adapter.connection.get("select", params: { q: "id:#{file_set.id}" })["response"]["docs"].first
expect(solr_doc["thumbnail_path_ss"]).not_to be_empty
end
Expand Down