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:
authorjramsay <jcai@gitlab.com>2019-10-22 04:21:54 +0300
committerJohn Cai <jcai@gitlab.com>2019-11-20 04:36:55 +0300
commit7d4a9c5be6a37cfd000df00bf71ed70103eb7845 (patch)
treead1703b9cb6edb6332b33fb2cdcbe56af8a02c06 /_support/test-boot
parent78f16381648b2d1857d01c39eeef25035599cffb (diff)
Validate that hook files are reachable and executable
Diffstat (limited to '_support/test-boot')
-rwxr-xr-x_support/test-boot70
1 files changed, 70 insertions, 0 deletions
diff --git a/_support/test-boot b/_support/test-boot
new file mode 100755
index 000000000..1d7b19f28
--- /dev/null
+++ b/_support/test-boot
@@ -0,0 +1,70 @@
+#!/usr/bin/env ruby
+
+require 'tempfile'
+require 'socket'
+
+ADDR = 'socket'.freeze
+
+def main(gitaly_dir)
+ gitaly_dir = File.realpath(gitaly_dir)
+
+ Dir.mktmpdir do |dir|
+ Dir.chdir(dir)
+
+ File.write('config.toml', <<~CONFIG
+ socket_path = "#{ADDR}"
+ bin_dir = "#{gitaly_dir}"
+
+ [[storage]]
+ name = "default"
+ path = "#{dir}"
+
+ [gitaly-ruby]
+ dir = "#{gitaly_dir}/ruby"
+
+ [gitlab-shell]
+ dir = "#{gitaly_dir}/ruby/gitlab-shell"
+ CONFIG
+ )
+
+ pid = nil
+
+ begin
+ start = Time.now
+ pid = spawn(File.join(gitaly_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 wait_connect
+ repeats = 100
+ sleep_time = 0.1
+
+ repeats.times do
+ begin
+ Socket.unix(ADDR)
+ return
+ rescue # rubocop:disable Lint/RescueWithoutErrorClass
+ print '.'
+ sleep(sleep_time)
+ end
+ end
+
+ puts "failed to connect to gitaly after #{repeats * sleep_time}s"
+
+ abort
+end
+
+unless ARGV.count == 1
+ abort "Usage: #{$PROGRAM_NAME} GITALY_DIR"
+end
+
+main(ARGV.first)