Class: DeepTest::Distributed::MasterTestServer
- Inherits:
-
Object
- Object
- DeepTest::Distributed::MasterTestServer
- Includes:
- ERB::Util
- Defined in:
- lib/deep_test/distributed/master_test_server.rb
Constant Summary collapse
- STATUS_PORT =
4020
Instance Attribute Summary collapse
-
#servers ⇒ Object
readonly
Returns the value of attribute servers.
Class Method Summary collapse
- .start(uri, server_uris) ⇒ Object
- .start_drb(uri, server_uris) ⇒ Object
- .start_http(master) ⇒ Object
Instance Method Summary collapse
-
#initialize(servers) ⇒ MasterTestServer
constructor
A new instance of MasterTestServer.
- #show_status(req, res) ⇒ Object
- #test_server_statuses ⇒ Object
Constructor Details
#initialize(servers) ⇒ MasterTestServer
Returns a new instance of MasterTestServer.
10 11 12 |
# File 'lib/deep_test/distributed/master_test_server.rb', line 10 def initialize(servers) @servers = servers end |
Instance Attribute Details
#servers ⇒ Object (readonly)
Returns the value of attribute servers.
8 9 10 |
# File 'lib/deep_test/distributed/master_test_server.rb', line 8 def servers @servers end |
Class Method Details
.start(uri, server_uris) ⇒ Object
31 32 33 34 35 36 |
# File 'lib/deep_test/distributed/master_test_server.rb', line 31 def self.start(uri, server_uris) master = start_drb(uri, server_uris) start_http(master) DeepTest.logger.info "MasterTestServer listening at #{DRb.uri}" DRb.thread.join end |
.start_drb(uri, server_uris) ⇒ Object
38 39 40 41 42 43 |
# File 'lib/deep_test/distributed/master_test_server.rb', line 38 def self.start_drb(uri, server_uris) servers = server_uris.map {|server_uri| DRbObject.new_with_uri server_uri} master = DeepTest::Distributed::MasterTestServer.new(servers) DRb.start_service(uri, master) master end |
.start_http(master) ⇒ Object
45 46 47 48 49 |
# File 'lib/deep_test/distributed/master_test_server.rb', line 45 def self.start_http(master) s = WEBrick::HTTPServer.new :Port => STATUS_PORT s.mount_proc("/", &master.method(:show_status)) Thread.new {s.start} end |
Instance Method Details
#show_status(req, res) ⇒ Object
14 15 16 17 |
# File 'lib/deep_test/distributed/master_test_server.rb', line 14 def show_status(req, res) template = File.read(File.dirname(__FILE__) + "/show_status.rhtml") res.body = ERB.new(template).result(binding) end |
#test_server_statuses ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/deep_test/distributed/master_test_server.rb', line 19 def test_server_statuses @servers.map do |s| status = begin s.status rescue Exception => e e end [s.__drburi, status] end end |