fix: clean e2e script lint
This commit is contained in:
parent
e53a9e7eb0
commit
d847fa694d
|
|
@ -6,6 +6,10 @@ require 'optparse'
|
||||||
|
|
||||||
require_relative 'lib/load_test_runner'
|
require_relative 'lib/load_test_runner'
|
||||||
|
|
||||||
|
def write_line(message = '')
|
||||||
|
$stdout.write("#{message}\n")
|
||||||
|
end
|
||||||
|
|
||||||
def parse_client_list(value)
|
def parse_client_list(value)
|
||||||
return [] if value.nil? || value.strip == '' || value.strip.casecmp('none').zero?
|
return [] if value.nil? || value.strip == '' || value.strip.casecmp('none').zero?
|
||||||
|
|
||||||
|
|
@ -72,33 +76,32 @@ runner = TurniereE2E::LoadTestRunner.new(**runner_options)
|
||||||
result = runner.run
|
result = runner.run
|
||||||
|
|
||||||
if options[:format] == 'json'
|
if options[:format] == 'json'
|
||||||
puts JSON.pretty_generate(result)
|
write_line JSON.pretty_generate(result)
|
||||||
exit
|
else
|
||||||
end
|
write_line "Load test base_url=#{result.fetch(:base_url)} tournament_id=#{result.dig(:tournament, :id)}"
|
||||||
|
|
||||||
puts "Load test base_url=#{result.fetch(:base_url)} tournament_id=#{result.dig(:tournament, :id)}"
|
result.fetch(:http).each do |level|
|
||||||
|
write_line(
|
||||||
result.fetch(:http).each do |level|
|
|
||||||
puts(
|
|
||||||
"HTTP #{level.fetch(:clients)} clients: " \
|
"HTTP #{level.fetch(:clients)} clients: " \
|
||||||
"#{level.fetch(:ok)}/#{level.fetch(:requests)} ok, errors=#{level.fetch(:errors)}, " \
|
"#{level.fetch(:ok)}/#{level.fetch(:requests)} ok, errors=#{level.fetch(:errors)}, " \
|
||||||
"p50=#{level.fetch(:p50_ms)}ms, p95=#{level.fetch(:p95_ms)}ms, " \
|
"p50=#{level.fetch(:p50_ms)}ms, p95=#{level.fetch(:p95_ms)}ms, " \
|
||||||
"max=#{level.fetch(:max_ms)}ms, rps=#{level.fetch(:requests_per_second)}"
|
"max=#{level.fetch(:max_ms)}ms, rps=#{level.fetch(:requests_per_second)}"
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
result.fetch(:websocket).each do |level|
|
result.fetch(:websocket).each do |level|
|
||||||
puts(
|
write_line(
|
||||||
"WS #{level.fetch(:clients)} clients: " \
|
"WS #{level.fetch(:clients)} clients: " \
|
||||||
"opened=#{level.fetch(:opened)}, errors=#{level.fetch(:errors)}, " \
|
"opened=#{level.fetch(:opened)}, errors=#{level.fetch(:errors)}, " \
|
||||||
"p50_open=#{level.fetch(:p50_open_ms)}ms, p95_open=#{level.fetch(:p95_open_ms)}ms, " \
|
"p50_open=#{level.fetch(:p50_open_ms)}ms, p95_open=#{level.fetch(:p95_open_ms)}ms, " \
|
||||||
"connections_metric=#{level.fetch(:connection_metric)}"
|
"connections_metric=#{level.fetch(:connection_metric)}"
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
metrics = result.fetch(:metrics)
|
metrics = result.fetch(:metrics)
|
||||||
puts(
|
write_line(
|
||||||
"Metrics: action_cable_connections=#{metrics.fetch(:action_cable_connections)}, " \
|
"Metrics: action_cable_connections=#{metrics.fetch(:action_cable_connections)}, " \
|
||||||
"action_cable_connections_total=#{metrics.fetch(:action_cable_connections_total)}, " \
|
"action_cable_connections_total=#{metrics.fetch(:action_cable_connections_total)}, " \
|
||||||
"ruby_threads=#{metrics.fetch(:ruby_threads)}"
|
"ruby_threads=#{metrics.fetch(:ruby_threads)}"
|
||||||
)
|
)
|
||||||
|
end
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,15 @@ require 'json'
|
||||||
require 'optparse'
|
require 'optparse'
|
||||||
require_relative '../e2e/lib/scenario_runner'
|
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 = {
|
options = {
|
||||||
base_url: ENV.fetch('TURNIERE_E2E_BASE_URL', 'http://127.0.0.1:3000'),
|
base_url: ENV.fetch('TURNIERE_E2E_BASE_URL', 'http://127.0.0.1:3000'),
|
||||||
stop_at: nil,
|
stop_at: nil,
|
||||||
|
|
@ -39,7 +48,9 @@ OptionParser.new do |parser|
|
||||||
parser.on('--username USERNAME', 'Confirmed E2E user username') { |value| options[:username] = value }
|
parser.on('--username USERNAME', 'Confirmed E2E user username') { |value| options[:username] = value }
|
||||||
end.parse!
|
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(
|
runner = TurniereE2E::ScenarioRunner.new(
|
||||||
base_url: options[:base_url],
|
base_url: options[:base_url],
|
||||||
email: options[:email],
|
email: options[:email],
|
||||||
|
|
@ -64,7 +75,7 @@ result = case scenario
|
||||||
stop_at: options[:stop_at] || :profiled_show
|
stop_at: options[:stop_at] || :profiled_show
|
||||||
)
|
)
|
||||||
else
|
else
|
||||||
abort("Unknown scenario #{scenario.inspect}")
|
fail_with("Unknown scenario #{scenario.inspect}")
|
||||||
end
|
end
|
||||||
|
|
||||||
puts JSON.pretty_generate(result)
|
write_line JSON.pretty_generate(result)
|
||||||
|
|
|
||||||
|
|
@ -8,4 +8,4 @@ timeout = (ARGV[1] || 30).to_i
|
||||||
|
|
||||||
runner = TurniereE2E::ScenarioRunner.new(base_url: url)
|
runner = TurniereE2E::ScenarioRunner.new(base_url: url)
|
||||||
runner.wait_for_healthcheck!(timeout_seconds: timeout)
|
runner.wait_for_healthcheck!(timeout_seconds: timeout)
|
||||||
puts "ready: #{url}"
|
$stdout.write("ready: #{url}\n")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue