2019-10-15 05:06:09 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-09-07 17:27:04 -04:00
|
|
|
require 'rake_helper'
|
|
|
|
|
|
|
|
describe 'gitlab:lfs namespace rake task' do
|
|
|
|
before :all do
|
2018-03-05 06:16:17 -05:00
|
|
|
Rake.application.rake_require 'tasks/gitlab/lfs/migrate'
|
2017-09-07 17:27:04 -04:00
|
|
|
end
|
|
|
|
|
2019-09-20 08:05:52 -04:00
|
|
|
context 'migration tasks' do
|
2018-02-02 08:59:43 -05:00
|
|
|
let(:local) { ObjectStorage::Store::LOCAL }
|
|
|
|
let(:remote) { ObjectStorage::Store::REMOTE }
|
2017-09-07 17:27:04 -04:00
|
|
|
|
2019-09-20 08:05:52 -04:00
|
|
|
before do
|
|
|
|
stub_lfs_object_storage(background_upload: false, direct_upload: false)
|
2017-09-07 17:27:04 -04:00
|
|
|
end
|
|
|
|
|
2019-09-20 08:05:52 -04:00
|
|
|
describe 'migrate' do
|
|
|
|
subject { run_rake_task('gitlab:lfs:migrate') }
|
|
|
|
|
|
|
|
let!(:lfs_object) { create(:lfs_object, :with_file) }
|
|
|
|
|
|
|
|
context 'object storage disabled' do
|
|
|
|
before do
|
|
|
|
stub_lfs_object_storage(enabled: false)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "doesn't migrate files" do
|
|
|
|
expect { subject }.not_to change { lfs_object.reload.file_store }
|
|
|
|
end
|
2017-09-07 17:27:04 -04:00
|
|
|
end
|
|
|
|
|
2019-09-20 08:05:52 -04:00
|
|
|
context 'object storage enabled' do
|
|
|
|
it 'migrates local file to object storage' do
|
|
|
|
expect { subject }.to change { lfs_object.reload.file_store }.from(local).to(remote)
|
|
|
|
end
|
2017-09-07 17:27:04 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-09-20 08:05:52 -04:00
|
|
|
describe 'migrate_to_local' do
|
|
|
|
subject { run_rake_task('gitlab:lfs:migrate_to_local') }
|
|
|
|
|
|
|
|
let(:lfs_object) { create(:lfs_object, :with_file, :object_storage) }
|
|
|
|
|
2017-09-07 17:27:04 -04:00
|
|
|
before do
|
2019-09-20 08:05:52 -04:00
|
|
|
stub_lfs_object_storage(background_upload: false, direct_upload: true)
|
2017-09-07 17:27:04 -04:00
|
|
|
end
|
|
|
|
|
2019-09-20 08:05:52 -04:00
|
|
|
context 'object storage enabled' do
|
|
|
|
it 'migrates remote files to local storage' do
|
|
|
|
expect { subject }.to change { lfs_object.reload.file_store }.from(remote).to(local)
|
|
|
|
end
|
2017-09-07 17:27:04 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|