diff options
author | Ahmad Sherif <ahmad.m.sherif@gmail.com> | 2017-09-05 17:33:04 +0300 |
---|---|---|
committer | Ahmad Sherif <ahmad.m.sherif@gmail.com> | 2017-09-05 17:33:04 +0300 |
commit | a9e32fbc5a2fcc2a5c261d90de662a3699d905c3 (patch) | |
tree | a1509209352b1d7e6440aa3ca201fa3cbed0fe21 | |
parent | 503ea3c3b74b8420fe7f2e325a7ca2864663b607 (diff) | |
parent | 3e0a09aad52cc2e36ff56372dfe69da85e9b80e9 (diff) |
Merge branch 'test-boot-time' into 'master'
Test boot time during build CI
See merge request !327
-rw-r--r-- | .gitlab-ci.yml | 1 | ||||
-rwxr-xr-x | _support/test-boot-time | 59 |
2 files changed, 60 insertions, 0 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d83ba16b6..be4098735 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -25,6 +25,7 @@ verify: stage: build_test script: - make + - _support/test-boot-time . build:default: <<: *build_definition diff --git a/_support/test-boot-time b/_support/test-boot-time new file mode 100755 index 000000000..f56c5f008 --- /dev/null +++ b/_support/test-boot-time @@ -0,0 +1,59 @@ +#!/usr/bin/env ruby + +require 'tempfile' +require 'socket' + +ADDR = 'socket' + +def main(gitaly_dir) + gitaly_dir = File.realpath(gitaly_dir) + + Dir.mktmpdir do |dir| + Dir.chdir(dir) + + File.write('config.toml', <<EOS +socket_path = "#{ADDR}" + +[[storage]] +name = "default" +path = "#{dir}" + +[gitaly-ruby] +dir = "#{gitaly_dir}/ruby" +EOS +) + + pid = nil + + begin + start = Time.now + pid = spawn(File.join(gitaly_dir, 'gitaly'), 'config.toml', out: '/dev/null') + wait_connect + puts + puts Time.now - start + ensure + if pid + Process.kill("KILL", pid) + Process.wait(pid) + end + end + end +end + +def wait_connect + loop do + begin + Socket.unix(ADDR) + return + rescue + print '.' + sleep(0.1) + end + end +end + +unless ARGV.count == 1 + abort "Usage: #{$PROGRAM_NAME} GITALY_DIR" +end + +main(ARGV.first) |