diff options
author | Grzegorz Bizon <grzegorz@gitlab.com> | 2017-12-05 14:31:33 +0000 |
---|---|---|
committer | Kamil TrzciĆski <ayufan@ayufan.eu> | 2018-02-28 20:44:09 +0100 |
commit | 6ca02a41500790b3e9061dd8836540955b9aaf7c (patch) | |
tree | 5c66c4826cafa2657fe25d85eb9e189b5f290f32 /spec/tasks | |
parent | ec72abf53fd82ca3e7f126536a83b27b368696ec (diff) | |
download | gitlab-ce-6ca02a41500790b3e9061dd8836540955b9aaf7c.tar.gz |
Merge branch 'zj-multiple-artifacts-ee' into 'master'
Multiple artifacts ee
See merge request gitlab-org/gitlab-ee!3276
Diffstat (limited to 'spec/tasks')
-rw-r--r-- | spec/tasks/gitlab/artifacts_rake_spec.rb | 118 |
1 files changed, 118 insertions, 0 deletions
diff --git a/spec/tasks/gitlab/artifacts_rake_spec.rb b/spec/tasks/gitlab/artifacts_rake_spec.rb new file mode 100644 index 00000000000..a30823b8875 --- /dev/null +++ b/spec/tasks/gitlab/artifacts_rake_spec.rb @@ -0,0 +1,118 @@ +require 'rake_helper' + +describe 'gitlab:artifacts namespace rake task' do + before(:context) do + Rake.application.rake_require 'tasks/gitlab/artifacts' + end + + let(:object_storage_enabled) { false } + + before do + stub_artifacts_object_storage(enabled: object_storage_enabled) + end + + subject { run_rake_task('gitlab:artifacts:migrate') } + + context 'legacy artifacts' do + describe 'migrate' do + let!(:build) { create(:ci_build, :legacy_artifacts, artifacts_file_store: store, artifacts_metadata_store: store) } + + context 'when local storage is used' do + let(:store) { ObjectStoreUploader::LOCAL_STORE } + + context 'and job does not have file store defined' do + let(:object_storage_enabled) { true } + let(:store) { nil } + + it "migrates file to remote storage" do + subject + + expect(build.reload.artifacts_file_store).to eq(ObjectStoreUploader::REMOTE_STORE) + expect(build.reload.artifacts_metadata_store).to eq(ObjectStoreUploader::REMOTE_STORE) + end + end + + context 'and remote storage is defined' do + let(:object_storage_enabled) { true } + + it "migrates file to remote storage" do + subject + + expect(build.reload.artifacts_file_store).to eq(ObjectStoreUploader::REMOTE_STORE) + expect(build.reload.artifacts_metadata_store).to eq(ObjectStoreUploader::REMOTE_STORE) + end + end + + context 'and remote storage is not defined' do + it "fails to migrate to remote storage" do + subject + + expect(build.reload.artifacts_file_store).to eq(ObjectStoreUploader::LOCAL_STORE) + expect(build.reload.artifacts_metadata_store).to eq(ObjectStoreUploader::LOCAL_STORE) + end + end + end + + context 'when remote storage is used' do + let(:object_storage_enabled) { true } + + let(:store) { ObjectStoreUploader::REMOTE_STORE } + + it "file stays on remote storage" do + subject + + expect(build.reload.artifacts_file_store).to eq(ObjectStoreUploader::REMOTE_STORE) + expect(build.reload.artifacts_metadata_store).to eq(ObjectStoreUploader::REMOTE_STORE) + end + end + end + end + + context 'job artifacts' do + let!(:artifact) { create(:ci_job_artifact, :archive, file_store: store) } + + context 'when local storage is used' do + let(:store) { ObjectStoreUploader::LOCAL_STORE } + + context 'and job does not have file store defined' do + let(:object_storage_enabled) { true } + let(:store) { nil } + + it "migrates file to remote storage" do + subject + + expect(artifact.reload.file_store).to eq(ObjectStoreUploader::REMOTE_STORE) + end + end + + context 'and remote storage is defined' do + let(:object_storage_enabled) { true } + + it "migrates file to remote storage" do + subject + + expect(artifact.reload.file_store).to eq(ObjectStoreUploader::REMOTE_STORE) + end + end + + context 'and remote storage is not defined' do + it "fails to migrate to remote storage" do + subject + + expect(artifact.reload.file_store).to eq(ObjectStoreUploader::LOCAL_STORE) + end + end + end + + context 'when remote storage is used' do + let(:object_storage_enabled) { true } + let(:store) { ObjectStoreUploader::REMOTE_STORE } + + it "file stays on remote storage" do + subject + + expect(artifact.reload.file_store).to eq(ObjectStoreUploader::REMOTE_STORE) + end + end + end +end |