Class: Hydra::Master

Inherits:
Object
  • Object
show all
Includes:
Hydra::Messages::Master
Defined in:
lib/hydra/master.rb

Overview

Hydra class responsible for delegate work down to workers.

The Master is run once for any given testing session.

Instance Method Summary collapse

Constructor Details

#initialize(opts = { }) ⇒ Master

Create a new Master

Options:

  • :files

    • An array of test files to be run. These should be relative paths from the root of the project, since they may be run on different machines which may have different paths.

  • :workers

    • An array of hashes. Each hash should be the configuration options for a worker.



17
18
19
20
21
22
23
# File 'lib/hydra/master.rb', line 17

def initialize(opts = { })
  @files = opts.fetch(:files) { [] }
  @workers = []
  @listeners = []
  boot_workers(opts.fetch(:workers) { [ {:runners => 1} ] } )
  process_messages
end

Instance Method Details

#send_file(worker) ⇒ Object

Send a file down to a worker. If there are no more files, this will shut the worker down.



29
30
31
32
33
34
35
36
37
# File 'lib/hydra/master.rb', line 29

def send_file(worker)
  f = @files.pop
  if f
    worker[:io].write(RunFile.new(:file => f))
  else
    worker[:io].write(Shutdown.new)
    Thread.exit
  end
end