2019-12-21 20:55:43 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-05-09 12:01:36 +05:30
|
|
|
require 'rake_helper'
|
|
|
|
|
|
|
|
describe 'gitlab:lfs namespace rake task' do
|
|
|
|
before :all do
|
|
|
|
Rake.application.rake_require 'tasks/gitlab/lfs/migrate'
|
|
|
|
end
|
|
|
|
|
2019-12-21 20:55:43 +05:30
|
|
|
context 'migration tasks' do
|
2018-05-09 12:01:36 +05:30
|
|
|
let(:local) { ObjectStorage::Store::LOCAL }
|
|
|
|
let(:remote) { ObjectStorage::Store::REMOTE }
|
|
|
|
|
2019-12-21 20:55:43 +05:30
|
|
|
before do
|
|
|
|
stub_lfs_object_storage(background_upload: false, direct_upload: false)
|
2018-05-09 12:01:36 +05:30
|
|
|
end
|
|
|
|
|
2019-12-21 20:55:43 +05:30
|
|
|
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
|
2018-05-09 12:01:36 +05:30
|
|
|
end
|
|
|
|
|
2019-12-21 20:55:43 +05:30
|
|
|
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
|
2018-05-09 12:01:36 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-12-21 20:55:43 +05:30
|
|
|
describe 'migrate_to_local' do
|
|
|
|
subject { run_rake_task('gitlab:lfs:migrate_to_local') }
|
|
|
|
|
|
|
|
let(:lfs_object) { create(:lfs_object, :with_file, :object_storage) }
|
|
|
|
|
2018-05-09 12:01:36 +05:30
|
|
|
before do
|
2019-12-21 20:55:43 +05:30
|
|
|
stub_lfs_object_storage(background_upload: false, direct_upload: true)
|
2018-05-09 12:01:36 +05:30
|
|
|
end
|
|
|
|
|
2019-12-21 20:55:43 +05:30
|
|
|
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
|
2018-05-09 12:01:36 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|