From 43f037c903605b55ca1c34a24ab1ea1a522816fb Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Wed, 10 May 2017 14:18:59 +0200 Subject: Don't reuse gRPC channels It seems that bad things happen when two gRPC stubs share one gRPC channel so let's stop doing that. The downside of this is that we create more gRPC connections; one per stub. --- spec/support/test_env.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'spec/support/test_env.rb') diff --git a/spec/support/test_env.rb b/spec/support/test_env.rb index 8e31c26591b..f8ad0ccdb41 100644 --- a/spec/support/test_env.rb +++ b/spec/support/test_env.rb @@ -120,7 +120,7 @@ module TestEnv end def setup_gitaly - socket_path = Gitlab::GitalyClient.get_address('default').sub(/\Aunix:/, '') + socket_path = Gitlab::GitalyClient.address('default').sub(/\Aunix:/, '') gitaly_dir = File.dirname(socket_path) unless File.directory?(gitaly_dir) || system('rake', "gitlab:gitaly:install[#{gitaly_dir}]") -- cgit v1.2.1 From 60106c1e1ecdb0bb8ed37e1137c846f1a415dabf Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Wed, 10 May 2017 15:06:56 +0200 Subject: Log gitaly output during testing --- spec/support/test_env.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'spec/support/test_env.rb') diff --git a/spec/support/test_env.rb b/spec/support/test_env.rb index f8ad0ccdb41..9bf9dc5d4b2 100644 --- a/spec/support/test_env.rb +++ b/spec/support/test_env.rb @@ -133,7 +133,8 @@ module TestEnv 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') + log_file = Rails.root.join('log/gitaly-test.log').to_s + @gitaly_pid = spawn(gitaly_exec, gitaly_config, [:out, :err] => log_file) end def stop_gitaly -- cgit v1.2.1 From 628cc84891228895daa19d7b1300fc032cb26910 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Coutable?= Date: Wed, 10 May 2017 17:19:48 +0200 Subject: Factorize TestEvent#copy_repo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rémy Coutable --- spec/support/test_env.rb | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) (limited to 'spec/support/test_env.rb') diff --git a/spec/support/test_env.rb b/spec/support/test_env.rb index 9bf9dc5d4b2..f319c9634e3 100644 --- a/spec/support/test_env.rb +++ b/spec/support/test_env.rb @@ -170,13 +170,13 @@ module TestEnv end end - def copy_repo(project) - base_repo_path = File.expand_path(factory_repo_path_bare) + def copy_repo(project, copy_fork: false) + base_repo_path = File.expand_path(copy_fork ? forked_repo_path_bare : factory_repo_path_bare) target_repo_path = File.expand_path(project.repository_storage_path + "/#{project.full_path}.git") FileUtils.mkdir_p(target_repo_path) FileUtils.cp_r("#{base_repo_path}/.", target_repo_path) FileUtils.chmod_R 0755, target_repo_path - set_repo_refs(target_repo_path, BRANCH_SHA) + set_repo_refs(target_repo_path, copy_fork ? FORKED_BRANCH_SHA : BRANCH_SHA) end def repos_path @@ -191,15 +191,6 @@ module TestEnv Gitlab.config.pages.path end - def copy_forked_repo_with_submodules(project) - base_repo_path = File.expand_path(forked_repo_path_bare) - target_repo_path = File.expand_path(project.repository_storage_path + "/#{project.full_path}.git") - FileUtils.mkdir_p(target_repo_path) - FileUtils.cp_r("#{base_repo_path}/.", target_repo_path) - FileUtils.chmod_R 0755, target_repo_path - set_repo_refs(target_repo_path, FORKED_BRANCH_SHA) - end - # When no cached assets exist, manually hit the root path to create them # # Otherwise they'd be created by the first test, often timing out and -- cgit v1.2.1 From 7e56ac8f434a327282401796ffd43a46eb08e94c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Coutable?= Date: Wed, 10 May 2017 17:31:50 +0200 Subject: If TestEnv#set_repo_refs fails, clean test repos and retry MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sometimes, new references are not retrieved when a `git fetch` is called in a bare repos. The easiest solution is to cleanup the test repos and retry in this case. This only happens when a new ref is added to TestEnv::BRANCH_SHA or TestEnv::FORKED_BRANCH_SHA. Signed-off-by: Rémy Coutable --- spec/support/test_env.rb | 48 +++++++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 23 deletions(-) (limited to 'spec/support/test_env.rb') diff --git a/spec/support/test_env.rb b/spec/support/test_env.rb index f319c9634e3..d53edb36138 100644 --- a/spec/support/test_env.rb +++ b/spec/support/test_env.rb @@ -155,14 +155,14 @@ module TestEnv FORKED_BRANCH_SHA) end - def setup_repo(repo_path, repo_path_bare, repo_name, branch_sha) + def setup_repo(repo_path, repo_path_bare, repo_name, refs) clone_url = "https://gitlab.com/gitlab-org/#{repo_name}.git" unless File.directory?(repo_path) system(*%W(#{Gitlab.config.git.bin_path} clone -q #{clone_url} #{repo_path})) end - set_repo_refs(repo_path, branch_sha) + set_repo_refs(repo_path, refs) unless File.directory?(repo_path_bare) # We must copy bare repositories because we will push to them. @@ -170,13 +170,12 @@ module TestEnv end end - def copy_repo(project, copy_fork: false) - base_repo_path = File.expand_path(copy_fork ? forked_repo_path_bare : factory_repo_path_bare) + def copy_repo(project, bare_repo:, refs:) target_repo_path = File.expand_path(project.repository_storage_path + "/#{project.full_path}.git") FileUtils.mkdir_p(target_repo_path) - FileUtils.cp_r("#{base_repo_path}/.", target_repo_path) + FileUtils.cp_r("#{File.expand_path(bare_repo)}/.", target_repo_path) FileUtils.chmod_R 0755, target_repo_path - set_repo_refs(target_repo_path, copy_fork ? FORKED_BRANCH_SHA : BRANCH_SHA) + set_repo_refs(target_repo_path, refs) end def repos_path @@ -202,16 +201,20 @@ module TestEnv Capybara.current_session.visit '/' end + def factory_repo_path_bare + "#{factory_repo_path}_bare" + end + + def forked_repo_path_bare + "#{forked_repo_path}_bare" + end + private def factory_repo_path @factory_repo_path ||= Rails.root.join('tmp', 'tests', factory_repo_name) end - def factory_repo_path_bare - "#{factory_repo_path}_bare" - end - def factory_repo_name 'gitlab-test' end @@ -220,10 +223,6 @@ module TestEnv @forked_repo_path ||= Rails.root.join('tmp', 'tests', forked_repo_name) end - def forked_repo_path_bare - "#{forked_repo_path}_bare" - end - def forked_repo_name 'gitlab-test-fork' end @@ -235,19 +234,22 @@ module TestEnv end def set_repo_refs(repo_path, branch_sha) - instructions = branch_sha.map {|branch, sha| "update refs/heads/#{branch}\x00#{sha}\x00" }.join("\x00") << "\x00" + instructions = branch_sha.map { |branch, sha| "update refs/heads/#{branch}\x00#{sha}\x00" }.join("\x00") << "\x00" update_refs = %W(#{Gitlab.config.git.bin_path} update-ref --stdin -z) reset = proc do - IO.popen(update_refs, "w") {|io| io.write(instructions) } - $?.success? + Dir.chdir(repo_path) do + IO.popen(update_refs, "w") { |io| io.write(instructions) } + $?.success? + end end - Dir.chdir(repo_path) do - # Try to reset without fetching to avoid using the network. - unless reset.call - raise 'Could not fetch test seed repository.' unless system(*%W(#{Gitlab.config.git.bin_path} fetch origin)) - raise 'The fetched test seed does not contain the required revision.' unless reset.call - end + # Try to reset without fetching to avoid using the network. + unless reset.call + raise 'Could not fetch test seed repository.' unless system(*%W(#{Gitlab.config.git.bin_path} -C #{repo_path} fetch origin)) + + # Before we used Git clone's --mirror option, bare repos could end up + # with missing refs, clearing them and retrying should fix the issue. + cleanup && init unless reset.call end end end -- cgit v1.2.1 From ba441bb6f48d8d01d60a88ca5407f38eea4a58e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Coutable?= Date: Wed, 10 May 2017 17:33:50 +0200 Subject: Shorten the last two commit SHA, because CONSISTENCY MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rémy Coutable --- spec/support/test_env.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'spec/support/test_env.rb') diff --git a/spec/support/test_env.rb b/spec/support/test_env.rb index d53edb36138..b168098edea 100644 --- a/spec/support/test_env.rb +++ b/spec/support/test_env.rb @@ -40,8 +40,8 @@ module TestEnv 'wip' => 'b9238ee', 'csv' => '3dd0896', 'v1.1.0' => 'b83d6e3', - 'add-ipython-files' => '6d85bb69', - 'add-pdf-file' => 'e774ebd3' + 'add-ipython-files' => '6d85bb6', + 'add-pdf-file' => 'e774ebd' }.freeze # gitlab-test-fork is a fork of gitlab-fork, but we don't necessarily -- cgit v1.2.1