fix: clean e2e script lint

This commit is contained in:
Daniel Schädler 2026-05-06 14:47:33 +02:00
parent e53a9e7eb0
commit d847fa694d
3 changed files with 44 additions and 30 deletions

View File

@ -6,6 +6,10 @@ require 'optparse'
require_relative 'lib/load_test_runner'
def write_line(message = '')
$stdout.write("#{message}\n")
end
def parse_client_list(value)
return [] if value.nil? || value.strip == '' || value.strip.casecmp('none').zero?
@ -72,14 +76,12 @@ runner = TurniereE2E::LoadTestRunner.new(**runner_options)
result = runner.run
if options[:format] == 'json'
puts JSON.pretty_generate(result)
exit
end
puts "Load test base_url=#{result.fetch(:base_url)} tournament_id=#{result.dig(:tournament, :id)}"
write_line JSON.pretty_generate(result)
else
write_line "Load test base_url=#{result.fetch(:base_url)} tournament_id=#{result.dig(:tournament, :id)}"
result.fetch(:http).each do |level|
puts(
write_line(
"HTTP #{level.fetch(:clients)} clients: " \
"#{level.fetch(:ok)}/#{level.fetch(:requests)} ok, errors=#{level.fetch(:errors)}, " \
"p50=#{level.fetch(:p50_ms)}ms, p95=#{level.fetch(:p95_ms)}ms, " \
@ -88,7 +90,7 @@ result.fetch(:http).each do |level|
end
result.fetch(:websocket).each do |level|
puts(
write_line(
"WS #{level.fetch(:clients)} clients: " \
"opened=#{level.fetch(:opened)}, errors=#{level.fetch(:errors)}, " \
"p50_open=#{level.fetch(:p50_open_ms)}ms, p95_open=#{level.fetch(:p95_open_ms)}ms, " \
@ -97,8 +99,9 @@ result.fetch(:websocket).each do |level|
end
metrics = result.fetch(:metrics)
puts(
write_line(
"Metrics: action_cable_connections=#{metrics.fetch(:action_cable_connections)}, " \
"action_cable_connections_total=#{metrics.fetch(:action_cable_connections_total)}, " \
"ruby_threads=#{metrics.fetch(:ruby_threads)}"
)
end

View File

@ -5,6 +5,15 @@ require 'json'
require 'optparse'
require_relative '../e2e/lib/scenario_runner'
def write_line(message)
$stdout.write("#{message}\n")
end
def fail_with(message)
$stderr.write("#{message}\n")
raise SystemExit, 1
end
options = {
base_url: ENV.fetch('TURNIERE_E2E_BASE_URL', 'http://127.0.0.1:3000'),
stop_at: nil,
@ -39,7 +48,9 @@ OptionParser.new do |parser|
parser.on('--username USERNAME', 'Confirmed E2E user username') { |value| options[:username] = value }
end.parse!
scenario = ARGV.shift or abort('Missing scenario name')
scenario = ARGV.shift
fail_with('Missing scenario name') if scenario.nil?
runner = TurniereE2E::ScenarioRunner.new(
base_url: options[:base_url],
email: options[:email],
@ -64,7 +75,7 @@ result = case scenario
stop_at: options[:stop_at] || :profiled_show
)
else
abort("Unknown scenario #{scenario.inspect}")
fail_with("Unknown scenario #{scenario.inspect}")
end
puts JSON.pretty_generate(result)
write_line JSON.pretty_generate(result)

View File

@ -8,4 +8,4 @@ timeout = (ARGV[1] || 30).to_i
runner = TurniereE2E::ScenarioRunner.new(base_url: url)
runner.wait_for_healthcheck!(timeout_seconds: timeout)
puts "ready: #{url}"
$stdout.write("ready: #{url}\n")