super-test 1.0.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (108) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGE.txt +9 -0
  3. data/README.txt +13 -0
  4. data/bin/idb +19 -0
  5. data/bin/ii +113 -0
  6. data/bin/istart_mock +36 -0
  7. data/bin/istop_mock +16 -0
  8. data/bin/kk +181 -0
  9. data/bin/rubyatp +42 -0
  10. data/bin/start_mock +36 -0
  11. data/bin/stop_mock +16 -0
  12. data/bin/xgo +45 -0
  13. data/conf/conf.rb +11 -0
  14. data/conf/db03.yml +31 -0
  15. data/conf/db13.yml +37 -0
  16. data/conf/db19.yml +33 -0
  17. data/conf/online.yml +32 -0
  18. data/conf/super_test.yml +40 -0
  19. data/conf/system.yml +26 -0
  20. data/conf/sz00.yml +31 -0
  21. data/conf/sz06.yml +34 -0
  22. data/conf/wise00.yml +11 -0
  23. data/data/case.house +0 -0
  24. data/data/char.house +0 -0
  25. data/data/images/Bluehills.jpg +0 -0
  26. data/data/images/Sunset.jpg +0 -0
  27. data/data/images/Waterlilies.jpg +0 -0
  28. data/data/images/Winter.jpg +0 -0
  29. data/data/query.house +18595 -0
  30. data/data/user.house +8 -0
  31. data/lib/action/module/check_action.rb +58 -0
  32. data/lib/action/module/cnnt_action.rb +161 -0
  33. data/lib/action/module/datacenter_action.rb +48 -0
  34. data/lib/action/module/http_pack_helper.rb +163 -0
  35. data/lib/action/module/httpserver_action.rb +297 -0
  36. data/lib/action/module/inc.rb +21 -0
  37. data/lib/action/module/mcpack_action.rb +57 -0
  38. data/lib/action/module/sql_action.rb +84 -0
  39. data/lib/action/module/ssh_action.rb +37 -0
  40. data/lib/action/system/user_action.rb +180 -0
  41. data/lib/common/appium_helper.rb +217 -0
  42. data/lib/common/atp_helper.rb +74 -0
  43. data/lib/common/atp_report.rb +344 -0
  44. data/lib/common/data_house.rb +405 -0
  45. data/lib/common/data_model.rb +87 -0
  46. data/lib/common/http/assert_helper.rb +343 -0
  47. data/lib/common/http/fix_hpricot.rb +118 -0
  48. data/lib/common/http/html_helper.rb +362 -0
  49. data/lib/common/http/http_helper.rb +469 -0
  50. data/lib/common/http/multipart.rb +81 -0
  51. data/lib/common/isandbox_helper.rb +195 -0
  52. data/lib/common/json_helper.rb +43 -0
  53. data/lib/common/mock_helper.rb +168 -0
  54. data/lib/common/mtop_helper.rb +141 -0
  55. data/lib/common/myconf_helper.rb +49 -0
  56. data/lib/common/mylog_helper.rb +77 -0
  57. data/lib/common/pairwise.rb +121 -0
  58. data/lib/common/query_house.rb +89 -0
  59. data/lib/common/report_helper.rb +97 -0
  60. data/lib/common/robot_helper.rb +85 -0
  61. data/lib/common/socket/check.rb +325 -0
  62. data/lib/common/socket/conf_modifier.rb +149 -0
  63. data/lib/common/socket/context.rb +55 -0
  64. data/lib/common/socket/data.rb +392 -0
  65. data/lib/common/socket/data_helper.rb +41 -0
  66. data/lib/common/socket/env.rb +317 -0
  67. data/lib/common/socket/inc.rb +24 -0
  68. data/lib/common/socket/log.rb +213 -0
  69. data/lib/common/socket/log4s.rb +58 -0
  70. data/lib/common/socket/log_helper.rb +332 -0
  71. data/lib/common/socket/my_sql.rb +77 -0
  72. data/lib/common/socket/net.rb +74 -0
  73. data/lib/common/socket/network.rb +115 -0
  74. data/lib/common/socket/rlib/conf_modifier.rb +130 -0
  75. data/lib/common/socket/rlib/data_helper.rb +33 -0
  76. data/lib/common/socket/rlib/log_helper.rb +303 -0
  77. data/lib/common/socket/rlib/process_helper.rb +91 -0
  78. data/lib/common/socket/stub.rb +276 -0
  79. data/lib/common/socket/util.rb +266 -0
  80. data/lib/patterns/inc.rb +10 -0
  81. data/lib/patterns/mc_base_pattern.rb +474 -0
  82. data/lib/patterns/some_pattern.rb +145 -0
  83. data/lib/super_test.rb +114 -0
  84. data/log/super_test.log +0 -0
  85. data/log/super_test.log.wf +0 -0
  86. data/test/cover_me.rb +6 -0
  87. data/tool/jenny +0 -0
  88. data/tool/mcsend/mcsend2 +0 -0
  89. data/tool/mcsend/mcsend2_shead +0 -0
  90. data/tool/mcserver/conf/mcserver.conf +77 -0
  91. data/tool/mcserver/conf/mcserverauthip +17 -0
  92. data/tool/mcserver/mcserver +0 -0
  93. data/tool/mcserver/mcserver_trans +0 -0
  94. data/tool/mysql +0 -0
  95. data/tool/net/mcsend/mcsend +0 -0
  96. data/tool/net/mcsend/mcsend_trans +0 -0
  97. data/tool/net/mcsend/nshead.data +7 -0
  98. data/tool/net/mcsend/res_nshead.data +7 -0
  99. data/tool/net/my_client/my_client +0 -0
  100. data/tool/net/tsclient/client.tcl +205 -0
  101. data/tool/others/kk +190 -0
  102. data/tool/others/rubyatp +42 -0
  103. data/tool/others/supertest_install.sh +34 -0
  104. data/tool/trip/idb +0 -0
  105. data/tool/ts-agent/nshead.bft +12 -0
  106. data/tool/ts-agent/server.conf +10 -0
  107. data/tool/ts-agent/server.tcl +376 -0
  108. metadata +275 -0
@@ -0,0 +1,10 @@
1
+ $LOAD_PATH << File.join(File.dirname(__FILE__), '../../conf/')
2
+ $LOAD_PATH << File.join(File.dirname(__FILE__), '.')
3
+ #!/usr/bin/env ruby
4
+ #coding: utf-8
5
+
6
+ require 'some_pattern'
7
+ require 'mc_base_pattern'
8
+
9
+ include SomePatternHelper
10
+ include MCBasePatternHelper
@@ -0,0 +1,474 @@
1
+ #!/usr/bin/env ruby
2
+ # coding: utf-8
3
+ #============================================================
4
+ # mc base pattern
5
+ # Author:: liqiang01
6
+ # Data:: 2009-8-28
7
+ #============================================================
8
+ module MCBasePatternHelper
9
+ include Env
10
+ include Network
11
+ include Check
12
+ include Stub
13
+
14
+ #===============================================
15
+ # send
16
+ #===============================================
17
+
18
+ # ===功能
19
+ # send_mcpack
20
+ # ===参数
21
+ # - ip target ip
22
+ # - port target port
23
+ # - nshead_hash nshead hash, nil to use default value
24
+ # - module_name the testing module name
25
+ # - packno sending mcpack file number
26
+ # - postfix=nil the postfix of the data
27
+ # - delay=0 sending interval(s)
28
+ # ===example
29
+ # mc_send "127.0.0.1", nil, 1
30
+ def mc_send ip, port, nshead_hash, packno, postfix=nil, delay=0
31
+ $log.debug "sending mcpack #{packno}..."
32
+ puts "\n##########sending mcpack #{packno}...##########"
33
+
34
+ #case_path = "#{CASE_ROOT}#{$globals[:MODULE_NAME]}/#{$globals[:CASE_NAME]}/"
35
+ case_path = "#{$CASE_ROOT}/"
36
+ recv_path = ""
37
+ if postfix == nil
38
+ recv_path = "#{case_path}tmp/#{packno}.recv"
39
+ else
40
+ recv_path = "#{case_path}tmp/#{packno}_#{postfix}.recv"
41
+ end
42
+ nshead_send(ip, port, nshead_hash, "#{case_path}data/#{packno}.send", recv_path, delay)
43
+
44
+ #set :SEND,:RECV to $globals
45
+ Context.set :SEND, "#{case_path}data/#{packno}.send"
46
+ Context.set :RECV, "#{case_path}tmp/#{packno}.recv"
47
+
48
+ $log.debug "send end..."
49
+
50
+ #copy res_nshead.data to module case's tmp dir
51
+ if File.exist? "#{MCSEND_PATH}res_nshead.data"
52
+ `cp #{MCSEND_PATH}res_nshead.data #{case_path}tmp/`
53
+ end
54
+
55
+ #set :RES_HEAD to $globalsdd
56
+ Context.set :RES_HEAD, "#{case_path}tmp/res_nshead.data"
57
+ end
58
+
59
+ # ===功能
60
+ # send_mcpack 为通用transfer定制
61
+ # ===参数
62
+ # - ip target ip
63
+ # - port target port
64
+ # - nshead_hash nshead hash, nil to use default value
65
+ # - module_name the testing module name
66
+ # - packno sending mcpack file number
67
+ # - postfix=nil the postfix of the data
68
+ # - delay=0 sending interval(s)
69
+ # ===example
70
+ # mc_trans_send "127.0.0.1", nil, 1
71
+ def mc_trans_send ip, port, nshead_hash, packno, postfix=nil, delay=0
72
+ $log.debug "sending mcpack #{packno}..."
73
+ puts "\n##########sending mcpack #{packno}...##########"
74
+
75
+ #case_path = "#{CASE_ROOT}#{$globals[:MODULE_NAME]}/#{$globals[:CASE_NAME]}/"
76
+ case_path = "#{$CASE_ROOT}/"
77
+ recv_path = ""
78
+ if postfix == nil
79
+ recv_path = "#{case_path}tmp/#{packno}.recv"
80
+ else
81
+ recv_path = "#{case_path}tmp/#{packno}_#{postfix}.recv"
82
+ end
83
+ nshead_trans_send(ip, port, nshead_hash, "#{case_path}data/#{packno}.send", recv_path, delay)
84
+
85
+ #set :SEND,:RECV to $globals
86
+ Context.set :SEND, "#{case_path}data/#{packno}.send"
87
+ Context.set :RECV, "#{case_path}tmp/#{packno}.recv"
88
+
89
+ $log.debug "send end..."
90
+
91
+ #copy res_nshead.data to module case's tmp dir
92
+ if File.exist? "#{MCSEND_PATH}res_nshead.data"
93
+ `cp #{MCSEND_PATH}res_nshead.data #{case_path}tmp/`
94
+ end
95
+
96
+ #set :RES_HEAD to $globalsdd
97
+ Context.set :RES_HEAD, "#{case_path}tmp/res_nshead.data"
98
+ end
99
+
100
+ # ===功能
101
+ # 支持下游桩的mc_send
102
+ # ===参数
103
+ # - ip
104
+ # - port
105
+ # - nshead_hash
106
+ # - prefix: .../$casedir/data/$prefix.send
107
+ # - postfix: tells which stub return what data, .../$casedir/stub/$prefix_$stubname_$postfix.stub; nil by default means the response data is $prefix_$stubname.stub
108
+ # - delay: sending interval
109
+ # ===example
110
+ # mc_stub_send ip, 3308, nil, 1
111
+ def mc_stub_send ip, port, nshead_hash, prefix, postfix=nil, delay=0
112
+ $log.debug "sending mcpack #{prefix}, with stub data #{postfix}..."
113
+ puts "sending mcpack #{prefix}, with stub data #{postfix}..."
114
+
115
+ #case_path = "#{CASE_ROOT}#{$globals[:MODULE_NAME]}/#{$globals[:CASE_NAME]}/"
116
+ case_path = "#{$CASE_ROOT}/"
117
+
118
+ # modify stub's server.conf
119
+ stubs = Context.get :STUBS
120
+ heads = {}
121
+ files = {}
122
+ stubs.each{|stub|
123
+ if postfix != nil
124
+ heads[stub] = "#{case_path}stub/#{prefix}_#{stub}_#{postfix}.head"
125
+ files[stub] = "#{case_path}stub/#{prefix}_#{stub}_#{postfix}.stub"
126
+ else
127
+ heads[stub] = "#{case_path}stub/#{prefix}_#{stub}.head"
128
+ files[stub] = "#{case_path}stub/#{prefix}_#{stub}.stub"
129
+ end
130
+ }
131
+ set_stub_head heads
132
+ set_stub_file files
133
+ sleep 1
134
+
135
+
136
+ #send
137
+ mc_send ip, port, nshead_hash, prefix, postfix
138
+ end
139
+
140
+
141
+ #===============================================
142
+ # asserts
143
+ #===============================================
144
+
145
+ # ===功能
146
+ # 校验两组prefix相同的.expc, .recv文件是否内容一致
147
+ # ===参数
148
+ # - prefix
149
+ # - msg=""
150
+ # ===example
151
+ # mc_assert_pack 1
152
+ def mc_assert_pack prefix, msg=""
153
+ module_name = $globals[:MODULE_NAME]
154
+ case_name = $globals[:CASE_NAME]
155
+ #case_path = "#{CASE_ROOT}#{module_name}/#{case_name}/"
156
+ case_path = "#{$CASE_ROOT}/"
157
+
158
+ postfixes = get_postfixes(module_name, case_name, prefix)
159
+ if postfixes == nil
160
+ flunk "get postfix from data dir fail, check the data dir and the .expc files"
161
+ end
162
+ postfixes.each{|postfix|
163
+ assert_file_same_by_str(case_path+"data/" + prefix + ".expc" + postfix, case_path+"tmp/" + prefix + ".recv" + postfix, msg)
164
+ }
165
+ end
166
+
167
+ # ===功能
168
+ # 校验两组prefix相同的.expc, .recv文件是否内容包含
169
+ # ===参数
170
+ # - prefix
171
+ # - msg=""
172
+ # ===example
173
+ # mc_assert_pack_include 1
174
+ def mc_assert_pack_include prefix, msg=""
175
+ module_name = $globals[:MODULE_NAME]
176
+ case_name = $globals[:CASE_NAME]
177
+ #case_path = "#{CASE_ROOT}#{module_name}/#{case_name}/"
178
+ case_path = "#{$CASE_ROOT}/"
179
+
180
+ postfixes = get_postfixes(module_name, case_name, prefix)
181
+ if postfixes == nil
182
+ flunk "get postfix from data dir fail, check the data dir and the .expc files"
183
+ end
184
+ postfixes.each{|postfix|
185
+ assert_file_include_by_str(case_path+"data/" + prefix + ".expc" + postfix, case_path+"tmp/" + prefix + ".recv" + postfix, msg)
186
+ }
187
+ end
188
+
189
+ # ===功能
190
+ # 校验响应头中指定key的期望值是否正确
191
+ # ===参数
192
+ # - key
193
+ # - expect_value
194
+ # - msg=""
195
+ # ===exmaple
196
+ # mc_assert_head_value "name", "new"
197
+ def mc_assert_head_value key, expect_value, msg=""
198
+ assert_head_value $globals[:RES_HEAD], key, expect_value, msg
199
+ end
200
+
201
+
202
+ #============helper methods=============
203
+
204
+ # ===功能
205
+ # return all the pack numbers in the specified module and case
206
+ # ===example
207
+ # ar = getpacks
208
+ def getpacks(suffix=".send")
209
+ #data_path = "#{CASE_ROOT}#{$globals[:MODULE_NAME]}/#{$globals[:CASE_NAME]}/data/"
210
+ # 保证返回的datai是数字类型的且已经排序
211
+ data_path = "#{$CASE_ROOT}/data/"
212
+ datai = []
213
+ datas = get_all_pack data_path, suffix
214
+ datas.each{ |item|
215
+ datai.push(item.to_i)
216
+ }
217
+ $log.debug "Get packnos from " + data_path
218
+ return datai.sort
219
+ end
220
+
221
+ # ===功能
222
+ # return all the pack in the specified module and case
223
+ # ===example
224
+ # ar = getpacks_all
225
+ def getpacks_all(suffix=".send")
226
+ #data_path = "#{CASE_ROOT}#{$globals[:MODULE_NAME]}/#{$globals[:CASE_NAME]}/data/"
227
+ # 保证返回data目录下的所有待发送的数据文件 *.send
228
+ data_path = "#{$CASE_ROOT}/data/"
229
+ datai = []
230
+ datas = get_all_pack data_path, suffix
231
+ datas.each{ |item|
232
+ datai.push(item)
233
+ }
234
+ $log.debug "Get packnos from " + data_path
235
+ # 按照字母表进行排序
236
+ return datai.sort
237
+ end
238
+
239
+ # ===功能
240
+ # get the packs query by pattern
241
+ # ===example
242
+ # packs = get_packs
243
+ def get_packs pattern
244
+ #data_path = "#{CASE_ROOT}#{$globals[:MODULE_NAME]}/#{$globals[:CASE_NAME]}/data/"
245
+ data_path = "#{$CASE_ROOT}/data/"
246
+
247
+ packs = []
248
+ files = Dir.glob(File.join(data_path, pattern))
249
+ files.each{|file|
250
+ arr = file.split /\//
251
+ entry = arr[arr.size-1]
252
+ pack = entry[0, entry.size-5]
253
+ packs << pack
254
+ }
255
+
256
+ return packs
257
+ end
258
+
259
+
260
+ # ===功能
261
+ # get all the postfix of a specified packno
262
+ # === Example
263
+ #
264
+ # data/1.expc, 1.expc.1, 1.expc.2
265
+ # return array ["", ".1", ".2"]
266
+ def get_postfixes(module_name, case_name, packno)
267
+ #data_path = "#{CASE_ROOT}#{module_name}/#{case_name}/data/"
268
+ data_path = "#{$CASE_ROOT}/data/"
269
+ $log.debug "get postfixes from #{data_path} where packno = #{packno}"
270
+
271
+ #param check
272
+ if !File.directory?(data_path) || !File.exist?(data_path) then
273
+ $log.debug "bad data path=" + data_path
274
+ return nil
275
+ end
276
+
277
+ postfixes = Array.new
278
+ Dir.foreach(data_path) do |entry|
279
+ if entry.match("#{packno}.expc.*") then
280
+ matches = entry.scan(/.*expc(.*)/)
281
+ postfixes << matches[0][0]
282
+ end
283
+ end
284
+ if postfixes.size == 0 then
285
+ return nil
286
+ $log.warn "packno=#{packno} should have at least one expct data"
287
+ end
288
+
289
+ $log.debug "postfixes = #{postfixes} and size = #{postfixes.size}"
290
+ return postfixes
291
+ end
292
+
293
+ # ===功能
294
+ # mc_base模式
295
+ #
296
+ # ===参数
297
+ # 无
298
+ #
299
+ # ===Example
300
+ # mc_base_pattern.each{ |packno|
301
+ # monitor_log IP, LOG_PATH, LOG
302
+ # mc_send IP, PORT, nil, packno
303
+ # 对于给通用tranfer模块发送,请使用:
304
+ # mc_trans_send IP, PORT, nil, packno
305
+ # mc_assert_pack "#{packno}", "@#{packno}: expect pack is not equal to recv pack!"
306
+ # assert_log_match_times IP, LOG_PATH, LOG, ["NOTICE"], "users_getInfo", 1
307
+ # }
308
+ #
309
+ # 备注:
310
+ # 能保证发送的数据按照前缀的顺序发送
311
+ def mc_base_pattern()
312
+ puts "+++++++++about to execute case #{Context.get 'CASE_NAME'}+++++++++"
313
+ $log.info "+++++++++about to execute case #{Context.get 'CASE_NAME'}+++++++++"
314
+ datas = getpacks
315
+
316
+ if datas != nil && datas.length > 0 then
317
+ return datas
318
+ else
319
+ return nil
320
+ end
321
+ puts "+++++++++end executing case #{Context.get 'CASE_NAME'}+++++++++"
322
+ $log.info "+++++++++end executing case #{Context.get 'CASE_NAME'}+++++++++"
323
+ end
324
+
325
+
326
+ # ===功能
327
+ # mc_base模式的变种,将发送data目录下的所有数据文件
328
+ #
329
+ # ===参数
330
+ # 无
331
+ #
332
+ # ===Example
333
+ # mc_base_all_pattern.each{ |packno|
334
+ # monitor_log IP, LOG_PATH, LOG
335
+ # mc_send IP, PORT, nil, packno
336
+ # 对于给通用tranfer模块发送,请使用:
337
+ # mc_trans_send IP, PORT, nil, packno
338
+ # mc_assert_pack "#{packno}", "@#{packno}: expect pack is not equal to recv pack!"
339
+ # assert_log_match_times IP, LOG_PATH, LOG, ["NOTICE"], "users_getInfo", 1
340
+ # }
341
+ #
342
+ # 备注:
343
+ # 能保证发送的数据按照前缀的顺序发送
344
+ def mc_base_all_pattern()
345
+ puts "+++++++++about to execute case #{Context.get 'CASE_NAME'}+++++++++"
346
+ $log.info "+++++++++about to execute case #{Context.get 'CASE_NAME'}+++++++++"
347
+ datas = getpacks_all
348
+
349
+ if datas != nil && datas.length > 0 then
350
+ return datas
351
+ else
352
+ return nil
353
+ end
354
+ puts "+++++++++end executing case #{Context.get 'CASE_NAME'}+++++++++"
355
+ $log.info "+++++++++end executing case #{Context.get 'CASE_NAME'}+++++++++"
356
+ end
357
+
358
+
359
+ # ===功能
360
+ # cm transfer测试模式
361
+ # 发送cm,检查cm返回数据,检查transfer发送数据
362
+ # 通过前缀来进行数据的匹配检查,不要求每个cm的发送的数据对有对应的transfer返回数据
363
+ # 例如: 1.send 对应1.expc, 不要求同时有 1.trans,如果有则进行transfer返回的数据的检验
364
+ #
365
+ #
366
+ # ===参数
367
+ #
368
+ # ===Example
369
+ # def test_xxx
370
+ # cm_transfer_pattern
371
+ # end
372
+ # def teardown
373
+ # cm_transfer_pattern_stop
374
+ # end
375
+ #
376
+ # 备注:
377
+ # 增加teardown函数处理case运行失败的情况,见: cm_transfer_pattern_stop
378
+ # 能保证发送的数据按照前缀的顺序发送
379
+ def cm_transfer_pattern(ip=HOST, port=PORT)
380
+ # 清理cm transfer原来的数据
381
+ ssh_cmd "rm -fr /home/space/phpcm/data/*; killall -9 phpcm;"
382
+ ssh_cmd "rm -fr /home/space/phptrans/data/transid/*; killall -9 transfer;"
383
+ sleep 2
384
+ cmd_str = "cd #{MCSERVER_PATH}; rm log/foo.log; nohup ./mcserver_trans &"
385
+ system "#{cmd_str}"
386
+ datas = getpacks
387
+ datas.each{ |packno|
388
+ mc_send ip, port, nil, packno
389
+ mc_assert_pack_include "#{packno}", "@#{packno}: expect pack is not equal to recv pack!"
390
+ }
391
+ sleep 1
392
+ datas = getpacks ".trans"
393
+ i=0
394
+ open("#{MCSERVER_PATH}/log/foo.log", "r").each{ |line|
395
+ if line=~/--------/ then next end
396
+ puts "trans_rev=================>"
397
+ puts line
398
+ puts "==========================>"
399
+ case_path = "#{$CASE_ROOT}/"
400
+ file = open(case_path+"/data/#{datas[i]}.trans", "r")
401
+ i=i+1
402
+ line2 = file.gets
403
+ file.close
404
+ assert_include line2, line, "Transfer data not match"
405
+ }
406
+ system "killall -9 mcserver_trans"
407
+ end
408
+
409
+
410
+ # ===功能
411
+ # cm transfer测试模式的一种修改,发送的数据就已经是通用transfer的格式,可用于类cm transfer的子系统
412
+ # 发送cm,检查cm返回数据,检查transfer发送数据
413
+ # 通过前缀来进行数据的匹配检查,不要求每个cm的发送的数据对有对应的transfer返回数据
414
+ # 例如: 1.send 对应1.expc, 不要求同时有 1.trans,如果有则进行transfer返回的数据的检验
415
+ #
416
+ #
417
+ # ===参数
418
+ #
419
+ # ===Example
420
+ # def test_xxx
421
+ # cm_transfer_pattern2
422
+ # end
423
+ # def teardown
424
+ # cm_transfer_pattern_stop
425
+ # end
426
+ #
427
+ # 备注:
428
+ # 增加teardown函数处理case运行失败的情况,见: cm_transfer_pattern_stop
429
+ # 能保证发送的数据按照前缀的顺序发送
430
+ def cm_transfer_pattern2(ip=HOST, port=PORT)
431
+ # 清理cm transfer原来的数据
432
+ cmd_str = "cd #{MCSERVER_PATH}; rm log/foo.log; nohup ./mcserver_trans &"
433
+ system "#{cmd_str}"
434
+ datas = getpacks
435
+ datas.each{ |packno|
436
+ mc_trans_send ip, port, nil, packno
437
+ mc_assert_pack_include "#{packno}", "@#{packno}: expect pack is not equal to recv pack!"
438
+ }
439
+ sleep 1
440
+ datas = getpacks ".trans"
441
+ i=0
442
+ open("#{MCSERVER_PATH}/log/foo.log", "r").each{ |line|
443
+ if line=~/--------/ then next end
444
+ puts "trans_rev=================>"
445
+ puts line
446
+ puts "==========================>"
447
+ case_path = "#{$CASE_ROOT}/"
448
+ file = open(case_path+"/data/#{datas[i]}.trans", "r")
449
+ i=i+1
450
+ line2 = file.gets
451
+ file.close
452
+ assert_include line2, line, "Transfer data not match"
453
+ }
454
+ system "killall -9 mcserver_trans"
455
+ end
456
+
457
+
458
+ # ===功能
459
+ # cm transfer模式的停止
460
+ # 主要是停止mcserver的工作
461
+ #
462
+ # ===参数
463
+ # 无
464
+ #
465
+ # ===Example
466
+ # def teardown
467
+ # cm_transfer_pattern_stop
468
+ # end
469
+ #
470
+ def cm_transfer_pattern_stop
471
+ system "killall -9 mcserver_trans"
472
+ end
473
+
474
+ end