Commit 8a20e8b8 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch '32796-add-ee-tag-detection-to-remove-old-in-gitlab-backup' into 'master'

Adds EE tag detection to remove_old in gitlab backup.

Closes #32796

See merge request gitlab-org/gitlab-ce!14413
parents f918e005 4c5acdda
...@@ -79,7 +79,7 @@ module Backup ...@@ -79,7 +79,7 @@ module Backup
# - 1495527122_gitlab_backup.tar # - 1495527122_gitlab_backup.tar
# - 1495527068_2017_05_23_gitlab_backup.tar # - 1495527068_2017_05_23_gitlab_backup.tar
# - 1495527097_2017_05_23_9.3.0-pre_gitlab_backup.tar # - 1495527097_2017_05_23_9.3.0-pre_gitlab_backup.tar
next unless file =~ /^(\d{10})(?:_\d{4}_\d{2}_\d{2}(_\d+\.\d+\.\d+((-|\.)(pre|rc\d))?)?)?_gitlab_backup\.tar$/ next unless file =~ /^(\d{10})(?:_\d{4}_\d{2}_\d{2}(_\d+\.\d+\.\d+((-|\.)(pre|rc\d))?(-ee)?)?)?_gitlab_backup\.tar$/
timestamp = $1.to_i timestamp = $1.to_i
......
...@@ -28,6 +28,7 @@ describe Backup::Manager do ...@@ -28,6 +28,7 @@ describe Backup::Manager do
'1451520000_2015_12_31_4.5.6_gitlab_backup.tar', '1451520000_2015_12_31_4.5.6_gitlab_backup.tar',
'1451520000_2015_12_31_4.5.6-pre_gitlab_backup.tar', '1451520000_2015_12_31_4.5.6-pre_gitlab_backup.tar',
'1451520000_2015_12_31_4.5.6-rc1_gitlab_backup.tar', '1451520000_2015_12_31_4.5.6-rc1_gitlab_backup.tar',
'1451520000_2015_12_31_4.5.6-pre-ee_gitlab_backup.tar',
'1451510000_2015_12_30_gitlab_backup.tar', '1451510000_2015_12_30_gitlab_backup.tar',
'1450742400_2015_12_22_gitlab_backup.tar', '1450742400_2015_12_22_gitlab_backup.tar',
'1449878400_gitlab_backup.tar', '1449878400_gitlab_backup.tar',
...@@ -114,14 +115,18 @@ describe Backup::Manager do ...@@ -114,14 +115,18 @@ describe Backup::Manager do
expect(FileUtils).to have_received(:rm).with(files[3]) expect(FileUtils).to have_received(:rm).with(files[3])
end end
it 'removes matching files with a human-readable non-versioned timestamp' do it 'removes matching files with a human-readable versioned timestamp with tagged EE' do
expect(FileUtils).to have_received(:rm).with(files[4]) expect(FileUtils).to have_received(:rm).with(files[4])
end
it 'removes matching files with a human-readable non-versioned timestamp' do
expect(FileUtils).to have_received(:rm).with(files[5]) expect(FileUtils).to have_received(:rm).with(files[5])
expect(FileUtils).to have_received(:rm).with(files[6])
end end
it 'removes matching files without a human-readable timestamp' do it 'removes matching files without a human-readable timestamp' do
expect(FileUtils).to have_received(:rm).with(files[6])
expect(FileUtils).to have_received(:rm).with(files[7]) expect(FileUtils).to have_received(:rm).with(files[7])
expect(FileUtils).to have_received(:rm).with(files[8])
end end
it 'does not remove files that are not old enough' do it 'does not remove files that are not old enough' do
...@@ -129,11 +134,11 @@ describe Backup::Manager do ...@@ -129,11 +134,11 @@ describe Backup::Manager do
end end
it 'does not remove non-matching files' do it 'does not remove non-matching files' do
expect(FileUtils).not_to have_received(:rm).with(files[8]) expect(FileUtils).not_to have_received(:rm).with(files[9])
end end
it 'prints a done message' do it 'prints a done message' do
expect(progress).to have_received(:puts).with('done. (7 removed)') expect(progress).to have_received(:puts).with('done. (8 removed)')
end end
end end
...@@ -153,10 +158,11 @@ describe Backup::Manager do ...@@ -153,10 +158,11 @@ describe Backup::Manager do
expect(FileUtils).to have_received(:rm).with(files[5]) expect(FileUtils).to have_received(:rm).with(files[5])
expect(FileUtils).to have_received(:rm).with(files[6]) expect(FileUtils).to have_received(:rm).with(files[6])
expect(FileUtils).to have_received(:rm).with(files[7]) expect(FileUtils).to have_received(:rm).with(files[7])
expect(FileUtils).to have_received(:rm).with(files[8])
end end
it 'sets the correct removed count' do it 'sets the correct removed count' do
expect(progress).to have_received(:puts).with('done. (6 removed)') expect(progress).to have_received(:puts).with('done. (7 removed)')
end end
it 'prints the error from file that could not be removed' do it 'prints the error from file that could not be removed' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment