Sha256: 08838f32739ba7e567dc68fc9f56a7a9372dbbdb667ee3ce61a2e8afdfb915eb

Contents?: true

Size: 1.32 KB

Versions: 24

Compression:

Stored size: 1.32 KB

Contents

module DeepTest
  module Distributed
    class MasterTestServer
      include ERB::Util

      STATUS_PORT = 4020 unless defined?(STATUS_PORT)

      attr_reader :servers

      def initialize(servers)
        @servers = servers
      end

      def show_status(req, res)
        template = File.read(File.dirname(__FILE__) + "/show_status.rhtml")
        res.body = ERB.new(template).result(binding)
      end

      def test_server_statuses
        @servers.map do |s|
          status = begin
                     s.status
                   rescue Exception => e
                     e
                   end

          [s.__drburi, status]
        end
      end

      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

      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

      def self.start_http(master)
        s = WEBrick::HTTPServer.new :Port => STATUS_PORT
        s.mount_proc("/", &master.method(:show_status))
        Thread.new {s.start}
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 4 rubygems

Version Path
jason-o-matic-deep_test-1.2.2.1 lib/deep_test/distributed/master_test_server.rb
jason-o-matic-deep_test-1.2.2.10 lib/deep_test/distributed/master_test_server.rb
jason-o-matic-deep_test-1.2.2.11 lib/deep_test/distributed/master_test_server.rb
jason-o-matic-deep_test-1.2.2.12 lib/deep_test/distributed/master_test_server.rb
jason-o-matic-deep_test-1.2.2.13 lib/deep_test/distributed/master_test_server.rb
jason-o-matic-deep_test-1.2.2.14 lib/deep_test/distributed/master_test_server.rb
jason-o-matic-deep_test-1.2.2.2 lib/deep_test/distributed/master_test_server.rb
jason-o-matic-deep_test-1.2.2.3 lib/deep_test/distributed/master_test_server.rb
jason-o-matic-deep_test-1.2.2.4 lib/deep_test/distributed/master_test_server.rb
jason-o-matic-deep_test-1.2.2.5 lib/deep_test/distributed/master_test_server.rb
jason-o-matic-deep_test-1.2.2.6 lib/deep_test/distributed/master_test_server.rb
jason-o-matic-deep_test-1.2.2.7 lib/deep_test/distributed/master_test_server.rb
jason-o-matic-deep_test-1.2.2.8 lib/deep_test/distributed/master_test_server.rb
jason-o-matic-deep_test-1.2.2.9 lib/deep_test/distributed/master_test_server.rb
jperkins-deep_test-1.2.2 lib/deep_test/distributed/master_test_server.rb
jason-o-matic-deep_test-1.2.2.15 lib/deep_test/distributed/master_test_server.rb
jstorimer-deep-test-1.4.0 lib/deep_test/distributed/master_test_server.rb
jstorimer-deep-test-1.3.0 lib/deep_test/distributed/master_test_server.rb
jstorimer-deep-test-1.2.0 lib/deep_test/distributed/master_test_server.rb
jstorimer-deep-test-1.1.0 lib/deep_test/distributed/master_test_server.rb