From 9dc7a11955b35cc2edb105898a59d914796702f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Rodr=C3=ADguez?= Date: Wed, 5 Oct 2016 18:26:45 -0300 Subject: Fix short circuit logic between rsync with and without ionice for storage migrations --- spec/gitlab_projects_spec.rb | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'spec/gitlab_projects_spec.rb') diff --git a/spec/gitlab_projects_spec.rb b/spec/gitlab_projects_spec.rb index bc615d4..149d53f 100644 --- a/spec/gitlab_projects_spec.rb +++ b/spec/gitlab_projects_spec.rb @@ -227,6 +227,41 @@ describe GitlabProjects do FileUtils.cd(new_repo_path) { Dir['**/*'].length.should_not be(0) } end + it "should attempt rsync with ionice first" do + expect(gl_projects).to receive(:system).with( + 'ionice -c2 -n7 rsync', '-a', '--delete', '--rsync-path="ionice -c2 -n7 rsync"', + "#{tmp_repo_path}/", new_repo_path + ).and_return(true) + + gl_projects.exec.should be_true + end + + it "should attempt rsync without ionice if with ionice fails" do + expect(gl_projects).to receive(:system).with( + 'ionice -c2 -n7 rsync', '-a', '--delete', '--rsync-path="ionice -c2 -n7 rsync"', + "#{tmp_repo_path}/", new_repo_path + ).and_return(false) + + expect(gl_projects).to receive(:system).with( + 'rsync', '-a', '--delete', '--rsync-path="rsync"', "#{tmp_repo_path}/", new_repo_path + ).and_return(true) + + gl_projects.exec.should be_true + end + + it "should fail if both rsync attempts fail" do + expect(gl_projects).to receive(:system).with( + 'ionice -c2 -n7 rsync', '-a', '--delete', '--rsync-path="ionice -c2 -n7 rsync"', + "#{tmp_repo_path}/", new_repo_path + ).and_return(false) + + expect(gl_projects).to receive(:system).with( + 'rsync', '-a', '--delete', '--rsync-path="rsync"', "#{tmp_repo_path}/", new_repo_path + ).and_return(false) + + gl_projects.exec.should be_false + end + it "should fail if no destination path is provided" do incomplete = build_gitlab_projects('mv-storage', tmp_repos_path, repo_name) $logger.should_receive(:error).with("mv-storage failed: no destination storage path provided.") -- cgit v1.2.1