Class: DeepTest::Distributed::TestServerWorkers

Inherits:
LocalWorkers
  • Object
show all
Defined in:
lib/deep_test/distributed/test_server_workers.rb

Instance Method Summary collapse

Methods inherited from LocalWorkers

#load_files, #stop_all

Constructor Details

#initialize(options, test_server_config, connection_info) ⇒ TestServerWorkers

Returns a new instance of TestServerWorkers.



4
5
6
7
8
# File 'lib/deep_test/distributed/test_server_workers.rb', line 4

def initialize(options, test_server_config, connection_info)
  super(options)
  @test_server_config = test_server_config
  @connection_info = connection_info
end

Instance Method Details

#number_of_workersObject



10
11
12
# File 'lib/deep_test/distributed/test_server_workers.rb', line 10

def number_of_workers
  @test_server_config[:number_of_workers]
end

#serverObject

Here we use DRb to communicate with the RemoteWorkerServer to avoid multiple processes trying to use the same drbfire connection. We have the RemoteWorkerServer proxy the interaction with Server since the RemoteServerWorker can connect back to the Server trough a NAT.



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/deep_test/distributed/test_server_workers.rb', line 17

def server
  # we're in a new process (one of the workers on the test_server),
  # so stop the old server from RemoteWorkerServer
  DRb.stop_service
  
  # since RemoteWorkerServer now uses drbfire, we use it here to communicate with it
  DRb.start_service(@server_proxy.uri, nil, DRbFire::ROLE => DRbFire::CLIENT)
  
  DeepTest.logger.debug "LocalWorkers start_all worker starting with with blackboard: #{@server_proxy.uri.inspect} #{@server_proxy.inspect}"
  
  # finally, return a remote reference to the RemoteWorkerServer
  DRbObject.new_with_uri(@server_proxy.uri)
end

#start_all(server_proxy) ⇒ Object



31
32
33
34
35
# File 'lib/deep_test/distributed/test_server_workers.rb', line 31

def start_all(server_proxy)
  @server_proxy = server_proxy
  super
  @warlock.exit_when_none_running
end