summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorBob Van Landuyt <bob@vanlanduyt.co>2017-08-03 16:22:52 +0200
committerBob Van Landuyt <bob@vanlanduyt.co>2017-08-04 15:38:50 +0200
commit4b34720c0ca8b5459cc56a4e52e11e213ab6ae9a (patch)
treee1933965092a34fa266458d03b76a74c3c998f1d /spec
parent3a2aaed881f8925b08acd4204f3e130939c73946 (diff)
downloadgitlab-ce-4b34720c0ca8b5459cc56a4e52e11e213ab6ae9a.tar.gz
Use ruby's `File.stat` to check storage availability
Diffstat (limited to 'spec')
-rw-r--r--spec/lib/gitlab/git/storage/forked_storage_check_spec.rb15
1 files changed, 12 insertions, 3 deletions
diff --git a/spec/lib/gitlab/git/storage/forked_storage_check_spec.rb b/spec/lib/gitlab/git/storage/forked_storage_check_spec.rb
index 20cee123ede..12366151f44 100644
--- a/spec/lib/gitlab/git/storage/forked_storage_check_spec.rb
+++ b/spec/lib/gitlab/git/storage/forked_storage_check_spec.rb
@@ -17,11 +17,20 @@ describe Gitlab::Git::Storage::ForkedStorageCheck, skip_database_cleaner: true d
end
it 'returns false when the check takes to long' do
- allow(described_class).to receive(:check_filesystem_in_fork) do
- fork { sleep 10 }
+ # We're forking a process here that takes too long
+ # It will be killed it's parent process will be killed by it's parent
+ # and waited for inside `Gitlab::Git::Storage::ForkedStorageCheck.timeout_check`
+ allow(described_class).to receive(:check_filesystem_in_process) do
+ Process.spawn("sleep 10")
end
+ result = true
- expect(described_class.storage_available?(existing_path, 0.5)).to be_falsey
+ runtime = Benchmark.realtime do
+ result = described_class.storage_available?(existing_path, 0.5)
+ end
+
+ expect(result).to be_falsey
+ expect(runtime).to be < 1.0
end
describe 'when using paths with spaces' do