Class: DeepTest::Distributed::TestServer
- Inherits:
-
Object
- Object
- DeepTest::Distributed::TestServer
- Defined in:
- lib/deep_test/distributed/test_server.rb
Constant Summary collapse
- DEFAULT_CONFIG =
{ :work_dir => "/tmp", :uri => "drubyall://:4022", :number_of_workers => 2 }
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(config) ⇒ TestServer
constructor
A new instance of TestServer.
- #servers ⇒ Object
- #spawn_worker_server(options) ⇒ Object
- #status ⇒ Object
- #sync(options) ⇒ Object
Constructor Details
#initialize(config) ⇒ TestServer
Returns a new instance of TestServer.
10 11 12 |
# File 'lib/deep_test/distributed/test_server.rb', line 10 def initialize(config) @config = config end |
Class Method Details
.connect(options) ⇒ Object
72 73 74 75 |
# File 'lib/deep_test/distributed/test_server.rb', line 72 def self.connect() servers = DRbObject.new_with_uri(.distributed_server).servers MultiTestServerProxy.new(, servers) end |
.parse_args(args) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/deep_test/distributed/test_server.rb', line 47 def self.parse_args(args) = DeepTest::Distributed::TestServer::DEFAULT_CONFIG.dup OptionParser.new do |opts| opts. = "Usage: deep_test test_server [options]" opts.on("--work_dir PATH", "Absolute path to keep mirror working copies at") do |v| [:work_dir] = v end opts.on("--uri URI", "DRb URI to bind server to") do |v| [:uri] = v end opts.on("--number_of_workers NUM", "Number of workers to start when running tests") do |v| [:number_of_workers] = v.to_i end opts.on_tail("-h", "--help", "Show this message") do puts opts exit end end.parse(args) end |
.start(config) ⇒ Object
40 41 42 43 44 45 |
# File 'lib/deep_test/distributed/test_server.rb', line 40 def self.start(config) server = DeepTest::Distributed::TestServer.new(config) DRb.start_service(config[:uri], server) DeepTest.logger.info "TestServer listening at #{DRb.uri}" DRb.thread.join end |
Instance Method Details
#servers ⇒ Object
36 37 38 |
# File 'lib/deep_test/distributed/test_server.rb', line 36 def servers [DRbObject.new_with_uri(DRb.uri)] end |
#spawn_worker_server(options) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/deep_test/distributed/test_server.rb', line 14 def spawn_worker_server() DeepTest.logger.debug("mirror spawn_worker_server for #{.origin_hostname}") RemoteWorkerServer.start(URI.parse(@config[:uri]).host, .mirror_path(@config[:work_dir]), TestServerWorkers.new(, @config, DRbClientConnectionInfo.new)) end |
#status ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/deep_test/distributed/test_server.rb', line 21 def status TestServerStatus.new( DRb.uri, @config[:number_of_workers], RemoteWorkerServer.running_server_count ) end |
#sync(options) ⇒ Object
29 30 31 32 33 34 |
# File 'lib/deep_test/distributed/test_server.rb', line 29 def sync() DeepTest.logger.debug "mirror sync for #{.origin_hostname}" path = .mirror_path(@config[:work_dir]) DeepTest.logger.debug "Syncing #{.[:source]} to #{path}" RSync.sync(DRbClientConnectionInfo.new, , path) end |