From c4862eca868ccbcbb645ea8030a7297b3029d117 Mon Sep 17 00:00:00 2001
From: Eric Ju <eju@gitlab.com>
Date: Thu, 11 Jul 2024 12:30:26 -0400
Subject: [PATCH] test: Add more time to spawn praefect

This commit adds a private method `process_details()` to print the
process status before terminating it. It is used to determine why
praefect is not ready for connectting.

We also added a longer timeout before dropping praefect connection.
---
 spec/support/helpers/gitaly_setup.rb | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/spec/support/helpers/gitaly_setup.rb b/spec/support/helpers/gitaly_setup.rb
index f4c569c10e7e4..e4a477a1f19f8 100644
--- a/spec/support/helpers/gitaly_setup.rb
+++ b/spec/support/helpers/gitaly_setup.rb
@@ -152,6 +152,7 @@ def start(service, toml = nil)
     begin
       try_connect!(service, toml)
     rescue StandardError
+      process_details(pid)
       Process.kill('TERM', pid)
       raise
     end
@@ -198,7 +199,7 @@ def connect_proc(toml)
 
   def try_connect!(service, toml)
     LOGGER.debug "Trying to connect to #{service}: "
-    timeout = 20
+    timeout = 40
     delay = 0.1
     connect = connect_proc(toml)
 
@@ -407,4 +408,12 @@ def praefect_with_db?
   def gitaly_with_transactions?
     Gitlab::Utils.to_boolean(ENV['GITALY_TRANSACTIONS_ENABLED'], default: false)
   end
+
+  private
+
+  # Logs the details of the process with the given pid.
+  def process_details(pid)
+    output = `ps -p #{pid} -o pid,ppid,state,%cpu,%mem,etime,args`
+    LOGGER.debug output
+  end
 end
-- 
GitLab