jason-o-matic-deep_test 1.2.2.4 → 1.2.2.5

Sign up to get free protection for your applications and to get access to all the features.
data/lib/deep_test.rb CHANGED
@@ -88,3 +88,5 @@ require File.dirname(__FILE__) + "/deep_test/test"
88
88
 
89
89
  require File.dirname(__FILE__) + "/deep_test/ui/console"
90
90
  require File.dirname(__FILE__) + "/deep_test/ui/null"
91
+
92
+ require File.expand_path(File.dirname(__FILE__) + "/deep_test/drbfire.rb")
@@ -19,7 +19,13 @@ module DeepTest
19
19
  Thread.new do
20
20
  Thread.current[:receiver] = r
21
21
  Timeout.timeout(@options.timeout_in_seconds) do
22
- r.send method_name, *args
22
+ begin
23
+ DeepTest.logger.debug "Dispatching to #{r.inspect}: #{method_name}(*#{args.inspect})"
24
+ r.send method_name, *args
25
+ rescue Exception => ex
26
+ DeepTest.logger.debug "DISPATCH EXCEPTION from #{r.inspect}: #{ex.message}\n#{ex.backtrace.join("\n")}"
27
+ raise
28
+ end
23
29
  end
24
30
  end
25
31
  end
@@ -38,7 +44,7 @@ module DeepTest
38
44
  end
39
45
  rescue Exception => e
40
46
  @receivers.delete t[:receiver]
41
- DeepTest.logger.error "Exception while dispatching #{method_name} to #{t[:receiver].__drburi} #{e.message}"
47
+ DeepTest.logger.error "Exception while dispatching #{method_name} to #{t[:receiver].__drburi} #{e.message}\n#{e.backtrace.join("\n")}"
42
48
  end
43
49
  end
44
50
 
@@ -1,6 +1,7 @@
1
1
  module DeepTest
2
2
  module Distributed
3
3
  class MultiTestServerProxy
4
+
4
5
  def initialize(options, slaves)
5
6
  DeepTest.logger.debug "MultiTestServerProxy#initialize #{slaves.length} slaves"
6
7
  @slave_controller = DispatchController.new(options, slaves)
@@ -27,7 +28,11 @@ module DeepTest
27
28
  end
28
29
 
29
30
  class WorkerServerProxy
31
+
32
+ attr_reader :slaves
33
+
30
34
  def initialize(options, slaves)
35
+ @slaves = slaves
31
36
  DeepTest.logger.debug "WorkerServerProxy#initialize #{slaves.inspect}"
32
37
  @slave_controller = DispatchController.new(options, slaves)
33
38
  end
@@ -13,6 +13,12 @@ module DeepTest
13
13
  t = Thread.new do
14
14
  @test_server.sync(@options)
15
15
  @worker_server = @test_server.spawn_worker_server(@options)
16
+
17
+ @worker_server.slaves.each do |s|
18
+ DeepTest.logger.debug "Startng the DRb service to connect to: #{s.inspect}"
19
+ DRb.start_service(s.__drburi, nil, DRbFire::ROLE => DRbFire::CLIENT)
20
+ end
21
+
16
22
  @worker_server.load_files filelist
17
23
  end
18
24
 
@@ -29,7 +35,13 @@ module DeepTest
29
35
  end
30
36
  end
31
37
 
32
- def start_all
38
+ def start_all(drbserver)
39
+
40
+ @worker_server.slaves.each do |s|
41
+ DeepTest.logger.debug "Remote worker client start_all sending Server reference to RemoteWorkerServer: #{s.inspect}"
42
+ s.drbserver = drbserver
43
+ end
44
+
33
45
  @worker_server.start_all
34
46
  rescue => e
35
47
  raise if failed_over?
@@ -5,6 +5,8 @@ module DeepTest
5
5
  include DRb::DRbUndumped
6
6
 
7
7
  MERCY_KILLING_GRACE_PERIOD = 10 * 60 unless defined?(MERCY_KILLING_GRACE_PERIOD)
8
+
9
+ attr_accessor :uri
8
10
 
9
11
  def initialize(base_path, workers, options)
10
12
  @base_path = base_path
@@ -56,7 +58,7 @@ module DeepTest
56
58
 
57
59
  def start_all
58
60
  @workers_started = true
59
- @workers.start_all
61
+ @workers.start_all(self)
60
62
  end
61
63
 
62
64
  def stop_all
@@ -88,10 +90,13 @@ module DeepTest
88
90
  innie.close
89
91
 
90
92
  server = new(base_path, workers, options)
91
-
92
- DRb.start_service("drubyall://#{address}:0", server)
93
+
94
+ # this is half the magic that lets us work through the NAT
95
+ DRb.start_service("drbfire://#{address}:0", server, DRbFire::ROLE => DRbFire::SERVER, DRbFire::DELEGATE => DRbBindAllTCPSocket)
93
96
  DeepTest.logger.info "RemoteWorkerServer started at #{DRb.uri}"
94
97
 
98
+ server.uri = DRb.uri
99
+
95
100
  outie.write DRb.uri
96
101
  outie.close
97
102
 
@@ -105,6 +110,21 @@ module DeepTest
105
110
  innie.close
106
111
  DRbObject.new_with_uri(uri)
107
112
  end
113
+
114
+ ######################################################################################
115
+ # These methods allow us to proxy the Server through the NAT
116
+ ######################################################################################
117
+ def drbserver=(drbserver)
118
+ DeepTest.logger.debug "Setting the Server remote reference to: #{drbserver.inspect}"
119
+ @drbserver = drbserver
120
+ end
121
+ def take_work
122
+ DeepTest.logger.debug "Remote worker server proxying 'take_work' back to Server"
123
+ @drbserver.take_work
124
+ end
125
+ def write_result(res)
126
+ @drbserver.write_result res
127
+ end
108
128
 
109
129
  end
110
130
  end
@@ -11,11 +11,25 @@ module DeepTest
11
11
  @test_server_config[:number_of_workers]
12
12
  end
13
13
 
14
+ # Here we use DRb to communicate with the RemoteWorkerServer to avoid multiple processes
15
+ # trying to use the same drbfire connection. We have the RemoteWorkerServer proxy the
16
+ # interaction with Server since the RemoteServerWorker can connect back to the Server trough a NAT.
14
17
  def server
15
- Server.remote_reference(@connection_info.address, @options.server_port)
18
+ # we're in a new process (one of the workers on the test_server),
19
+ # so stop the old server from RemoteWorkerServer
20
+ DRb.stop_service
21
+
22
+ # since RemoteWorkerServer now uses drbfire, we use it here to communicate with it
23
+ DRb.start_service(@server_proxy.uri, nil, DRbFire::ROLE => DRbFire::CLIENT)
24
+
25
+ DeepTest.logger.debug "LocalWorkers start_all worker starting with with blackboard: #{@server_proxy.uri.inspect} #{@server_proxy.inspect}"
26
+
27
+ # finally, return a remote reference to the RemoteWorkerServer
28
+ DRbObject.new_with_uri(@server_proxy.uri)
16
29
  end
17
30
 
18
- def start_all
31
+ def start_all(server_proxy)
32
+ @server_proxy = server_proxy
19
33
  super
20
34
  @warlock.exit_when_none_running
21
35
  end
@@ -15,6 +15,9 @@ module DeepTest
15
15
  # Open a server listening for connections at +uri+ using
16
16
  # configuration +config+.
17
17
  def self.open_server(uri, config)
18
+
19
+ DeepTest.logger.debug "drubyall open_server with args: #{uri.inspect} #{config.inspect}"
20
+
18
21
  uri = 'drubyall://:0' unless uri
19
22
  host, port, opt = parse_uri(uri)
20
23
 
@@ -27,6 +30,12 @@ module DeepTest
27
30
  port = soc.addr[1] if port == 0
28
31
  uri = "druby://#{host}:#{port}"
29
32
  self.new(uri, soc, config)
33
+
34
+ rescue Exception => e
35
+ unless DRb::DRbBadURI === e or DRb::DRbBadScheme === e
36
+ DeepTest.logger.debug "drubyall open_server exception: #{e.message}\n#{e.backtrace.join("\n")}"
37
+ end
38
+ raise
30
39
  end
31
40
  end
32
41
  end
@@ -1,5 +1,6 @@
1
1
  module DeepTest
2
2
  class LocalWorkers
3
+
3
4
  def initialize(options)
4
5
  @options = options
5
6
  @warlock = Warlock.new
@@ -8,12 +9,12 @@ module DeepTest
8
9
  def load_files(files)
9
10
  files.each {|f| load f}
10
11
  end
11
-
12
+
12
13
  def server
13
14
  @options.server
14
15
  end
15
16
 
16
- def start_all
17
+ def start_all(s)
17
18
  each_worker do |worker_num|
18
19
  start_worker(worker_num) do
19
20
  reseed_random_numbers
@@ -16,10 +16,10 @@ module DeepTest
16
16
  begin
17
17
  server = Server.start(@options)
18
18
  @options.new_listener_list.before_starting_workers
19
- @workers.start_all
19
+ @workers.start_all(server)
20
20
  begin
21
21
  DeepTest.logger.debug "Loader Starting (#{$$})"
22
- passed = @runner.process_work_units
22
+ passed = @runner.process_work_units(server)
23
23
  ensure
24
24
  shutdown(server)
25
25
  end
@@ -1,9 +1,16 @@
1
1
  module DeepTest
2
2
  class Server
3
+ include DRbUndumped
4
+
3
5
  def self.start(options)
4
6
  server = new(options)
5
- DRb.start_service("druby://0.0.0.0:#{options.server_port}", server)
6
- DeepTest.logger.info "Started DeepTest service at #{DRb.uri}"
7
+
8
+ # start_sevice if running locally, otherise we only want to use the RemoteWorkerClient connection
9
+ if options.distributed_server.nil?
10
+ DRb.start_service("drbfire://0.0.0.0:#{options.server_port}", server, DRbFire::ROLE => DRbFire::SERVER)
11
+ DeepTest.logger.info "Started DeepTest service at #{DRb.uri}"
12
+ end
13
+
7
14
  server
8
15
  end
9
16
 
@@ -12,8 +19,8 @@ module DeepTest
12
19
  end
13
20
 
14
21
  def self.remote_reference(address, port)
15
- DRb.start_service
16
- blackboard = DRbObject.new_with_uri("druby://#{address}:#{port}")
22
+ DRb.start_service("drbfire://#{address}:#{port}", nil, DRbFire::ROLE => DRbFire::CLIENT)
23
+ blackboard = DRbObject.new_with_uri("drbfire://#{address}:#{port}")
17
24
  DeepTest.logger.debug "Connecting to DeepTest server at #{blackboard.__drburi}"
18
25
  blackboard
19
26
  end
@@ -12,9 +12,9 @@ module DeepTest
12
12
  @options = options
13
13
  end
14
14
 
15
- def process_work_units
15
+ def process_work_units(server)
16
16
  suite = ::Test::Unit::AutoRunner::COLLECTORS[:objectspace].call NO_FILTERS
17
- supervised_suite = DeepTest::Test::SupervisedTestSuite.new(suite, @options.server)
17
+ supervised_suite = DeepTest::Test::SupervisedTestSuite.new(suite, server)
18
18
  require 'test/unit/ui/console/testrunner'
19
19
  result = ::Test::Unit::UI::Console::TestRunner.run(supervised_suite, ::Test::Unit::UI::NORMAL)
20
20
  result.passed?
@@ -28,9 +28,13 @@ module DeepTest
28
28
  end
29
29
  rescue Server::NoWorkUnitsRemainingError
30
30
  DeepTest.logger.debug("Worker #{number}: no more work to do")
31
+ rescue Exception => e
32
+ DeepTest.logger.debug "Worker #{number} EXCEPTION: #{e.message}\n#{e.backtrace.join("\n")}"
33
+ raise
31
34
  end
32
35
 
33
36
  def next_work_unit
37
+ DeepTest.logger.debug "Worker #{number} getting next work unit from: #{@blackboard.inspect}"
34
38
  @blackboard.take_work
35
39
  rescue Server::NoWorkUnitsAvailableError
36
40
  sleep 0.02
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jason-o-matic-deep_test
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2.4
4
+ version: 1.2.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - anonymous z, Dan Manges, David Vollbracht