Skip to content

Commit

Permalink
Merge 8896c3a into d025653
Browse files Browse the repository at this point in the history
  • Loading branch information
jmartin-sul committed Oct 16, 2018
2 parents d025653 + 8896c3a commit a4d5b2a
Show file tree
Hide file tree
Showing 16 changed files with 79 additions and 62 deletions.
7 changes: 7 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ Bundler/OrderedGems:
Exclude:
- 'Gemfile'

Layout/EmptyLineAfterGuardClause:
Enabled: false

Metrics/BlockLength:
Exclude:
- 'app/services/preserved_object_handler.rb' # FIXME check_existence shameless green
Expand All @@ -46,6 +49,7 @@ Naming/FileName:
Exclude:
- 'Capfile'
- 'Gemfile'
- 'lib/capistrano/tasks/capistrano-resque-pool.rake'

Rails/HasAndBelongsToMany:
Enabled: false
Expand All @@ -56,6 +60,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
88 changes: 44 additions & 44 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.1.0)
i18n (1.1.1)
concurrent-ruby (~> 1.0)
jaro_winkler (1.5.1)
jbuilder (2.7.0)
Expand All @@ -183,10 +183,10 @@ GEM
loofah (2.2.2)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.7.0)
mail (2.7.1)
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 All @@ -332,7 +332,7 @@ GEM
thor (0.19.4)
thread_safe (0.3.6)
tilt (2.0.8)
tins (1.16.3)
tins (1.17.0)
tzinfo (1.2.5)
thread_safe (~> 0.1)
unicode-display_width (1.4.0)
Expand Down Expand Up @@ -385,4 +385,4 @@ DEPENDENCIES
whenever

BUNDLED WITH
1.16.3
1.16.6
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/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/preservation_catalog/s3/audit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,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/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
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
6 changes: 3 additions & 3 deletions spec/factories/preservation_policy.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FactoryBot.define do
factory :preservation_policy do
preservation_policy_name 'default'
archive_ttl 7_776_000
fixity_ttl 7_776_000
preservation_policy_name { 'default' }
archive_ttl { 7_776_000 }
fixity_ttl { 7_776_000 }
end
end
2 changes: 1 addition & 1 deletion spec/factories/preserved_object.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FactoryBot.define do
factory :preserved_object do
sequence(:druid) { |n| 'bj102hs' + format('%04d', 9686 + n) } # start at bj102hs9687
current_version 1
current_version { 1 }
preservation_policy { PreservationPolicy.default_policy }
end

Expand Down
4 changes: 2 additions & 2 deletions spec/factories/zip_endpoints.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
factory :zip_endpoint do
sequence(:endpoint_name) { |n| "endpoint#{format('%02d', n)}" }
sequence(:endpoint_node) { |n| "us-west-#{format('%02d', n)}" }
storage_location 'bucket_name'
delivery_class 1
storage_location { 'bucket_name' }
delivery_class { 1 }
preservation_policies { [PreservationPolicy.default_policy] }
end
end
10 changes: 5 additions & 5 deletions spec/factories/zip_parts.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
FactoryBot.define do
factory :zip_part do
md5 "00236a2ae558018ed13b5222ef1bd977"
create_info "ok"
parts_count 1
size 1234
status 'unreplicated'
md5 { "00236a2ae558018ed13b5222ef1bd977" }
create_info { "ok" }
parts_count { 1 }
size { 1234 }
status { 'unreplicated' }
suffix { parts_count == 1 ? '.zip' : format('.z%02d', parts_count) }
zipped_moab_version
end
Expand Down
2 changes: 1 addition & 1 deletion spec/factories/zipped_moab_versions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Because ZMVs are auto-created in callback, you probably don't create from this factory directly.
# Instead create a :complete_moab and get the zipped_moab_versions from it
factory :zipped_moab_version do
version 1
version { 1 }
zip_endpoint
complete_moab
end
Expand Down
4 changes: 2 additions & 2 deletions spec/services/workflow_reporter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
full_url = 'https://workflows.example.org/workflow/dor/objects/druid:jj925bx9565/workflows/preservationAuditWF/moab-valid'
result = 'Invalid moab, validation error...ential version directories.'
body = "<?xml version=\"1.0\"?>\n<process name=\"moab-valid\" status=\"error\" errorMessage=\"#{result}\"/>\n"
headers = { 'User-Agent' => 'Faraday v0.15.2' }
headers = { 'User-Agent' => 'Faraday v0.15.3' }
druid = 'jj925bx9565'
process_name = 'moab-valid'

Expand All @@ -26,7 +26,7 @@
it 'returns true' do
full_url = 'https://workflows.example.org/workflow/dor/objects/druid:jj925bx9565/workflows/preservationAuditWF/preservation-audit'
body = "<?xml version=\"1.0\"?>\n<process name=\"preservation-audit\" status=\"completed\" elapsed=\"0\"/>\n"
headers = { 'User-Agent' => 'Faraday v0.15.2' }
headers = { 'User-Agent' => 'Faraday v0.15.3' }
druid = 'jj925bx9565'
process_name = 'preservation-audit'

Expand Down
1 change: 1 addition & 0 deletions spec/support/job_config.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
RSpec.configure do |config|
config.before do
next unless RSpec.current_example.metadata[:type] == :job

ActiveJob::Base.queue_adapter = :test
allow(ActiveJob::Base.logger).to receive(:info) # keep the default logging quiet
begin
Expand Down

0 comments on commit a4d5b2a

Please sign in to comment.