Class: DTR::Server
- Inherits:
-
Object
show all
- Defined in:
- lib/dtr/base.rb
Defined Under Namespace
Classes: NoAliveClientsError
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(test_files = []) ⇒ Server
Returns a new instance of Server.
62
63
64
65
66
67
68
69
|
# File 'lib/dtr/base.rb', line 62
def initialize(test_files=[])
@test_files = test_files
@packer = AveragePacker.new
@runner_name = RubyRunner.name
@server_signature = Object.new.to_s
@report_signature = nil
@raise_on_no_alive_client = DTROPTIONS[:raise_on_no_alive_client]
end
|
Instance Attribute Details
#latest_build_time ⇒ Object
Returns the value of attribute latest_build_time.
60
61
62
|
# File 'lib/dtr/base.rb', line 60
def latest_build_time
@latest_build_time
end
|
#packer ⇒ Object
Returns the value of attribute packer.
60
61
62
|
# File 'lib/dtr/base.rb', line 60
def packer
@packer
end
|
#runner_name ⇒ Object
Returns the value of attribute runner_name.
60
61
62
|
# File 'lib/dtr/base.rb', line 60
def runner_name
@runner_name
end
|
#server_signature ⇒ Object
Returns the value of attribute server_signature.
60
61
62
|
# File 'lib/dtr/base.rb', line 60
def server_signature
@server_signature
end
|
#test_files ⇒ Object
Returns the value of attribute test_files.
60
61
62
|
# File 'lib/dtr/base.rb', line 60
def test_files
@test_files
end
|
Instance Method Details
#add_client(client) ⇒ Object
121
122
123
124
|
# File 'lib/dtr/base.rb', line 121
def add_client(client)
clients_map[client.name] = client
client_setup_logs[client.name] = nil
end
|
#available_clients ⇒ Object
82
83
84
85
86
|
# File 'lib/dtr/base.rb', line 82
def available_clients
alive_clients = self.clients.select{|client| client.server_signature == @server_signature}
raise NoAliveClientsError.new if @raise_on_no_alive_client && alive_clients.empty?
alive_clients.select{|client| client.idle?}
end
|
#client_setup_logs ⇒ Object
117
118
119
|
# File 'lib/dtr/base.rb', line 117
def client_setup_logs
@client_setup_logs ||= {}
end
|
#clients ⇒ Object
78
79
80
|
# File 'lib/dtr/base.rb', line 78
def clients
clients_map.values
end
|
#complete? ⇒ Boolean
92
93
94
|
# File 'lib/dtr/base.rb', line 92
def complete?
@complete ||= false
end
|
#latest_build_summary ⇒ Object
71
72
73
74
75
76
|
# File 'lib/dtr/base.rb', line 71
def latest_build_summary
raise 'Server never ran!' unless latest_build_time
%{Finished in #{format('%.1f', latest_build_time)} seconds.
#{collect_report(:tests)}, #{collect_report(:assertions)}, #{collect_report(:failures)}, #{collect_report(:errors)}}
end
|
#reports ⇒ Object
113
114
115
|
# File 'lib/dtr/base.rb', line 113
def reports
@reports ||= {}
end
|
#run(opt = {}) ⇒ Object
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
# File 'lib/dtr/base.rb', line 96
def run(opt={})
opt = {:wait_for_reports => true, :setup => false}.merge opt
run_start(opt)
@run_once = false
loop do
break if complete?
run_once unless @run_once
@run_once = DTROPTIONS[:packing_once]
break if !opt[:wait_for_reports] || complete?
sleep(DTROPTIONS[:wait_a_moment]) if DTROPTIONS[:wait_a_moment]
break if complete?
end
ensure
@report_signature = nil if opt[:wait_for_reports]
self.latest_build_time = Time.now - @build_start_time
end
|
#succeeded? ⇒ Boolean
88
89
90
|
# File 'lib/dtr/base.rb', line 88
def succeeded?
complete? && !reports.empty? && reports.values.all?{|report| report.succeeded?}
end
|
#update(signature, report) ⇒ Object
135
136
137
138
139
140
|
# File 'lib/dtr/base.rb', line 135
def update(signature, report)
with_valid_signature(signature) do
self.reports[report.test] = report
@report_signature = nil if @complete = self.reports.keys.size == @test_files.size
end
end
|
#update_setup_log(signature, report) ⇒ Object
126
127
128
129
130
131
132
133
|
# File 'lib/dtr/base.rb', line 126
def update_setup_log(signature, report)
with_valid_signature(signature) do
client_setup_logs[report[:client_name]] = report
if report[:exit_code] != 0
clients_map.delete(report[:client_name])
end
end
end
|