diff options
author | Phil Hughes <me@iamphill.com> | 2017-04-13 08:01:55 +0100 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2017-04-13 08:01:55 +0100 |
commit | 2c643a552e911be09d543d06537c7a3113f9bb93 (patch) | |
tree | b8bd28bac4bc5c1f379a5f90f9dc2dcbc6b3848e /spec/support/test_env.rb | |
parent | bf5248ac28bf817344a8b1b4feda744a0832d32d (diff) | |
parent | d7a527163b64fa38e46fc6195fef2f5d93e47d07 (diff) | |
download | gitlab-ce-2c643a552e911be09d543d06537c7a3113f9bb93.tar.gz |
Merge branch 'master' into notebooklab-in-repo
Diffstat (limited to 'spec/support/test_env.rb')
-rw-r--r-- | spec/support/test_env.rb | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/spec/support/test_env.rb b/spec/support/test_env.rb index af1defb5a2e..eb0f1efe55b 100644 --- a/spec/support/test_env.rb +++ b/spec/support/test_env.rb @@ -65,6 +65,8 @@ module TestEnv # Setup GitLab shell for test instance setup_gitlab_shell + setup_gitaly if Gitlab::GitalyClient.enabled? + # Create repository for FactoryGirl.create(:project) setup_factory_repo @@ -72,6 +74,10 @@ module TestEnv setup_forked_repo end + def cleanup + stop_gitaly + end + def disable_mailer allow_any_instance_of(NotificationService).to receive(:mailer). and_return(double.as_null_object) @@ -93,7 +99,7 @@ module TestEnv tmp_test_path = Rails.root.join('tmp', 'tests', '**') Dir[tmp_test_path].each do |entry| - unless File.basename(entry) =~ /\Agitlab-(shell|test|test_bare|test-fork|test-fork_bare)\z/ + unless File.basename(entry) =~ /\A(gitaly|gitlab-(shell|test|test_bare|test-fork|test-fork_bare))\z/ FileUtils.rm_rf(entry) end end @@ -111,6 +117,28 @@ module TestEnv end end + def setup_gitaly + socket_path = Gitlab::GitalyClient.get_address('default').sub(/\Aunix:/, '') + gitaly_dir = File.dirname(socket_path) + + unless File.directory?(gitaly_dir) || system('rake', "gitlab:gitaly:install[#{gitaly_dir}]") + raise "Can't clone gitaly" + end + + start_gitaly(gitaly_dir, socket_path) + end + + def start_gitaly(gitaly_dir, socket_path) + gitaly_exec = File.join(gitaly_dir, 'gitaly') + @gitaly_pid = spawn({ "GITALY_SOCKET_PATH" => socket_path }, gitaly_exec, [:out, :err] => '/dev/null') + end + + def stop_gitaly + return unless @gitaly_pid + + Process.kill('KILL', @gitaly_pid) + end + def setup_factory_repo setup_repo(factory_repo_path, factory_repo_path_bare, factory_repo_name, BRANCH_SHA) |