rails-profiler 0.44.29 → 0.44.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,6 +14,7 @@ module Profiler
14
14
  class RunTests
15
15
  DEFAULT_TIMEOUT = 120
16
16
  DEFAULT_MAX_OUTPUT = 4000
17
+ MAX_TIMEOUT = 600 # seconds, cap to prevent blocking Puma threads
17
18
  POLL_TIMEOUT = 10 # seconds per wait_for_output call
18
19
 
19
20
  def self.call(params)
@@ -24,7 +25,9 @@ module Profiler
24
25
  files = Array(params["files"])
25
26
  framework = params["framework"]&.to_s
26
27
  timeout_secs = (params["timeout_seconds"] || DEFAULT_TIMEOUT).to_i
28
+ timeout_secs = [timeout_secs, MAX_TIMEOUT].min
27
29
  max_output = (params["max_output"] || DEFAULT_MAX_OUTPUT).to_i
30
+ max_output = DEFAULT_MAX_OUTPUT if max_output <= 0
28
31
 
29
32
  # Auto-detect framework if not provided
30
33
  framework ||= begin
@@ -81,9 +84,14 @@ module Profiler
81
84
  files = Array(params["files"])
82
85
  framework = params["framework"].to_s
83
86
  timeout_secs = (params["timeout_seconds"] || DEFAULT_TIMEOUT).to_i
87
+ timeout_secs = [timeout_secs, MAX_TIMEOUT].min
84
88
  max_output = (params["max_output"] || DEFAULT_MAX_OUTPUT).to_i
89
+ max_output = DEFAULT_MAX_OUTPUT if max_output <= 0
85
90
 
86
- run_data = proxy.post_json("/_profiler/api/test_runner/runs", { files: files, framework: framework.presence || "rspec" })
91
+ payload = {}
92
+ payload[:files] = files if files.any?
93
+ payload[:framework] = framework if framework.present?
94
+ run_data = proxy.post_json("/_profiler/api/test_runner/runs", payload)
87
95
 
88
96
  if run_data["error"]
89
97
  return [{ type: "text", text: "Error starting tests on slave: #{run_data["error"]}" }]
@@ -99,6 +107,9 @@ module Profiler
99
107
  break
100
108
  end
101
109
  run_data = proxy.get_json("/_profiler/api/test_runner/runs/#{run_id}")
110
+ if run_data["error"]
111
+ return [{ type: "text", text: "Error reading test run #{run_id} on slave: #{run_data["error"]}" }]
112
+ end
102
113
  break if Profiler::TestRunner::RunStore::TERMINAL_STATUSES.include?(run_data["status"])
103
114
  sleep 2
104
115
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Profiler
4
- VERSION = "0.44.29"
4
+ VERSION = "0.44.31"
5
5
 
6
6
  GEM_ROOT = File.expand_path("../..", __dir__)
7
7
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-profiler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.44.29
4
+ version: 0.44.31
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sébastien Duplessy