Skip to content

Commit

Permalink
Merge pull request #973 from samvera/test_fcrepo_6.5
Browse files Browse the repository at this point in the history
Support Fedora 6.5
  • Loading branch information
tpendragon authored Dec 6, 2024
2 parents 4aeffac + d69f4a1 commit 04c2039
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
environment:
CATALINA_OPTS: "-Djava.awt.headless=true -Dfile.encoding=UTF-8 -server -Xms512m -Xmx1024m -XX:NewSize=256m -XX:MaxNewSize=256m -XX:PermSize=256m -XX:MaxPermSize=256m -XX:+DisableExplicitGC"
JAVA_OPTIONS: "-Djetty.http.port=8998 -Dfcrepo.dynamic.jms.port=61618 -Dfcrepo.dynamic.stomp.port=61614"
- image: fcrepo/fcrepo:6.4.0
- image: fcrepo/fcrepo:6.5.1-RC3-tomcat9
environment:
CATALINA_OPTS: "-Djava.awt.headless=true -Dfile.encoding=UTF-8 -server -Xms512m -Xmx1024m -XX:NewSize=256m -XX:MaxNewSize=256m -XX:PermSize=256m -XX:MaxPermSize=256m -XX:+DisableExplicitGC -Dorg.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true"
JAVA_OPTS: "-Djetty.http.port=8978 -Dfcrepo.dynamic.jms.port=61619 -Dfcrepo.dynamic.stomp.port=61615 -Dorg.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true"
Expand Down
2 changes: 1 addition & 1 deletion .lando.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ services:
volumes:
fedora6:
services:
image: fcrepo/fcrepo:6.4.0
image: fcrepo/fcrepo:6.5.1-RC3-tomcat9
command:
- "catalina.sh"
- "run"
Expand Down
23 changes: 19 additions & 4 deletions lib/valkyrie/specs/shared_specs/storage_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,9 @@ def open_files
resource = Valkyrie::Specs::CustomResource.new(id: "test#{SecureRandom.uuid}")
sha1 = Digest::SHA1.file(file).to_s
size = file.size
expect(uploaded_file = storage_adapter.upload(file: file, original_filename: 'foo.jpg', resource: resource, fake_upload_argument: true)).to be_kind_of Valkyrie::StorageAdapter::File
uploaded_file = storage_adapter.upload(file: file, original_filename: 'foo.jpg', resource: resource, fake_upload_argument: true)

expect(uploaded_file).to be_kind_of Valkyrie::StorageAdapter::File
expect(uploaded_file).to respond_to(:checksum).with_keywords(:digests)
expect(uploaded_file).to respond_to(:valid?).with_keywords(:size, :digests)
expect(uploaded_file.checksum(digests: [Digest::SHA1.new])).to eq([sha1])
Expand Down Expand Up @@ -133,28 +134,42 @@ def open_files
# Deleting a version should leave the current versions
if storage_adapter.supports?(:version_deletion)
storage_adapter.delete(id: uploaded_file.version_id)
expect(storage_adapter.find_versions(id: uploaded_file.id).length).to eq 1
remnants = storage_adapter.find_versions(id: uploaded_file.id)
expect(remnants.length).to eq 1
expect(remnants.first.version_id).to eq new_version.version_id
expect { storage_adapter.find_by(id: uploaded_file.version_id) }.to raise_error Valkyrie::StorageAdapter::FileNotFound
end
current_length = storage_adapter.find_versions(id: new_version.id).length

# Restoring a previous version is just pumping its file into upload_version
newest_version = storage_adapter.upload_version(file: new_version, id: new_version.id)
current_length += 1
expect(newest_version.version_id).not_to eq new_version.id
expect(storage_adapter.find_by(id: newest_version.id).version_id).to eq newest_version.version_id

# I can restore a version twice
newest_version = storage_adapter.upload_version(file: new_version, id: new_version.id)
current_length += 1
expect(newest_version.version_id).not_to eq new_version.id
expect(storage_adapter.find_by(id: newest_version.id).version_id).to eq newest_version.version_id
expect(storage_adapter.find_versions(id: newest_version.id).length).to eq current_length + 2
expect(storage_adapter.find_versions(id: newest_version.id).length).to eq current_length

# Fedora 6.5 may not create versions when the timestamp is the same?
# See: https://fedora-repository.atlassian.net/browse/FCREPO-3958
sleep 1 if storage_adapter.supports?(:list_deleted_versions)

# NOTE: We originally wanted deleting the current record to push it into the
# versions history, but FCRepo 4/5/6 doesn't work that way, so we changed to
# instead make deleting delete everything.
storage_adapter.delete(id: new_version.id)
expect { storage_adapter.find_by(id: new_version.id) }.to raise_error Valkyrie::StorageAdapter::FileNotFound
expect(storage_adapter.find_versions(id: new_version.id).length).to eq 0

if storage_adapter.supports?(:list_deleted_versions)
expect(storage_adapter.find_versions(id: new_version.id).length).to eq current_length
else
expect(storage_adapter.find_versions(id: new_version.id).length).to eq 0
end

ensure
f&.close
end
Expand Down
8 changes: 6 additions & 2 deletions lib/valkyrie/storage/fedora.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ def supports?(feature)
return true if feature == :versions
# Fedora 6 auto versions and you can't delete versions.
return true if feature == :version_deletion && fedora_version < 6
# Fedora 6.5+ lists versions for deleted objects
return true if feature == :list_deleted_versions && fedora_version >= 6.5
false
end

Expand Down Expand Up @@ -88,7 +90,9 @@ def find_versions(id:)
version_list.map do |version|
id = valkyrie_identifier(uri: version["@id"])
perform_find(id: id, version_id: id)
end
rescue Valkyrie::StorageAdapter::FileNotFound
nil
end.compact
end

# Delete the file in Fedora associated with the given identifier.
Expand Down Expand Up @@ -211,7 +215,7 @@ def valkyrie_identifier(uri:)
# @return [IOProxy]
def response(id:)
response = connection.http.get(fedora_identifier(id: id))
raise Valkyrie::StorageAdapter::FileNotFound unless response.success?
raise Valkyrie::StorageAdapter::FileNotFound, "HTTP #{response.status} #{response.body}" unless response.success?
IOProxy.new(response.body)
end

Expand Down
2 changes: 1 addition & 1 deletion spec/valkyrie/storage/fedora_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ class Valkyrie::Specs::FedoraCustomResource < Valkyrie::Resource
wipe_fedora!(base_path: "test", fedora_version: 6)
end

let(:storage_adapter) { described_class.new(**fedora_adapter_config(base_path: 'test', fedora_version: 6)) }
let(:storage_adapter) { described_class.new(**fedora_adapter_config(base_path: 'test', fedora_version: 6.5)) }
let(:file) { fixture_file_upload('files/example.tif', 'image/tiff') }

it_behaves_like "a Valkyrie::StorageAdapter"
Expand Down

0 comments on commit 04c2039

Please sign in to comment.