1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
# frozen_string_literal: true
require 'rake_helper'
RSpec.describe 'gitlab:pages' do
before(:context) do
Rake.application.rake_require 'tasks/gitlab/pages'
end
describe 'migrate_legacy_storage task' do
subject { run_rake_task('gitlab:pages:migrate_legacy_storage') }
it 'calls migration service' do
expect_next_instance_of(::Pages::MigrateFromLegacyStorageService, anything,
migration_threads: 3,
batch_size: 10,
ignore_invalid_entries: false) do |service|
expect(service).to receive(:execute).and_call_original
end
subject
end
it 'uses PAGES_MIGRATION_THREADS environment variable' do
stub_env('PAGES_MIGRATION_THREADS', '5')
expect_next_instance_of(::Pages::MigrateFromLegacyStorageService, anything,
migration_threads: 5,
batch_size: 10,
ignore_invalid_entries: false) do |service|
expect(service).to receive(:execute).and_call_original
end
subject
end
it 'uses PAGES_MIGRATION_BATCH_SIZE environment variable' do
stub_env('PAGES_MIGRATION_BATCH_SIZE', '100')
expect_next_instance_of(::Pages::MigrateFromLegacyStorageService, anything,
migration_threads: 3,
batch_size: 100,
ignore_invalid_entries: false) do |service|
expect(service).to receive(:execute).and_call_original
end
subject
end
it 'uses PAGES_MIGRATION_IGNORE_INVALID_ENTRIES environment variable' do
stub_env('PAGES_MIGRATION_IGNORE_INVALID_ENTRIES', 'true')
expect_next_instance_of(::Pages::MigrateFromLegacyStorageService, anything,
migration_threads: 3,
batch_size: 10,
ignore_invalid_entries: true) do |service|
expect(service).to receive(:execute).and_call_original
end
subject
end
end
describe 'clean_migrated_zip_storage task' do
it 'removes only migrated deployments' do
regular_deployment = create(:pages_deployment)
migrated_deployment = create(:pages_deployment, :migrated)
regular_deployment.project.update_pages_deployment!(regular_deployment)
migrated_deployment.project.update_pages_deployment!(migrated_deployment)
expect(PagesDeployment.all).to contain_exactly(regular_deployment, migrated_deployment)
run_rake_task('gitlab:pages:clean_migrated_zip_storage')
expect(PagesDeployment.all).to contain_exactly(regular_deployment)
expect(PagesDeployment.find_by_id(regular_deployment.id)).not_to be_nil
expect(PagesDeployment.find_by_id(migrated_deployment.id)).to be_nil
end
end
end
|