Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToon Claes <toon@gitlab.com>2023-04-12 13:04:03 +0300
committerToon Claes <toon@gitlab.com>2023-04-14 15:58:58 +0300
commita0dbd18268dd8829f9a705daadf1b8928a3db3c3 (patch)
tree4a1c79e565d771de2ed82a566144ef64001fde8d /_support
parent683033db2043d8b3ad716115a37d0f2af3c86936 (diff)
tools: Rewrite test-boot in Go
Replace the Ruby script _support/test-boot with a small tool written in Go. Issue: https://gitlab.com/gitlab-org/gitaly/-/issues/4636
Diffstat (limited to '_support')
-rwxr-xr-x_support/test-boot118
1 files changed, 0 insertions, 118 deletions
diff --git a/_support/test-boot b/_support/test-boot
deleted file mode 100755
index 6678a89a8..000000000
--- a/_support/test-boot
+++ /dev/null
@@ -1,118 +0,0 @@
-#!/usr/bin/env ruby
-# frozen_string_literal: true
-
-require 'tempfile'
-require 'socket'
-require 'optparse'
-
-ADDR = 'socket'
-
-def main(params) # rubocop:disable Metrics/MethodLength
- gitaly_dir = File.realpath(params[:dir])
- build_dir = File.join(gitaly_dir, '_build')
- bin_dir = File.join(build_dir, 'bin')
-
- git_path, use_bundled_git =
- if params[:"bundled-git"]
- ['', true]
- else
- [File.join(build_dir, 'deps', 'git-distribution', 'bin-wrappers', 'git'), false]
- end
-
- version = IO.popen("#{File.join(bin_dir, 'gitaly')} -version").read.delete_prefix('Gitaly, version ').strip
- version_from_file = IO.read(File.join(gitaly_dir, 'VERSION')).strip
-
- # Use start_with? instead of == because the version output could use git describe, if it is a source install
- # eg: Gitaly, version 1.75.0-14-gd1ecb43f
- unless version.start_with?(version_from_file)
- abort "\nversion check failed: VERSION file contained '#{version_from_file}'"\
- " but 'gitaly -version' reported '#{version}'."\
- ' If you are working from a fork, please fetch the latest tags.'
- end
-
- Dir.mktmpdir do |dir|
- Dir.chdir(dir)
-
- gitlab_shell_dir = File.join(dir, 'gitlab-shell')
- Dir.mkdir(gitlab_shell_dir)
- File.write(File.join(gitlab_shell_dir, '.gitlab_shell_secret'), 'test_gitlab_shell_token')
- write_gitaly_config('config.toml',
- bin_dir: bin_dir,
- dir: dir,
- use_bundled_git: use_bundled_git,
- git_path: git_path,
- gitaly_dir: gitaly_dir,
- gitlab_shell_dir: gitlab_shell_dir)
-
- pid = nil
-
- begin
- start = Time.now
- pid = spawn(File.join(bin_dir, 'gitaly'), 'config.toml')
- wait_connect
- puts
- puts "\n\nconnection established after #{Time.now - start} seconds\n\n"
- ensure
- if pid
- Process.kill('KILL', pid)
- Process.wait(pid)
- end
- end
- end
-end
-
-def write_gitaly_config(config_path, bin_dir:, dir:, use_bundled_git:, git_path:, gitaly_dir:, gitlab_shell_dir:) # rubocop:disable Metrics/ParameterLists
- File.write(config_path, <<~CONFIG
- socket_path = "#{ADDR}"
- bin_dir = "#{bin_dir}"
-
- [[storage]]
- name = "default"
- path = "#{dir}"
-
- [git]
- use_bundled_binaries = #{use_bundled_git}
- bin_path = "#{git_path}"
-
- [gitaly-ruby]
- dir = "#{gitaly_dir}/ruby"
-
- [gitlab-shell]
- dir = "#{gitlab_shell_dir}"
-
- [gitlab]
- url = 'http://gitlab_url'
-
- CONFIG
- )
-end
-
-def wait_connect
- repeats = 100
- sleep_time = 0.1
-
- repeats.times do
- Socket.unix(ADDR)
- return
- rescue StandardError
- print '.'
- sleep(sleep_time)
- end
-
- puts "failed to connect to gitaly after #{repeats * sleep_time}s"
-
- abort
-end
-
-params = {}
-OptionParser.new do |parser|
- parser.banner = "Usage: #{$0} [options] <GITALY_DIR>"
- parser.on('--[no-]bundled-git', 'Set up Gitaly with bundled Git binaries')
-end.parse!(into: params)
-
-params[:dir] = ARGV.pop
-abort 'Gitaly source directory not provided' if params[:dir].nil?
-
-abort 'Extra arguments' unless ARGV.count.zero?
-
-main(params)