Module: SplitTestRb::DebugPrinter

Defined in:
lib/split_test_rb.rb

Overview

Outputs debug information about test distribution

Class Method Summary collapse

Class Method Details

.calculate_load_balance_stats(nodes, total_time) ⇒ Object

Calculates load balance statistics across nodes



347
348
349
350
351
352
# File 'lib/split_test_rb.rb', line 347

def self.calculate_load_balance_stats(nodes, total_time)
  avg_time = total_time / nodes.size
  variance = nodes.map { |n| ((n[:total_time] - avg_time) / avg_time * 100).round(1) }
  max_deviation = variance.map(&:abs).max
  [avg_time, variance, max_deviation]
end

.format_file_timing(file, timings, default_files) ⇒ Object

Formats file timing information with labels



391
392
393
394
395
396
397
# File 'lib/split_test_rb.rb', line 391

def self.format_file_timing(file, timings, default_files)
  time = timings[file]
  timing_str = "(#{time.round(2)}s"
  timing_str += ', default - no historical data' if default_files.include?(file)
  timing_str += ')'
  timing_str
end

Shows distribution statistics, timing data sources, and per-node assignments



317
318
319
320
321
322
323
324
325
326
327
328
329
330
# File 'lib/split_test_rb.rb', line 317

def self.print(nodes, timings, default_files, json_files)
  total_files = timings.size
  total_time = timings.values.sum.round(2)
  files_from_xml = total_files - default_files.size
  avg_time, variance, max_deviation = calculate_load_balance_stats(nodes, total_time)

  warn '=== Test Balancing Debug Info ==='
  warn ''
  print_loaded_json_files(json_files, timings)
  print_timing_data_source(files_from_xml, default_files.size, total_files, total_time)
  print_load_balance_stats(avg_time, max_deviation)
  print_node_distribution(nodes, variance, timings, default_files)
  warn '===================================='
end

Prints load balance statistics



365
366
367
368
369
370
# File 'lib/split_test_rb.rb', line 365

def self.print_load_balance_stats(avg_time, max_deviation)
  warn '## Load Balance'
  warn "  - Average time per node: #{avg_time.round(2)}s"
  warn "  - Max deviation from average: #{max_deviation}%"
  warn ''
end

Prints information about loaded JSON result files



333
334
335
336
337
338
339
340
341
342
343
344
# File 'lib/split_test_rb.rb', line 333

def self.print_loaded_json_files(json_files, timings)
  warn '## Loaded Test Result Files'
  if json_files.empty?
    warn '  (no JSON files loaded)'
  else
    json_files.each do |file|
      warn "  - #{file}"
    end
    warn "  Total: #{json_files.size} JSON files, #{timings.size} test files extracted"
  end
  warn ''
end

Prints per-node distribution details



373
374
375
376
377
378
# File 'lib/split_test_rb.rb', line 373

def self.print_node_distribution(nodes, variance, timings, default_files)
  warn '## Per-Node Distribution'
  nodes.each_with_index do |node, index|
    print_node_info(node, index, variance[index], timings, default_files)
  end
end

Prints information for a single node



381
382
383
384
385
386
387
388
# File 'lib/split_test_rb.rb', line 381

def self.print_node_info(node, index, deviation, timings, default_files)
  deviation_str = deviation >= 0 ? "+#{deviation}%" : "#{deviation}%"
  warn "Node #{index}: #{node[:files].size} files, #{node[:total_time].round(2)}s (#{deviation_str} from avg)"
  node[:files].each do |file|
    warn "  - #{file} #{format_file_timing(file, timings, default_files)}"
  end
  warn ''
end

Prints timing data source information



355
356
357
358
359
360
361
362
# File 'lib/split_test_rb.rb', line 355

def self.print_timing_data_source(files_from_xml, default_files_count, total_files, total_time)
  warn '## Timing Data Source (from past test execution results)'
  warn "  - Files with historical timing: #{files_from_xml} files"
  warn "  - Files with default timing (1.0s): #{default_files_count} files"
  warn "  - Total files: #{total_files} files"
  warn "  - Total estimated time: #{total_time}s"
  warn ''
end