Spork::RunStrategy::Magazine

Constants

Slave_Id_Range

Public Class Methods

available?() click to toggle source
    # File lib/spork/run_strategy/magazine.rb, line 64
64:   def self.available?
65:     true
66:   end
new(test_framework) click to toggle source
    # File lib/spork/run_strategy/magazine.rb, line 20
20:   def initialize(test_framework)
21:     @test_framework = test_framework
22:     this_path = File.expand_path(File.dirname(__FILE__))
23:     @path = File.join(this_path, 'magazine')
24:     @pids = []
25: 
26:     @pids << start_Rinda_ringserver
27:     sleep 1
28: 
29:     fill_slave_pool
30:   rescue RuntimeError => e
31:     kill_all_processes
32:     raise e
33:   end

Public Instance Methods

abort() click to toggle source
     # File lib/spork/run_strategy/magazine.rb, line 108
108:   def abort
109:     kill_all_processes
110:   end
fill_slave_pool() click to toggle source
    # File lib/spork/run_strategy/magazine.rb, line 40
40:   def fill_slave_pool
41:     Slave_Id_Range.each do |id|
42:       start_slave(id)
43:     end
44:     puts "  -- Starting to fill pool..."
45:     puts "     Wait until at least one slave is provided before running tests..."
46:     puts "  ** CTRL+BREAK to stop Spork and kill all ruby slave processes **"
47:     $stdout.flush
48:   end
kill_all_processes() click to toggle source
    # File lib/spork/run_strategy/magazine.rb, line 95
95:   def kill_all_processes
96: 
97:     @pids.each {|pid| Process.kill(9, pid)}
98:     puts "\nKilling processes."; $stdout.flush
99:   end
preload() click to toggle source
     # File lib/spork/run_strategy/magazine.rb, line 112
112:   def preload
113:     true
114:     #    @test_framework.preload
115:   end
restart_slave(id) click to toggle source
    # File lib/spork/run_strategy/magazine.rb, line 89
89:   def restart_slave(id)
90:     pid   = @pids[id]
91:     Process.kill(9, pid)
92:     start_slave(id)
93:   end
run(argv, stderr, stdout) click to toggle source
    # File lib/spork/run_strategy/magazine.rb, line 68
68:   def run(argv, stderr, stdout)
69:         DRb.start_service
70:         ts = Rinda::RingFinger.primary
71:         if ts.read_all([:name, :MagazineSlave, nil, nil]).size > 0
72:           print '  <-- take tuple'; stdout.flush
73:           tuple = ts.take([:name, :MagazineSlave, nil, nil])
74:           slave = tuple[2]
75:           id = tuple[3]
76: 
77:           puts "(#{slave.id_num}); slave.run..."; $stdout.flush
78:           begin
79:             slave.run(argv,stderr,stdout)
80:             puts "   -- (#{slave.id_num});run done"; $stdout.flush
81:           ensure
82:             restart_slave(id)
83:           end
84:         else
85:           puts '- NO tuple'; $stdout.flush
86:         end
87:   end
running?() click to toggle source
     # File lib/spork/run_strategy/magazine.rb, line 117
117:   def running?
118:     @running
119:   end
slave_count() click to toggle source
     # File lib/spork/run_strategy/magazine.rb, line 101
101:   def slave_count
102:     DRb.start_service
103:     ts = Rinda::RingFinger.primary
104:     ts.read_all([:name, :MagazineSlave, nil, nil]).size
105:   end
slave_max() click to toggle source
    # File lib/spork/run_strategy/magazine.rb, line 16
16:   def slave_max
17:     Slave_Id_Range.to_a.size
18:   end
spawn_process(app) click to toggle source
    # File lib/spork/run_strategy/magazine.rb, line 56
56:   def spawn_process(app)
57:     if RUBY_VERSION < '1.9.1'
58:       Process.create( :app_name => app, :cwd => @path ).process_id
59:     else
60:       Process.spawn( app, :chdir => @path )
61:     end
62:   end
start_Rinda_ringserver() click to toggle source
    # File lib/spork/run_strategy/magazine.rb, line 35
35:   def start_Rinda_ringserver
36:     app_name = 'ruby ring_server.rb'
37:     spawn_process(app_name)    
38:   end
start_slave(id) click to toggle source
    # File lib/spork/run_strategy/magazine.rb, line 50
50:   def start_slave(id)
51:     app_pwd = Dir.pwd  # path running app in
52:     app = "ruby magazine_slave_provider.rb #{id} '#{app_pwd}' #{@test_framework.short_name}"
53:     @pids[id] = spawn_process(app)
54:   end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.