File tree Expand file tree Collapse file tree 1 file changed +19
-5
lines changed Expand file tree Collapse file tree 1 file changed +19
-5
lines changed Original file line number Diff line number Diff line change @@ -140,20 +140,34 @@ def get_benchmark_routes(app_dir)
140140# Helper method to check if server is responding
141141def server_responding? ( uri )
142142 response = Net ::HTTP . get_response ( uri )
143- response . is_a? ( Net ::HTTPSuccess )
144- rescue StandardError
145- false
143+ { success : response . is_a? ( Net ::HTTPSuccess ) , info : "HTTP #{ response . code } #{ response . message } " }
144+ rescue StandardError => e
145+ { success : false , info : " #{ e . class . name } : #{ e . message } " }
146146end
147147
148148# Wait for the server to be ready
149149TIMEOUT_SEC = 60
150150puts "Checking server availability at #{ BASE_URL } ..."
151151test_uri = URI . parse ( "http://#{ BASE_URL } #{ routes . first } " )
152152start_time = Time . now
153+ attempt_count = 0
153154loop do
154- break if server_responding? ( test_uri )
155+ attempt_count += 1
156+ attempt_start = Time . now
157+ result = server_responding? ( test_uri )
158+ attempt_duration = Time . now - attempt_start
159+ elapsed = Time . now - start_time
160+
161+ # rubocop:disable Layout/LineLength
162+ if result [ :success ]
163+ puts " ✅ Attempt #{ attempt_count } at #{ elapsed . round ( 2 ) } s: SUCCESS - #{ result [ :info ] } (took #{ attempt_duration . round ( 3 ) } s)"
164+ break
165+ else
166+ puts " ❌ Attempt #{ attempt_count } at #{ elapsed . round ( 2 ) } s: FAILED - #{ result [ :info ] } (took #{ attempt_duration . round ( 3 ) } s)"
167+ end
168+ # rubocop:enable Layout/LineLength
155169
156- raise "Server at #{ BASE_URL } not responding within #{ TIMEOUT_SEC } s" if Time . now - start_time > TIMEOUT_SEC
170+ raise "Server at #{ BASE_URL } not responding within #{ TIMEOUT_SEC } s" if elapsed > TIMEOUT_SEC
157171
158172 sleep 1
159173end
You can’t perform that action at this time.
0 commit comments