From 6f945f20b4c3683bc862ebc476bad9331d72784e Mon Sep 17 00:00:00 2001 From: Nick Thomas Date: Tue, 27 Feb 2018 19:15:25 +0000 Subject: Foreground verification of uploads and LFS objects --- spec/tasks/gitlab/lfs/check_rake_spec.rb | 28 ++++++++++++++++++++++++++++ spec/tasks/gitlab/uploads/check_rake_spec.rb | 28 ++++++++++++++++++++++++++++ spec/tasks/gitlab/uploads_rake_spec.rb | 27 --------------------------- 3 files changed, 56 insertions(+), 27 deletions(-) create mode 100644 spec/tasks/gitlab/lfs/check_rake_spec.rb create mode 100644 spec/tasks/gitlab/uploads/check_rake_spec.rb delete mode 100644 spec/tasks/gitlab/uploads_rake_spec.rb (limited to 'spec/tasks') diff --git a/spec/tasks/gitlab/lfs/check_rake_spec.rb b/spec/tasks/gitlab/lfs/check_rake_spec.rb new file mode 100644 index 00000000000..2610edf8bac --- /dev/null +++ b/spec/tasks/gitlab/lfs/check_rake_spec.rb @@ -0,0 +1,28 @@ +require 'rake_helper' + +describe 'gitlab:lfs rake tasks' do + describe 'check' do + let!(:lfs_object) { create(:lfs_object, :with_file, :correct_oid) } + + before do + Rake.application.rake_require('tasks/gitlab/lfs/check') + stub_env('VERBOSE' => 'true') + end + + it 'outputs the integrity check for each batch' do + expect { run_rake_task('gitlab:lfs:check') }.to output(/Failures: 0/).to_stdout + end + + it 'errors out about missing files on the file system' do + FileUtils.rm_f(lfs_object.file.path) + + expect { run_rake_task('gitlab:lfs:check') }.to output(/No such file.*#{Regexp.quote(lfs_object.file.path)}/).to_stdout + end + + it 'errors out about invalid checksum' do + File.truncate(lfs_object.file.path, 0) + + expect { run_rake_task('gitlab:lfs:check') }.to output(/Checksum mismatch/).to_stdout + end + end +end diff --git a/spec/tasks/gitlab/uploads/check_rake_spec.rb b/spec/tasks/gitlab/uploads/check_rake_spec.rb new file mode 100644 index 00000000000..5d597c66133 --- /dev/null +++ b/spec/tasks/gitlab/uploads/check_rake_spec.rb @@ -0,0 +1,28 @@ +require 'rake_helper' + +describe 'gitlab:uploads rake tasks' do + describe 'check' do + let!(:upload) { create(:upload, path: Rails.root.join('spec/fixtures/banana_sample.gif')) } + + before do + Rake.application.rake_require('tasks/gitlab/uploads/check') + stub_env('VERBOSE' => 'true') + end + + it 'outputs the integrity check for each batch' do + expect { run_rake_task('gitlab:uploads:check') }.to output(/Failures: 0/).to_stdout + end + + it 'errors out about missing files on the file system' do + missing_upload = create(:upload) + + expect { run_rake_task('gitlab:uploads:check') }.to output(/No such file.*#{Regexp.quote(missing_upload.absolute_path)}/).to_stdout + end + + it 'errors out about invalid checksum' do + upload.update_column(:checksum, '01a3156db2cf4f67ec823680b40b7302f89ab39179124ad219f94919b8a1769e') + + expect { run_rake_task('gitlab:uploads:check') }.to output(/Checksum mismatch/).to_stdout + end + end +end diff --git a/spec/tasks/gitlab/uploads_rake_spec.rb b/spec/tasks/gitlab/uploads_rake_spec.rb deleted file mode 100644 index ac0005e51e0..00000000000 --- a/spec/tasks/gitlab/uploads_rake_spec.rb +++ /dev/null @@ -1,27 +0,0 @@ -require 'rake_helper' - -describe 'gitlab:uploads rake tasks' do - describe 'check' do - let!(:upload) { create(:upload, path: Rails.root.join('spec/fixtures/banana_sample.gif')) } - - before do - Rake.application.rake_require 'tasks/gitlab/uploads' - end - - it 'outputs the integrity check for each uploaded file' do - expect { run_rake_task('gitlab:uploads:check') }.to output(/Checking file \(#{upload.id}\): #{Regexp.quote(upload.absolute_path)}/).to_stdout - end - - it 'errors out about missing files on the file system' do - create(:upload) - - expect { run_rake_task('gitlab:uploads:check') }.to output(/File does not exist on the file system/).to_stdout - end - - it 'errors out about invalid checksum' do - upload.update_column(:checksum, '01a3156db2cf4f67ec823680b40b7302f89ab39179124ad219f94919b8a1769e') - - expect { run_rake_task('gitlab:uploads:check') }.to output(/File checksum \(9e697aa09fe196909813ee36103e34f721fe47a5fdc8aac0e4e4ac47b9b38282\) does not match the one in the database \(#{upload.checksum}\)/).to_stdout - end - end -end -- cgit v1.2.3