Class: Hydra::Master
- Inherits:
-
Object
- Object
- Hydra::Master
- 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
-
#initialize(opts = { }) ⇒ Master
constructor
Create a new Master.
-
#process_results(worker, message) ⇒ Object
Process the results coming back from the worker.
-
#send_file(worker) ⇒ Object
Send a file down to a worker.
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.
-
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/hydra/master.rb', line 19 def initialize(opts = { }) opts.stringify_keys! config_file = opts.delete('config') { nil } if config_file opts.merge!(YAML.load_file(config_file).stringify_keys!) end @files = opts.fetch('files') { [] } @files.sort!{|a,b| File.size(b) <=> File.size(a)} # dumb heuristic @incomplete_files = @files.dup @workers = [] @listeners = [] @verbose = opts.fetch('verbose') { false } # default is one worker that is configured to use a pipe with one runner worker_cfg = opts.fetch('workers') { [ { 'type' => 'local', 'runners' => 1} ] } trace "Initialized" trace " Files: (#{@files.inspect})" trace " Workers: (#{worker_cfg.inspect})" trace " Verbose: (#{@verbose.inspect})" boot_workers worker_cfg end |
Instance Method Details
#process_results(worker, message) ⇒ Object
Process the results coming back from the worker.
53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/hydra/master.rb', line 53 def process_results(worker, ) $stdout.write .output # only delete one @incomplete_files.delete_at(@incomplete_files.index(.file)) trace "#{@incomplete_files.size} Files Remaining" if @incomplete_files.empty? shutdown_all_workers else send_file(worker) end end |