summaryrefslogtreecommitdiff
path: root/spec/support/test_env.rb
diff options
context:
space:
mode:
authorLuke "Jared" Bennett <lbennett@gitlab.com>2017-04-26 11:26:10 +0000
committerLuke "Jared" Bennett <lbennett@gitlab.com>2017-04-26 11:26:10 +0000
commitc3633db6176a3e72903601400a965fc8c44a2cb1 (patch)
tree16779d3e748b3e089d5e74663a70d6fe9d1b1d37 /spec/support/test_env.rb
parent0453d6d7ae72f0179d02ff5190122a86e304e1bb (diff)
parentf00bb1c29ea438be66b3766545a57b468ade37d4 (diff)
downloadgitlab-ce-c3633db6176a3e72903601400a965fc8c44a2cb1.tar.gz
Merge branch 'master' into 'balsalmiq-support'
# Conflicts: # config/webpack.config.js
Diffstat (limited to 'spec/support/test_env.rb')
-rw-r--r--spec/support/test_env.rb34
1 files changed, 32 insertions, 2 deletions
diff --git a/spec/support/test_env.rb b/spec/support/test_env.rb
index 5765a31ca18..d498ddafd08 100644
--- a/spec/support/test_env.rb
+++ b/spec/support/test_env.rb
@@ -39,7 +39,8 @@ module TestEnv
'deleted-image-test' => '6c17798',
'wip' => 'b9238ee',
'csv' => '3dd0896',
- 'v1.1.0' => 'b83d6e3'
+ 'v1.1.0' => 'b83d6e3',
+ 'add-ipython-files' => '6d85bb69'
}.freeze
# gitlab-test-fork is a fork of gitlab-fork, but we don't necessarily
@@ -65,6 +66,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 +75,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 +100,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 +118,29 @@ 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)
+ end
+
+ def start_gitaly(gitaly_dir)
+ gitaly_exec = File.join(gitaly_dir, 'gitaly')
+ gitaly_config = File.join(gitaly_dir, 'config.toml')
+ @gitaly_pid = spawn(gitaly_exec, gitaly_config, [: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)