-
Notifications
You must be signed in to change notification settings - Fork 20
Open
Description
valkyrie/lib/valkyrie/specs/shared_specs/storage_adapter.rb
Lines 55 to 72 in 814494d
| it "doesn't leave a file handle open on upload/find_by" do | |
| # No file handle left open from upload. | |
| resource = Valkyrie::Specs::CustomResource.new(id: "testdiscovery") | |
| pre_open_files = open_files | |
| uploaded_file = storage_adapter.upload(file: file, original_filename: 'foo.jpg', resource: resource, fake_upload_argument: true) | |
| file.close | |
| expect(pre_open_files.size).to eq open_files.size | |
| # No file handle left open from find_by | |
| pre_open_files = open_files | |
| the_file = storage_adapter.find_by(id: uploaded_file.id) | |
| expect(the_file).to be_kind_of Valkyrie::StorageAdapter::File | |
| expect(pre_open_files.size).to eq open_files.size | |
| end | |
| def open_files | |
| `lsof +D .`.split("\n").map { |r| r.split("\t").last } | |
| end |
This spec frequently fails, occasionally even during CI. This is also true for downstream application's custom storage adapters since this is a shared spec.
Currently the check uses lsof +D to list all open files within the application directory. Issues with this include:
lsofis an additional system level dependency- If a storage adapter stashes files in a location outside the application dir tree (e.g. /tmp) then those would be missed.
- Other (even non-ruby) processes are included in the open file list.
lsofitself notes that the+Dmode is inefficient and resource hungry.
Potential actions:
- Filter
open_filesto those with a PID that matchesProcess.pid - Use a more specific path
- Include additional paths like /tmp
- Remove the spec or make it a warning?
Metadata
Metadata
Assignees
Labels
No labels