class Roma::Test::Scenario
Attributes
log[R]
roma_procs[R]
stress[R]
working_path[R]
Public Class Methods
new(path, procs)
click to toggle source
# File lib/roma/tools/test-scenario.rb 103 def initialize(path, procs) 104 @working_path = path 105 @roma_procs = procs 106 @stress = Stress.new 1 107 @log = Logger.new "./test-scenario.log", "daily" 108 end
Public Instance Methods
init_roma()
click to toggle source
# File lib/roma/tools/test-scenario.rb 110 def init_roma 111 @log.debug "begin init_roma" 112 exec "rm -f localhost_1121?.*" 113 exec "bin/mkroute -d 7 #{RomaProc.to_str(@roma_procs)} --replication_in_host" 114 @log.debug "end init_roma" 115 end
send_recover(addr, port)
click to toggle source
# File lib/roma/tools/test-scenario.rb 172 def send_recover addr, port 173 commander = Roma::MultiCommander.new "#{addr}_#{port}" 174 res = commander.send_cmd "recover", "#{addr}_#{port}" 175 puts res 176 end
send_stats(addr, port)
click to toggle source
# File lib/roma/tools/test-scenario.rb 178 def send_stats addr, port 179 commander = Roma::MultiCommander.new "#{addr}_#{port}" 180 res = commander.send_cmd "stats run", "#{addr}_#{port}" 181 puts res 182 end
send_stats_routing_nodes_length(addr, port)
click to toggle source
# File lib/roma/tools/test-scenario.rb 184 def send_stats_routing_nodes_length addr, port 185 commander = Roma::MultiCommander.new "#{addr}_#{port}" 186 res = commander.send_cmd "stats routing.nodes.length", "#{addr}_#{port}" 187 splited = res.split(' ') 188 splited.each_with_index { |w, i| 189 if w == "routing.nodes.length" 190 return splited[i + 1].to_i 191 end 192 } 193 raise "not found a specified property: routing.nodes.length" 194 end
send_stats_run_acquire_vnodes(addr, port)
click to toggle source
# File lib/roma/tools/test-scenario.rb 196 def send_stats_run_acquire_vnodes addr, port 197 commander = Roma::MultiCommander.new "#{addr}_#{port}" 198 res = commander.send_cmd "stats stats.run_acquire_vnodes", "#{addr}_#{port}" 199 splited = res.split(' ') 200 splited.each_with_index { |w, i| 201 if w == "stats.run_acquire_vnodes" 202 return splited[i + 1] == "true" 203 end 204 } 205 raise "not found a specified property: stats.run_acquire_vnodes" 206 end
start_roma()
click to toggle source
# File lib/roma/tools/test-scenario.rb 117 def start_roma 118 @log.debug "begin start_roma" 119 @roma_procs.length.times { |i| 120 start_roma_proc i 121 } 122 @log.debug "end start_roma" 123 end
start_roma_client(addr, port)
click to toggle source
# File lib/roma/tools/test-scenario.rb 164 def start_roma_client addr, port 165 @stress.start addr, port 166 end
stop_roma()
click to toggle source
# File lib/roma/tools/test-scenario.rb 149 def stop_roma 150 @log.debug "begin start_roma" 151 @roma_procs.length.times { |i| 152 stop_roma_proc i 153 } 154 @log.debug "end start_roma" 155 end
stop_roma_client()
click to toggle source
# File lib/roma/tools/test-scenario.rb 168 def stop_roma_client 169 @stress.runnable = false 170 end
test_kill_join_recover()
click to toggle source
# File lib/roma/tools/test-scenario.rb 208 def test_kill_join_recover 209 @log.info "begin method test_kill_join_recover" 210 211 # initialize a ROMA 212 init_roma 213 214 # start a ROMA 215 start_roma 216 217 sleep 10 218 219 # stress 220 start_roma_client @roma_procs[0].addr, @roma_procs[0].port 221 222 sleep 2 223 224 nlen = send_stats_routing_nodes_length @roma_procs[0].addr, @roma_procs[0].port 225 if nlen != 3 226 raise "fatal error nlen: #{nlen}" 227 end 228 229 sleep 2 230 231 # stop the specified roma process 232 stop_roma_proc 2 233 234 sleep 10 235 236 nlen = send_stats_routing_nodes_length @roma_procs[0].addr, @roma_procs[0].port 237 if nlen != 2 238 raise "fatal error nlen: #{nlen}" 239 end 240 241 #ret = send_stats_run_acquire_vnodes @roma_procs[0].addr, @roma_procs[0].port 242 #puts "$$ #{ret}" 243 #send_stats @roma_procs[0].addr, @roma_procs[0].port 244 #puts "$$" 245 #ret = send_stats_run_acquire_vnodes @roma_procs[0].addr, @roma_procs[0].port 246 #puts "$$ #{ret}" 247 #send_stats @roma_procs[0].addr, @roma_procs[0].port 248 #send_recover @roma_procs[0].addr, @roma_procs[0].port 249 250 251 sleep 2 252 253 stop_roma_client 254 255 #stop_roma 256 stop_roma_proc 0 257 stop_roma_proc 1 258 259 @log.info "end method test_kill_join_recover" 260 end
test_suite()
click to toggle source
# File lib/roma/tools/test-scenario.rb 262 def test_suite 263 test_kill_join_recover 264 end
Private Instance Methods
exec(cmd)
click to toggle source
# File lib/roma/tools/test-scenario.rb 134 def exec cmd 135 `cd #{@working_path}; #{cmd}` 136 end
get_pid(reg_str)
click to toggle source
# File lib/roma/tools/test-scenario.rb 139 def get_pid reg_str 140 open("| ps -ef | grep romad") { |f| 141 while l = f.gets 142 return $1.to_i if l =~ /(\d+).+ruby\s#{reg_str}/ 143 end 144 } 145 nil 146 end
start_roma_proc(i)
click to toggle source
# File lib/roma/tools/test-scenario.rb 125 def start_roma_proc i 126 @log.debug "begin start_roma_proc" 127 str = "bin/romad #{@roma_procs[i].addr} -p #{@roma_procs[i].port.to_s} -d --replication_in_host" 128 exec str 129 @roma_procs[i].pid = get_pid(str) 130 @log.debug "end start_roma_proc" 131 end
stop_roma_proc(i)
click to toggle source
# File lib/roma/tools/test-scenario.rb 157 def stop_roma_proc i 158 @log.debug "begin start_roma_proc" 159 exec "kill -9 #{@roma_procs[i].pid}" 160 @log.debug "end start_roma_proc" 161 end