Module: Tlb

Defined in:
lib/tlb.rb

Defined Under Namespace

Modules: Balancer, RSpec, RunData, TestUnit, Util Classes: BalancerProcess, ForkBalancerProcess, JavaBalancerProcess

Constant Summary collapse

TLB_OUT_FILE =
'TLB_OUT_FILE'
TLB_ERR_FILE =
'TLB_ERR_FILE'
TLB_APP =
'TLB_APP'

Class Method Summary collapse

Class Method Details

.balance_and_order(file_set) ⇒ Object



77
78
79
80
# File 'lib/tlb.rb', line 77

def self.balance_and_order file_set
  ensure_server_running
  Balancer.send(Balancer::BALANCE_PATH, file_set.join("\n")).split("\n")
end

.balancer_process_typeObject



224
225
226
# File 'lib/tlb.rb', line 224

def self.balancer_process_type
  can_fork? ? ForkBalancerProcess : JavaBalancerProcess
end

.can_fork?Boolean

Returns:

  • (Boolean)


116
117
118
# File 'lib/tlb.rb', line 116

def self.can_fork?
  RUBY_PLATFORM != 'java'
end

.ensure_server_runningObject



96
97
98
# File 'lib/tlb.rb', line 96

def self.ensure_server_running
  server_running? || fail_as_balancer_is_not_running
end

.fail_as_balancer_is_not_runningObject



92
93
94
# File 'lib/tlb.rb', line 92

def self.fail_as_balancer_is_not_running
  raise "Balancer server must be started before tests are run."
end

.relative_file_path(file_name) ⇒ Object



68
69
70
71
# File 'lib/tlb.rb', line 68

def self.relative_file_path file_name
  abs_file_name = File.expand_path(file_name)
  rel_file_name = abs_file_name.sub(/^#{Dir.pwd}/, '.')
end

.relative_file_paths(file_names) ⇒ Object



73
74
75
# File 'lib/tlb.rb', line 73

def self.relative_file_paths file_names
  file_names.map { |file_name| relative_file_path(file_name) }
end

.root_dirObject



104
105
106
# File 'lib/tlb.rb', line 104

def self.root_dir
  File.expand_path(File.join(File.dirname(__FILE__), ".."))
end

.server_commandObject



112
113
114
# File 'lib/tlb.rb', line 112

def self.server_command
  "java -jar #{tlb_jar}"
end

.server_running?Boolean

Returns:

  • (Boolean)


100
101
102
# File 'lib/tlb.rb', line 100

def self.server_running?
  Balancer.running?
end

.start_serverObject



228
229
230
231
232
233
# File 'lib/tlb.rb', line 228

def self.start_server
  ENV[TLB_APP] = 'tlb.balancer.BalancerInitializer'
  bal_klass = balancer_process_type
  @balancer_process = bal_klass.new(server_command)
  Balancer.wait_for_start
end

.stop_serverObject



235
236
237
# File 'lib/tlb.rb', line 235

def self.stop_server
  @balancer_process.die
end

.suite_result(suite_name, result) ⇒ Object



82
83
84
85
# File 'lib/tlb.rb', line 82

def self.suite_result suite_name, result
  ensure_server_running
  Balancer.send(Balancer::SUITE_RESULT_REPORTING_PATH, "#{suite_name}: #{result}")
end

.suite_time(suite_name, mills) ⇒ Object



87
88
89
90
# File 'lib/tlb.rb', line 87

def self.suite_time suite_name, mills
  ensure_server_running
  Balancer.send(Balancer::SUITE_TIME_REPORTING_PATH, "#{suite_name}: #{mills}")
end

.tlb_jarObject



108
109
110
# File 'lib/tlb.rb', line 108

def self.tlb_jar
  File.expand_path(Dir.glob(File.join(root_dir, "tlb-alien*")).first)
end