Class: Roma::Test::Scenario

Inherits:
Object
  • Object
show all
Defined in:
lib/roma/tools/test-scenario.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, procs) ⇒ Scenario

Returns a new instance of Scenario.



103
104
105
106
107
108
# File 'lib/roma/tools/test-scenario.rb', line 103

def initialize(path, procs)
  @working_path = path
  @roma_procs = procs
  @stress = Stress.new 1
  @log = Logger.new "./test-scenario.log", "daily"
end

Instance Attribute Details

#logObject (readonly)

Returns the value of attribute log.



101
102
103
# File 'lib/roma/tools/test-scenario.rb', line 101

def log
  @log
end

#roma_procsObject (readonly)

Returns the value of attribute roma_procs.



99
100
101
# File 'lib/roma/tools/test-scenario.rb', line 99

def roma_procs
  @roma_procs
end

#stressObject (readonly)

Returns the value of attribute stress.



100
101
102
# File 'lib/roma/tools/test-scenario.rb', line 100

def stress
  @stress
end

#working_pathObject (readonly)

Returns the value of attribute working_path.



98
99
100
# File 'lib/roma/tools/test-scenario.rb', line 98

def working_path
  @working_path
end

Instance Method Details

#init_romaObject



110
111
112
113
114
115
# File 'lib/roma/tools/test-scenario.rb', line 110

def init_roma
  @log.debug "begin init_roma"
  exec "rm -f localhost_1121?.*"
  exec "bin/mkroute -d 7 #{RomaProc.to_str(@roma_procs)} --replication_in_host"
  @log.debug "end init_roma"
end

#send_recover(addr, port) ⇒ Object



172
173
174
175
176
# File 'lib/roma/tools/test-scenario.rb', line 172

def send_recover addr, port
  commander = Roma::MultiCommander.new "#{addr}_#{port}"
  res = commander.send_cmd "recover", "#{addr}_#{port}"
  puts res
end

#send_stats(addr, port) ⇒ Object



178
179
180
181
182
# File 'lib/roma/tools/test-scenario.rb', line 178

def send_stats addr, port
  commander = Roma::MultiCommander.new "#{addr}_#{port}"
  res = commander.send_cmd "stats run", "#{addr}_#{port}"
  puts res
end

#send_stats_routing_nodes_length(addr, port) ⇒ Object



184
185
186
187
188
189
190
191
192
193
194
# File 'lib/roma/tools/test-scenario.rb', line 184

def send_stats_routing_nodes_length addr, port
  commander = Roma::MultiCommander.new "#{addr}_#{port}"
  res = commander.send_cmd "stats routing.nodes.length", "#{addr}_#{port}"
  splited = res.split(' ')
  splited.each_with_index { |w, i|
    if w == "routing.nodes.length"
      return splited[i + 1].to_i
    end
  }
  raise "not found a specified property: routing.nodes.length"
end

#send_stats_run_acquire_vnodes(addr, port) ⇒ Object



196
197
198
199
200
201
202
203
204
205
206
# File 'lib/roma/tools/test-scenario.rb', line 196

def send_stats_run_acquire_vnodes addr, port
  commander = Roma::MultiCommander.new "#{addr}_#{port}"
  res = commander.send_cmd "stats stats.run_acquire_vnodes", "#{addr}_#{port}"
  splited = res.split(' ')
  splited.each_with_index { |w, i|
    if w == "stats.run_acquire_vnodes"
      return splited[i + 1] == "true"
    end
  }
  raise "not found a specified property: stats.run_acquire_vnodes"
end

#start_romaObject



117
118
119
120
121
122
123
# File 'lib/roma/tools/test-scenario.rb', line 117

def start_roma
  @log.debug "begin start_roma"
  @roma_procs.length.times { |i|
    start_roma_proc i
  }
  @log.debug "end start_roma"
end

#start_roma_client(addr, port) ⇒ Object



164
165
166
# File 'lib/roma/tools/test-scenario.rb', line 164

def start_roma_client addr, port
  @stress.start addr, port
end

#stop_romaObject



149
150
151
152
153
154
155
# File 'lib/roma/tools/test-scenario.rb', line 149

def stop_roma
  @log.debug "begin start_roma"
  @roma_procs.length.times { |i|
    stop_roma_proc i
  }
  @log.debug "end start_roma"
end

#stop_roma_clientObject



168
169
170
# File 'lib/roma/tools/test-scenario.rb', line 168

def stop_roma_client
  @stress.runnable = false
end

#test_kill_join_recoverObject



208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
# File 'lib/roma/tools/test-scenario.rb', line 208

def test_kill_join_recover
  @log.info "begin method test_kill_join_recover"

  # initialize a ROMA
  init_roma

  # start a ROMA
  start_roma

  sleep 10

  # stress 
  start_roma_client @roma_procs[0].addr, @roma_procs[0].port

  sleep 2

  nlen = send_stats_routing_nodes_length @roma_procs[0].addr, @roma_procs[0].port
  if nlen != 3
    raise "fatal error nlen: #{nlen}"
  end

  sleep 2

  # stop the specified roma process
  stop_roma_proc 2

  sleep 10

  nlen = send_stats_routing_nodes_length @roma_procs[0].addr, @roma_procs[0].port
  if nlen != 2
    raise "fatal error nlen: #{nlen}"
  end

  #ret = send_stats_run_acquire_vnodes @roma_procs[0].addr, @roma_procs[0].port
  #puts "$$ #{ret}"
  #send_stats @roma_procs[0].addr, @roma_procs[0].port
  #puts "$$"
  #ret = send_stats_run_acquire_vnodes @roma_procs[0].addr, @roma_procs[0].port
  #puts "$$ #{ret}"
  #send_stats @roma_procs[0].addr, @roma_procs[0].port
  #send_recover @roma_procs[0].addr, @roma_procs[0].port


  sleep 2

  stop_roma_client

  #stop_roma
  stop_roma_proc 0
  stop_roma_proc 1

  @log.info "end method test_kill_join_recover"
end

#test_suiteObject



262
263
264
# File 'lib/roma/tools/test-scenario.rb', line 262

def test_suite
  test_kill_join_recover
end