Class: Binpacker::Orchestrator

Inherits:
Object
  • Object
show all
Defined in:
lib/binpacker/orchestrator.rb,
sig/binpacker/orchestrator.rbs

Constant Summary collapse

BATCH_SIZE =
10

Instance Method Summary collapse

Constructor Details

#initialize(config, passthrough: [], quiet: false, report_path: nil) ⇒ Orchestrator

Returns a new instance of Orchestrator.

Parameters:

  • (Object)
  • passthrough: (Object) (defaults to: [])
  • quiet: (Object) (defaults to: false)
  • report_path: (Object) (defaults to: nil)


7
8
9
10
11
12
# File 'lib/binpacker/orchestrator.rb', line 7

def initialize(config, passthrough: [], quiet: false, report_path: nil)
  @config = config
  @passthrough = passthrough
  @quiet = quiet
  @report_path = report_path
end

Instance Method Details

#run{ passed: untyped, total: untyped, passed_count: untyped, timings: Array[untyped], empty_filter: untyped }

Returns:

  • ({ passed: untyped, total: untyped, passed_count: untyped, timings: Array[untyped], empty_filter: untyped })


14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/binpacker/orchestrator.rb', line 14

def run
  tests = discover
  timing = Timing.new(@config.timing_file)
  timings = timing.load_with_fallback(tests)
  @timings = timings

  scheduler = Scheduler.for(@config.scheduler["algorithm"])
  queues = scheduler.partition(
    tests: tests,
    worker_count: @config.worker_count,
    timings: timings
  )

  # Capture predicted per-Worker loads before execution drains the queues.
  @predicted_loads = queues.map { |q| q.total_weight(timings) }

  runner_class = TestRunner.for(@config.test_runner)
  workers = queues.map.with_index do |queue, idx|
    Worker.new(idx, runner_class, passthrough: @passthrough, quiet: @quiet).tap(&:start)
  end

  if @config.scheduler["steal_enabled"]
    run_dynamic(workers, queues, timing, tests)
  else
    run_static(workers, queues, timing, tests)
  end
end