Some more specs

parent a2c435cc
...@@ -28,12 +28,24 @@ describe 'gitlab:app namespace rake task' do ...@@ -28,12 +28,24 @@ describe 'gitlab:app namespace rake task' do
before do before do
stub_env('force', 'yes') stub_env('force', 'yes')
FileUtils.rm(tars_glob, force: true) FileUtils.rm(tars_glob, force: true)
FileUtils.rm('artifacts.tar.gz', force: true)
FileUtils.rm('builds.tar.gz', force: true)
FileUtils.rm('lfs.tar.gz', force: true)
FileUtils.rm('pages.tar.gz', force: true)
FileUtils.rm_rf('db', secure: true)
FileUtils.rm_rf('repositories', secure: true)
reenable_backup_sub_tasks reenable_backup_sub_tasks
stub_container_registry_config(enabled: enable_registry) stub_container_registry_config(enabled: enable_registry)
end end
after do after do
FileUtils.rm(tars_glob, force: true) FileUtils.rm(tars_glob, force: true)
FileUtils.rm('artifacts.tar.gz', force: true)
FileUtils.rm('builds.tar.gz', force: true)
FileUtils.rm('lfs.tar.gz', force: true)
FileUtils.rm('pages.tar.gz', force: true)
FileUtils.rm_rf('db', secure: true)
FileUtils.rm_rf('repositories', secure: true)
end end
def run_rake_task(task_name) def run_rake_task(task_name)
...@@ -62,15 +74,6 @@ describe 'gitlab:app namespace rake task' do ...@@ -62,15 +74,6 @@ describe 'gitlab:app namespace rake task' do
let(:gitlab_version) { Gitlab::VERSION } let(:gitlab_version) { Gitlab::VERSION }
it 'fails on mismatch' do
allow(YAML).to receive(:load_file)
.and_return({ gitlab_version: "not #{gitlab_version}" })
expect do
expect { run_rake_task('gitlab:backup:restore') }.to output.to_stdout
end.to raise_error(SystemExit)
end
context 'restore with matching gitlab version' do context 'restore with matching gitlab version' do
before do before do
allow(YAML).to receive(:load_file) allow(YAML).to receive(:load_file)
...@@ -379,6 +382,49 @@ describe 'gitlab:app namespace rake task' do ...@@ -379,6 +382,49 @@ describe 'gitlab:app namespace rake task' do
end end
end end
describe 'Skipping tar archive creation' do
before do
stub_env('SKIP', 'tar')
end
it 'created files with backup content and no tar archive' do
expect { run_rake_task('gitlab:backup:create') }.to output.to_stdout
dir_contents, _exit_status = Gitlab::Popen.popen(
%W{ls -la #{Gitlab.config.backup.path}}
)
expect(dir_contents).to match('backup_information.yml')
expect(dir_contents).to match('db')
expect(dir_contents).to match('uploads.tar.gz')
expect(dir_contents).to match('builds.tar.gz')
expect(dir_contents).to match('artifacts.tar.gz')
expect(dir_contents).to match('lfs.tar.gz')
expect(dir_contents).to match('pages.tar.gz')
expect(dir_contents).to match('registry.tar.gz')
expect(dir_contents).not_to match("_gitlab_backup.tar")
end
it 'those component files can be restored from' do
expect { run_rake_task("gitlab:backup:create") }.to output.to_stdout
allow(Rake::Task['gitlab:shell:setup'])
.to receive(:invoke).and_return(true)
expect(Rake::Task['gitlab:db:drop_tables']).to receive :invoke
expect(Rake::Task['gitlab:backup:db:restore']).to receive :invoke
expect(Rake::Task['gitlab:backup:repo:restore']).to receive :invoke
expect(Rake::Task['gitlab:backup:uploads:restore']).to receive :invoke
expect(Rake::Task['gitlab:backup:builds:restore']).to receive :invoke
expect(Rake::Task['gitlab:backup:artifacts:restore']).to receive :invoke
expect(Rake::Task['gitlab:backup:pages:restore']).to receive :invoke
expect(Rake::Task['gitlab:backup:lfs:restore']).to receive :invoke
expect(Rake::Task['gitlab:backup:registry:restore']).to receive :invoke
expect(Rake::Task['gitlab:shell:setup']).to receive :invoke
expect { run_rake_task("gitlab:backup:restore") }.to output.to_stdout
end
end
describe "Human Readable Backup Name" do describe "Human Readable Backup Name" do
it 'name has human readable time' do it 'name has human readable time' do
expect { run_rake_task('gitlab:backup:create') }.to output.to_stdout expect { run_rake_task('gitlab:backup:create') }.to output.to_stdout
......
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