Skip to content

Commit

Permalink
Merge 1ab2d0e into 9fc616b
Browse files Browse the repository at this point in the history
  • Loading branch information
jmartin-sul committed Oct 11, 2018
2 parents 9fc616b + 1ab2d0e commit d507278
Show file tree
Hide file tree
Showing 27 changed files with 89 additions and 60 deletions.
4 changes: 4 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Naming/FileName:
Exclude:
- 'Capfile'
- 'Gemfile'
- 'lib/capistrano/tasks/capistrano-resque-pool.rake'

Rails/HasAndBelongsToMany:
Enabled: false
Expand All @@ -56,6 +57,9 @@ RSpec/ContextWording:
RSpec/ExampleLength:
Max: 25

RSpec/ImplicitSubject: # we use this for `define_enum_for`, `validate_presence_of`, etc.
Enabled: false

# we like 'expect(x).to receive' better than 'have_received'
RSpec/MessageSpies:
Enabled: false
Expand Down
84 changes: 42 additions & 42 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,17 @@ GEM
arel (8.0.0)
ast (2.4.0)
aws-eventstream (1.0.1)
aws-partitions (1.96.0)
aws-sdk-core (3.23.0)
aws-partitions (1.105.0)
aws-sdk-core (3.30.0)
aws-eventstream (~> 1.0)
aws-partitions (~> 1.0)
aws-sigv4 (~> 1.0)
jmespath (~> 1.0)
aws-sdk-kms (1.7.0)
aws-sdk-core (~> 3)
aws-sdk-kms (1.9.0)
aws-sdk-core (~> 3, >= 3.26.0)
aws-sigv4 (~> 1.0)
aws-sdk-s3 (1.17.0)
aws-sdk-core (~> 3, >= 3.21.2)
aws-sdk-s3 (1.21.0)
aws-sdk-core (~> 3, >= 3.26.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.0)
aws-sigv4 (1.0.3)
Expand Down Expand Up @@ -146,29 +146,29 @@ GEM
dry-equalizer (~> 0.2)
dry-inflector (~> 0.1, >= 0.1.2)
dry-logic (~> 0.4, >= 0.4.2)
dry-validation (0.12.1)
dry-validation (0.12.2)
concurrent-ruby (~> 1.0)
dry-configurable (~> 0.1, >= 0.1.3)
dry-core (~> 0.2, >= 0.2.1)
dry-equalizer (~> 0.2)
dry-logic (~> 0.4, >= 0.4.0)
dry-types (~> 0.13.1)
erubi (1.7.1)
factory_bot (4.10.0)
factory_bot (4.11.1)
activesupport (>= 3.0.0)
factory_bot_rails (4.10.0)
factory_bot (~> 4.10.0)
factory_bot_rails (4.11.1)
factory_bot (~> 4.11.1)
railties (>= 3.0.0)
faraday (0.15.2)
faraday (0.15.3)
multipart-post (>= 1.2, < 3)
ffi (1.9.25)
globalid (0.4.1)
activesupport (>= 4.2.0)
hashdiff (0.3.7)
hashie (3.5.7)
hashie (3.6.0)
hirb (0.7.3)
honeybadger (3.3.0)
i18n (1.0.1)
honeybadger (4.0.0)
i18n (1.1.0)
concurrent-ruby (~> 1.0)
jaro_winkler (1.5.1)
jbuilder (2.7.0)
Expand All @@ -186,7 +186,7 @@ GEM
mail (2.7.0)
mini_mime (>= 0.1.1)
method_source (0.9.0)
mini_mime (1.0.0)
mini_mime (1.0.1)
mini_portile2 (2.3.0)
minitest (5.11.3)
moab-versioning (4.2.2)
Expand All @@ -198,7 +198,7 @@ GEM
mono_logger (1.1.0)
multi_json (1.13.1)
multipart-post (2.0.0)
mustermann (1.0.2)
mustermann (1.0.3)
net-http-persistent (3.0.0)
connection_pool (~> 2.2)
net-scp (1.2.1)
Expand All @@ -207,13 +207,13 @@ GEM
nio4r (2.3.1)
nokogiri (1.8.5)
mini_portile2 (~> 2.3.0)
nokogiri-happymapper (0.6.0)
nokogiri-happymapper (0.8.0)
nokogiri (~> 1.5)
okcomputer (1.17.2)
okcomputer (1.17.3)
parallel (1.12.1)
parser (2.5.1.2)
ast (~> 2.4.0)
pg (1.0.0)
pg (1.1.3)
powerpack (0.1.2)
pry (0.11.3)
coderay (~> 1.1.0)
Expand All @@ -223,12 +223,12 @@ GEM
pry (~> 0.10)
pry-rails (0.3.6)
pry (>= 0.10.4)
public_suffix (3.0.2)
public_suffix (3.0.3)
puma (3.12.0)
rack (2.0.5)
rack-protection (2.0.3)
rack-protection (2.0.4)
rack
rack-test (1.0.0)
rack-test (1.1.0)
rack (>= 1.0, < 3)
rails (5.1.6)
actioncable (= 5.1.6)
Expand Down Expand Up @@ -262,7 +262,7 @@ GEM
rb-fsevent (0.10.3)
rb-inotify (0.9.10)
ffi (>= 0.5.0, < 2)
redis (4.0.1)
redis (4.0.2)
redis-namespace (1.6.0)
redis (>= 3.0.4)
resque (1.27.4)
Expand All @@ -276,46 +276,46 @@ GEM
rake
resque (~> 1.22)
retries (0.0.5)
rspec-core (3.7.1)
rspec-support (~> 3.7.0)
rspec-expectations (3.7.0)
rspec-core (3.8.0)
rspec-support (~> 3.8.0)
rspec-expectations (3.8.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.7.0)
rspec-mocks (3.7.0)
rspec-support (~> 3.8.0)
rspec-mocks (3.8.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.7.0)
rspec-rails (3.7.2)
rspec-support (~> 3.8.0)
rspec-rails (3.8.0)
actionpack (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
rspec-core (~> 3.7.0)
rspec-expectations (~> 3.7.0)
rspec-mocks (~> 3.7.0)
rspec-support (~> 3.7.0)
rspec-support (3.7.1)
rubocop (0.58.2)
rspec-core (~> 3.8.0)
rspec-expectations (~> 3.8.0)
rspec-mocks (~> 3.8.0)
rspec-support (~> 3.8.0)
rspec-support (3.8.0)
rubocop (0.59.2)
jaro_winkler (~> 1.5.1)
parallel (~> 1.10)
parser (>= 2.5, != 2.5.1.1)
powerpack (~> 0.1)
rainbow (>= 2.2.2, < 4.0)
ruby-progressbar (~> 1.7)
unicode-display_width (~> 1.0, >= 1.0.1)
rubocop-rspec (1.27.0)
rubocop (>= 0.56.0)
rubocop-rspec (1.30.0)
rubocop (>= 0.58.0)
ruby-prof (0.17.0)
ruby-progressbar (1.9.0)
ruby-progressbar (1.10.0)
ruby_dep (1.5.0)
safe_yaml (1.0.4)
simplecov (0.16.1)
docile (~> 1.1)
json (>= 1.8, < 3)
simplecov-html (~> 0.10.0)
simplecov-html (0.10.2)
sinatra (2.0.3)
sinatra (2.0.4)
mustermann (~> 1.0)
rack (~> 2.0)
rack-protection (= 2.0.3)
rack-protection (= 2.0.4)
tilt (~> 2.0)
sprockets (3.7.2)
concurrent-ruby (~> 1.0)
Expand Down Expand Up @@ -385,4 +385,4 @@ DEPENDENCIES
whenever

BUNDLED WITH
1.16.3
1.16.6
2 changes: 2 additions & 0 deletions app/controllers/catalog_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,14 @@ def incoming_size

def moab_storage_root
return unless poh_params[:storage_location]

MoabStorageRoot.find_by(storage_location: "#{poh_params[:storage_location]}/#{Moab::Config.storage_trunk}")
end

# @return boolean
def checksums_validated
return poh_params[:checksums_validated].casecmp('true').zero? if poh_params[:checksums_validated]

false
end
end
1 change: 1 addition & 0 deletions app/jobs/application_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class ApplicationJob < ActiveJob::Base
# @option metadata [String] :zip_version
def zip_info_check!(metadata)
raise ArgumentError, 'metadata Hash not found' if metadata.blank?

%i[checksum_md5 size zip_cmd zip_version].each do |key|
raise ArgumentError, "Required metadata[:#{key}] not found" if metadata[key].blank?
end
Expand Down
1 change: 1 addition & 0 deletions app/jobs/moab_replication_audit_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def perform(complete_moab)

complete_moab.zipped_moab_versions.each do |zmv|
next unless check_child_zip_part_attributes(zmv, results)

check_aws_replicated_zipped_moab_version(zmv, results)
end

Expand Down
1 change: 1 addition & 0 deletions app/jobs/results_recorder_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def perform(druid, version, s3_part_key, _delivery_class)
part.ok!
# only publish result if all of the parts replicated for all zip_endpoints
return unless zmvs.reload.all?(&:all_parts_replicated?)

publish_result(message(druid, version).to_json)
end

Expand Down
2 changes: 2 additions & 0 deletions app/jobs/s3_west_delivery_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ class S3WestDeliveryJob < ZipPartJobBase
def perform(druid, version, part_s3_key, metadata)
s3_part = bucket.object(part_s3_key) # Aws::S3::Object
return if s3_part.exists?

fresh_md5 = dvz_part.read_md5
given_md5 = metadata[:checksum_md5]
raise "#{part_s3_key} MD5 mismatch: passed #{given_md5}, computed #{fresh_md5}" unless fresh_md5 == given_md5

s3_part.upload_file(dvz_part.file_path, metadata: stringify_values(metadata))
ResultsRecorderJob.perform_later(druid, version, part_s3_key, self.class.to_s)
end
Expand Down
1 change: 1 addition & 0 deletions app/lib/audit/catalog_to_moab.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def check_catalog_version

def online_moab_found?
return true if moab

false
end

Expand Down
1 change: 1 addition & 0 deletions app/lib/preservation_catalog/s3/audit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def check_aws_replicated_zipped_moab_version
aws_s3_object = bucket.object(part.s3_key)
next unless check_existence(aws_s3_object, part)
next unless compare_checksum_metadata(aws_s3_object, part)

part.ok!
end
end
Expand Down
1 change: 1 addition & 0 deletions app/models/complete_moab.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ def matches_po_current_version?

private_class_method def self.normalize_date(timestamp)
return timestamp if timestamp.is_a?(Time) || timestamp.is_a?(ActiveSupport::TimeWithZone)

Time.parse(timestamp).utc
end

Expand Down
3 changes: 3 additions & 0 deletions app/models/druid_version_zip.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def ensure_zip_directory!
# @return [Array<String>] Ordered pathnames expected to correspond to a zip broken into a given number of parts
def expected_part_keys(count = 1)
raise ArgumentError, "count (#{count}) must be >= 1" if count < 1

[s3_key].concat(
(1..(count - 1)).map { |n| base_key + format('.z%02d', n) }
)
Expand Down Expand Up @@ -135,7 +136,9 @@ def fetch_zip_version
re = zip_version_regexp
io.find { |line| match = line.match(re) }
end

return match[1] if match && match[1].present?

raise 'No version info matched from `zip -v` ouptut'
end

Expand Down
1 change: 1 addition & 0 deletions app/models/zip_endpoint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class ZipEndpoint < ApplicationRecord
# TODO: figure out deletion/update based on config?
def self.seed_from_config(preservation_policies)
return unless Settings.zip_endpoints

Settings.zip_endpoints.map do |endpoint_name, endpoint_config|
find_or_create_by!(endpoint_name: endpoint_name.to_s) do |zip_endpoint|
zip_endpoint.endpoint_node = endpoint_config.endpoint_node
Expand Down
1 change: 1 addition & 0 deletions app/models/zip_part.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class ZipPart < ApplicationRecord
# @return [Boolean] true if all expected parts are now replicated
def all_parts_replicated?
return false unless persisted? && ok?

parts = zipped_moab_version.zip_parts.where(suffix: suffixes_in_set)
parts.count == parts_count && parts.all?(&:ok?)
end
Expand Down
1 change: 1 addition & 0 deletions app/models/zipped_moab_version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def all_parts_replicated?
# @return [ZipmakerJob, nil] nil if unpersisted or parent PC has non-replicatable status
def replicate!
return nil unless persisted? && complete_moab.replicatable_status?

ZipmakerJob.perform_later(preserved_object.druid, version)
end
end
1 change: 1 addition & 0 deletions app/services/audit_results.rb
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ def result_hash(code, msg_args=nil)

def report_errors_to_workflows(candidate_workflow_results)
return if candidate_workflow_results.empty?

msg = "#{workflows_msg_prefix} #{candidate_workflow_results.map(&:values).flatten.join(' && ')}"
WorkflowReporter.report_error(druid, 'preservation-audit', msg)
end
Expand Down
1 change: 1 addition & 0 deletions app/services/checksum_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ def validate_manifest_inventory(moab_version)

def parse_verification_subentities(manifest_inventory_verification_result)
return if manifest_inventory_verification_result.verified

manifest_inventory_verification_result.subentities.each do |subentity|
parse_verification_subentity(subentity) unless subentity.verified
end
Expand Down
1 change: 1 addition & 0 deletions app/services/moab_validation_handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def ran_moab_validation?
def update_status(new_status)
complete_moab.status = new_status
return unless complete_moab.status_changed?

results.add_result(
AuditResults::CM_STATUS_CHANGED, old_status: complete_moab.status_was, new_status: complete_moab.status
)
Expand Down
2 changes: 2 additions & 0 deletions app/services/preserved_object_handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -320,13 +320,15 @@ def version_string_to_int(val)
return result if result.instance_of?(Integer)
# accommodate 'vnnn' strings from Moab version directories
return val[1..-1].to_i if val.instance_of?(String) && val.match(/^v\d+$/)

val
end

def string_to_int(val)
return if val.blank?
return val if val.instance_of?(Integer) # NOTE: negative integers caught with validation
return val.to_i if val.instance_of?(String) && val.scan(/\D/).empty?

val
end
end
5 changes: 4 additions & 1 deletion config/initializers/okcomputer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@ def check
mark_message msg
end

private

# @return [String] message
private def table_check(klass)
def table_check(klass)
# has at least 1 record, using select(:id) to avoid returning all data
return "#{klass.name} has data." if klass.select(:id).first!.present?

mark_failure
"#{klass.name} has no data."
rescue ActiveRecord::RecordNotFound
Expand Down
6 changes: 3 additions & 3 deletions spec/factories/complete_moab.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
FactoryBot.define do
factory :complete_moab do
version 1
status 'ok'
size 231
version { 1 }
status { 'ok' }
size { 231 }
moab_storage_root
preserved_object
end
Expand Down

0 comments on commit d507278

Please sign in to comment.