super-test 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGE.txt +9 -0
- data/README.txt +13 -0
- data/bin/idb +19 -0
- data/bin/ii +113 -0
- data/bin/istart_mock +36 -0
- data/bin/istop_mock +16 -0
- data/bin/kk +181 -0
- data/bin/rubyatp +42 -0
- data/bin/start_mock +36 -0
- data/bin/stop_mock +16 -0
- data/bin/xgo +45 -0
- data/conf/conf.rb +11 -0
- data/conf/db03.yml +31 -0
- data/conf/db13.yml +37 -0
- data/conf/db19.yml +33 -0
- data/conf/online.yml +32 -0
- data/conf/super_test.yml +40 -0
- data/conf/system.yml +26 -0
- data/conf/sz00.yml +31 -0
- data/conf/sz06.yml +34 -0
- data/conf/wise00.yml +11 -0
- data/data/case.house +0 -0
- data/data/char.house +0 -0
- data/data/images/Bluehills.jpg +0 -0
- data/data/images/Sunset.jpg +0 -0
- data/data/images/Waterlilies.jpg +0 -0
- data/data/images/Winter.jpg +0 -0
- data/data/query.house +18595 -0
- data/data/user.house +8 -0
- data/lib/action/module/check_action.rb +58 -0
- data/lib/action/module/cnnt_action.rb +161 -0
- data/lib/action/module/datacenter_action.rb +48 -0
- data/lib/action/module/http_pack_helper.rb +163 -0
- data/lib/action/module/httpserver_action.rb +297 -0
- data/lib/action/module/inc.rb +21 -0
- data/lib/action/module/mcpack_action.rb +57 -0
- data/lib/action/module/sql_action.rb +84 -0
- data/lib/action/module/ssh_action.rb +37 -0
- data/lib/action/system/user_action.rb +180 -0
- data/lib/common/appium_helper.rb +217 -0
- data/lib/common/atp_helper.rb +74 -0
- data/lib/common/atp_report.rb +344 -0
- data/lib/common/data_house.rb +405 -0
- data/lib/common/data_model.rb +87 -0
- data/lib/common/http/assert_helper.rb +343 -0
- data/lib/common/http/fix_hpricot.rb +118 -0
- data/lib/common/http/html_helper.rb +362 -0
- data/lib/common/http/http_helper.rb +469 -0
- data/lib/common/http/multipart.rb +81 -0
- data/lib/common/isandbox_helper.rb +195 -0
- data/lib/common/json_helper.rb +43 -0
- data/lib/common/mock_helper.rb +168 -0
- data/lib/common/mtop_helper.rb +141 -0
- data/lib/common/myconf_helper.rb +49 -0
- data/lib/common/mylog_helper.rb +77 -0
- data/lib/common/pairwise.rb +121 -0
- data/lib/common/query_house.rb +89 -0
- data/lib/common/report_helper.rb +97 -0
- data/lib/common/robot_helper.rb +85 -0
- data/lib/common/socket/check.rb +325 -0
- data/lib/common/socket/conf_modifier.rb +149 -0
- data/lib/common/socket/context.rb +55 -0
- data/lib/common/socket/data.rb +392 -0
- data/lib/common/socket/data_helper.rb +41 -0
- data/lib/common/socket/env.rb +317 -0
- data/lib/common/socket/inc.rb +24 -0
- data/lib/common/socket/log.rb +213 -0
- data/lib/common/socket/log4s.rb +58 -0
- data/lib/common/socket/log_helper.rb +332 -0
- data/lib/common/socket/my_sql.rb +77 -0
- data/lib/common/socket/net.rb +74 -0
- data/lib/common/socket/network.rb +115 -0
- data/lib/common/socket/rlib/conf_modifier.rb +130 -0
- data/lib/common/socket/rlib/data_helper.rb +33 -0
- data/lib/common/socket/rlib/log_helper.rb +303 -0
- data/lib/common/socket/rlib/process_helper.rb +91 -0
- data/lib/common/socket/stub.rb +276 -0
- data/lib/common/socket/util.rb +266 -0
- data/lib/patterns/inc.rb +10 -0
- data/lib/patterns/mc_base_pattern.rb +474 -0
- data/lib/patterns/some_pattern.rb +145 -0
- data/lib/super_test.rb +114 -0
- data/log/super_test.log +0 -0
- data/log/super_test.log.wf +0 -0
- data/test/cover_me.rb +6 -0
- data/tool/jenny +0 -0
- data/tool/mcsend/mcsend2 +0 -0
- data/tool/mcsend/mcsend2_shead +0 -0
- data/tool/mcserver/conf/mcserver.conf +77 -0
- data/tool/mcserver/conf/mcserverauthip +17 -0
- data/tool/mcserver/mcserver +0 -0
- data/tool/mcserver/mcserver_trans +0 -0
- data/tool/mysql +0 -0
- data/tool/net/mcsend/mcsend +0 -0
- data/tool/net/mcsend/mcsend_trans +0 -0
- data/tool/net/mcsend/nshead.data +7 -0
- data/tool/net/mcsend/res_nshead.data +7 -0
- data/tool/net/my_client/my_client +0 -0
- data/tool/net/tsclient/client.tcl +205 -0
- data/tool/others/kk +190 -0
- data/tool/others/rubyatp +42 -0
- data/tool/others/supertest_install.sh +34 -0
- data/tool/trip/idb +0 -0
- data/tool/ts-agent/nshead.bft +12 -0
- data/tool/ts-agent/server.conf +10 -0
- data/tool/ts-agent/server.tcl +376 -0
- metadata +275 -0
@@ -0,0 +1,97 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# coding: utf-8
|
3
|
+
#
|
4
|
+
# Author:: zhangxue
|
5
|
+
# Date:: 2016-05-25 14:52:01 +0800
|
6
|
+
###########################################
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
# 测试报告生成工具类
|
11
|
+
module ReportHelper
|
12
|
+
|
13
|
+
# === 功能:
|
14
|
+
# 测试报告生成工具类,输入相关的报告数据,在当前case目录下自动生成html报告
|
15
|
+
# === 参数解释:
|
16
|
+
#testResults = Array[
|
17
|
+
# {"case_name" => "用例名1",
|
18
|
+
# "case_direction" => "用例说明1",
|
19
|
+
# "case_detail"=>"case执行信息1",
|
20
|
+
# "case_result"=>"case执行结果1"},
|
21
|
+
# {"case_name" => "用例名2",
|
22
|
+
# "case_direction" => "用例说明2",
|
23
|
+
# "case_detail"=>"case执行信息2",
|
24
|
+
# "case_result"=>"case执行结果2"}
|
25
|
+
# ]
|
26
|
+
#
|
27
|
+
# === Example:
|
28
|
+
# Example #1:
|
29
|
+
#
|
30
|
+
#title = "大促主会场检查测试报告"
|
31
|
+
#testResults = Array[
|
32
|
+
# {"case_name" => "test_case1",
|
33
|
+
# "case_direction" => "定金规则校验",
|
34
|
+
# "case_detail"=>"商品优惠价为xxx,定金为xxxx,预期为xxx,不符合预期",
|
35
|
+
# "case_result"=>"warning"},
|
36
|
+
# {"case_name"=>"test_case2",
|
37
|
+
# "case_direction"=>"价格校验",
|
38
|
+
# "case_detail"=>"Pass! 商品原价xxx VS 优惠价xxxx",
|
39
|
+
# "case_result"=>"pass"}
|
40
|
+
# ]
|
41
|
+
#report_create(title, testResults)
|
42
|
+
def report_create(title,testResults)
|
43
|
+
#TODO
|
44
|
+
html_content = "<!DOCTYPE html><html><head>
|
45
|
+
<style>
|
46
|
+
table {
|
47
|
+
border-collapse: collapse;
|
48
|
+
}
|
49
|
+
|
50
|
+
table,th,td
|
51
|
+
{
|
52
|
+
border:1px solid #AAAAAA;
|
53
|
+
font-size:14px;
|
54
|
+
height:50px;
|
55
|
+
}
|
56
|
+
|
57
|
+
th
|
58
|
+
{
|
59
|
+
background-color:#CCDDFF;
|
60
|
+
font-size:16px;
|
61
|
+
}
|
62
|
+
|
63
|
+
td
|
64
|
+
{
|
65
|
+
font-size:14px;
|
66
|
+
}
|
67
|
+
</style>
|
68
|
+
|
69
|
+
<title> #{title} </title></head><body><p>#{title}</p><div><table border=\"1\" >
|
70
|
+
<tr>\
|
71
|
+
<th>case名</th>\
|
72
|
+
<th>case说明</th>\
|
73
|
+
<th>case执行详情</th>\
|
74
|
+
<th>case结果</th>\
|
75
|
+
</tr>"
|
76
|
+
for num in 0..(testResults.length-1)
|
77
|
+
html_content += "<tr><td> #{testResults[num]["case_name"]} </td>\
|
78
|
+
<td> #{testResults[num]["case_direction"]} </td>\
|
79
|
+
<td> #{testResults[num]["case_detail"]} </td>\
|
80
|
+
<td> #{testResults[num]["case_result"]} </td>\
|
81
|
+
</tr>"
|
82
|
+
end
|
83
|
+
puts html_content += "</table><div></body></html>"
|
84
|
+
time = Time.new.strftime("%Y%m%d%H%M%S")
|
85
|
+
|
86
|
+
file = File.new("testresult_#{time}.html","w")
|
87
|
+
file.puts html_content
|
88
|
+
file.close
|
89
|
+
|
90
|
+
end
|
91
|
+
|
92
|
+
|
93
|
+
end
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
|
@@ -0,0 +1,85 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# coding: utf-8
|
3
|
+
#
|
4
|
+
# Author:: hanyu
|
5
|
+
# Date:: 2009.7.7
|
6
|
+
|
7
|
+
if __FILE__ == $0
|
8
|
+
$LIB_ROOT = "#{File.dirname(__FILE__)}/.."
|
9
|
+
$TEST_ROOT = "#{$LIB_ROOT}/.."
|
10
|
+
$: << "#{$LIB_ROOT}"
|
11
|
+
require 'common/log_helper'
|
12
|
+
require 'common/config_helper'
|
13
|
+
require 'common/http_helper'
|
14
|
+
require 'common/assert_helper'
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
module RobotHelper
|
19
|
+
|
20
|
+
# === 功能:
|
21
|
+
# 灌数据专用方法
|
22
|
+
#
|
23
|
+
# === 参数解释:
|
24
|
+
# - total_num 灌数据的总数
|
25
|
+
# - thread_num 使用的线程数,默认为10
|
26
|
+
#
|
27
|
+
# === Example:
|
28
|
+
# # 开20个线程来并发进行操作
|
29
|
+
# robot 100,20 do |i|
|
30
|
+
# get "http://www.baidu.com/"
|
31
|
+
# end
|
32
|
+
#
|
33
|
+
def robot(total_num,thread_num=10)
|
34
|
+
@is_press = true
|
35
|
+
threads = []
|
36
|
+
step = (total_num.to_f/thread_num.ceil).ceil
|
37
|
+
raise "total_num must >0" if step <= 0
|
38
|
+
remain = total_num % thread_num
|
39
|
+
remain = thread_num if remain == 0
|
40
|
+
cur = 1
|
41
|
+
remain.times do |i|
|
42
|
+
threads << Thread.new(step) do |mystep|
|
43
|
+
mystep.times { |j| yield(cur);cur+=1 }
|
44
|
+
end
|
45
|
+
end
|
46
|
+
remain.upto(thread_num-1) do |i|
|
47
|
+
threads << Thread.new(step-1) do |mystep|
|
48
|
+
mystep.times { |j| yield(cur);cur+=1 }
|
49
|
+
end
|
50
|
+
end
|
51
|
+
threads.each { |aThread| aThread.join }
|
52
|
+
@is_press = false
|
53
|
+
$log.debug "robot total_num[#{total_num}] thread_num[#{thread_num}] success!"
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
if __FILE__ == $0
|
60
|
+
class MyTest
|
61
|
+
include HttpHelper
|
62
|
+
include RobotHelper
|
63
|
+
include AssertHelper
|
64
|
+
def test_1
|
65
|
+
@cookies = {}
|
66
|
+
puts Time.now
|
67
|
+
robot(1000) do
|
68
|
+
get "http://sz-testing-space02.sz01.baidu.com:8081/st/loginok.html"
|
69
|
+
assert_ok
|
70
|
+
end
|
71
|
+
puts Time.now
|
72
|
+
end
|
73
|
+
def test_2
|
74
|
+
@cookies = {}
|
75
|
+
puts Time.now
|
76
|
+
1000.times do
|
77
|
+
get "http://sz-testing-space02.sz01.baidu.com:8081/st/loginok.html"
|
78
|
+
end
|
79
|
+
puts Time.now
|
80
|
+
end
|
81
|
+
end
|
82
|
+
MyTest.new.test_1
|
83
|
+
#MyTest.new.test_2
|
84
|
+
end
|
85
|
+
|
@@ -0,0 +1,325 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# coding: utf-8
|
3
|
+
$LOAD_PATH << File.join(File.dirname(__FILE__), '.')
|
4
|
+
|
5
|
+
require 'log'
|
6
|
+
require 'data'
|
7
|
+
|
8
|
+
#============================================================
|
9
|
+
# 校验相关服务的顶层接口
|
10
|
+
# e.g. log/data/env...
|
11
|
+
# Author:: chenjie
|
12
|
+
# Data:: 2009-4-30
|
13
|
+
#
|
14
|
+
# 建议使用的ruby assert库子集
|
15
|
+
#
|
16
|
+
# Asserts that boolean is not false or nil.
|
17
|
+
# Example:
|
18
|
+
# assert [1, 2].include?(5)
|
19
|
+
# assert(boolean, message=nil)
|
20
|
+
#
|
21
|
+
# Passes if expected == +actual.
|
22
|
+
# Note that the ordering of arguments is important, since a helpful error message is generated when this one
|
23
|
+
# fails that tells you the values of expected and actual.
|
24
|
+
# Example:
|
25
|
+
# assert_equal 'MY STRING', 'my string'.upcase
|
26
|
+
# assert_equal(expected, actual, message=nil)
|
27
|
+
#
|
28
|
+
# Passes if string =~ pattern.
|
29
|
+
# Example:
|
30
|
+
# assert_match(/\d+/, 'five, 6, seven')
|
31
|
+
# assert_match(pattern, string, message="")
|
32
|
+
#
|
33
|
+
# Passes if object is nil.
|
34
|
+
# Example:
|
35
|
+
# assert_nil [1, 2].uniq!
|
36
|
+
# assert_nil(object, message="")
|
37
|
+
#
|
38
|
+
# Passes if expected != actual
|
39
|
+
# Example:
|
40
|
+
# assert_not_equal 'some string', 5
|
41
|
+
# assert_not_equal(expected, actual, message="")
|
42
|
+
#
|
43
|
+
# Passes if ! object .nil?
|
44
|
+
# Example:
|
45
|
+
# assert_not_nil '1 two 3'.sub!(/two/, '2')
|
46
|
+
# assert_not_nil(object, message="")
|
47
|
+
#
|
48
|
+
# Flunk always fails.
|
49
|
+
# Example:
|
50
|
+
# flunk 'Not done testing yet.'
|
51
|
+
# flunk(message="Flunked")
|
52
|
+
#
|
53
|
+
#============================================================
|
54
|
+
|
55
|
+
module Check
|
56
|
+
include Log
|
57
|
+
include DATA
|
58
|
+
|
59
|
+
|
60
|
+
#=======================
|
61
|
+
# Log
|
62
|
+
#=======================
|
63
|
+
|
64
|
+
# ===功能:
|
65
|
+
# 验证最新的日志内容中匹配到关键字
|
66
|
+
# ===参数
|
67
|
+
# - host
|
68
|
+
# - log_path
|
69
|
+
# - log_name
|
70
|
+
# - log_level 日志级别数字,可以包含如下枚举值["DEBUG", "NOTICE", "WARNING", "FATAL"]
|
71
|
+
# - pattern
|
72
|
+
# - n expected match times
|
73
|
+
# - msg
|
74
|
+
# pass if the newly log content match the pattern n times; fail if not
|
75
|
+
# Example:
|
76
|
+
# assert_log_match_times host, "/home/space/space/log/", "log1", ["DEBUG"], "time", 2
|
77
|
+
def assert_log_match_times host, log_path, log_name, log_level, pattern, n, msg="", user=USERNAME, password=PASSWORD
|
78
|
+
match_times = get_match_times(host, log_path, log_name, log_level, pattern, user, password)
|
79
|
+
$log.debug "match times = #{match_times}"
|
80
|
+
assert_equal n, match_times, msg
|
81
|
+
$log.info "assert log match times success, logfile=#{host}:#{log_path}:#{log_name}, #{log_level}, pattern=#{pattern}, n=#{n}"
|
82
|
+
end
|
83
|
+
|
84
|
+
# ===功能
|
85
|
+
# 验证最新的日志中匹配到关键字的次数
|
86
|
+
# 简化版方法,减少参数传递
|
87
|
+
# 约束: helper中必须定义 IP, PORT, LOG_PATH, LOG, WFLOG等变量
|
88
|
+
# === example:
|
89
|
+
# _assert_log_match_times ["DEBUG"], "time", 2
|
90
|
+
def _assert_log_match_times log_level, pattern, n, msg=""
|
91
|
+
assert_log_match_times IP, LOG_PATH, LOG, log_level, pattern, n, msg
|
92
|
+
end
|
93
|
+
|
94
|
+
# === 功能
|
95
|
+
# 验证最新的异常日志中匹配到关键字的次数
|
96
|
+
# 简化版方法,减少参数传递
|
97
|
+
# 约束: helper中必须定义 IP, PORT, LOG_PATH, LOG, WFLOG等变量
|
98
|
+
# === example:
|
99
|
+
# _assert_wflog_match_times ["DEBUG"], "time", 2
|
100
|
+
def _assert_wflog_match_times log_level, pattern, n, msg=""
|
101
|
+
assert_log_match_times IP, LOG_PATH, WFLOG, log_level, pattern, n, msg
|
102
|
+
end
|
103
|
+
|
104
|
+
|
105
|
+
# === 功能
|
106
|
+
# 验证最新日志中是否匹配到关键字
|
107
|
+
# ===参数
|
108
|
+
# - host
|
109
|
+
# - log_path
|
110
|
+
# - log_name
|
111
|
+
# - log_level 日志级别数字,可以包含如下枚举值["DEBUG", "NOTICE", "WARNING", "FATAL"]
|
112
|
+
# - pattern
|
113
|
+
# - msg
|
114
|
+
# pass if the newly log content match the pattern; fail if not
|
115
|
+
# ===exmaple
|
116
|
+
# assert_log_match host, path, "log1", ["DEBUG", "WARNING"], "time"
|
117
|
+
def assert_log_match host, log_path, log_name, log_level, pattern, msg="", user=USERNAME, password=PASSWORD
|
118
|
+
$log.info "assert log match, logfile=#{host}:#{log_path}:#{log_name}, #{log_level}, #{pattern}"
|
119
|
+
assert(get_match_times(host, log_path, log_name, log_level, pattern, user, password) > 0)
|
120
|
+
$log.info "assert log match success"
|
121
|
+
end
|
122
|
+
|
123
|
+
# ===功能
|
124
|
+
# 验证最新的日志内容中匹配到关键字
|
125
|
+
# 简化版方法,减少参数传递
|
126
|
+
# 约束: helper中必须定义 IP, PORT, LOG_PATH, LOG, WFLOG等变量
|
127
|
+
# ===example
|
128
|
+
# _assert_log_match ["DEBUG"], "time"
|
129
|
+
def _assert_log_match log_level, pattern, msg=""
|
130
|
+
assert_log_match IP, LOG_PATH, LOG, log_level, pattern, msg
|
131
|
+
end
|
132
|
+
|
133
|
+
# ===功能
|
134
|
+
# 验证最新的异常日志中匹配到关键字
|
135
|
+
# 简化版方法,减少参数传递
|
136
|
+
# 约束: helper中必须定义 IP, PORT, LOG_PATH, LOG, WFLOG等变量
|
137
|
+
# ===example
|
138
|
+
# _assert_wflog_match ["DEBUG"], "time"
|
139
|
+
def _assert_wflog_match log_level, pattern, msg=""
|
140
|
+
assert_log_match IP, LOG_PATH, WFLOG, log_level, pattern, msg
|
141
|
+
end
|
142
|
+
|
143
|
+
# ===功能
|
144
|
+
# 验证没有新日志
|
145
|
+
# ===example
|
146
|
+
# assert_no_log host, path, "log1"
|
147
|
+
def assert_no_log host, log_path, log_name, user=USERNAME, password=PASSWORD
|
148
|
+
assert(!has_new_log?(host, log_path, log_name, user, password))
|
149
|
+
$log.info "assert no log success, logfile=#{host}:#{log_path}:#{log_name}"
|
150
|
+
end
|
151
|
+
|
152
|
+
# ===功能
|
153
|
+
# 验证没有新日志
|
154
|
+
# 简化版方法,减少参数传递
|
155
|
+
# 约束: helper中必须定义 IP, PORT, LOG_PATH, LOG, WFLOG等变量
|
156
|
+
# ===example
|
157
|
+
# _assert_no_log
|
158
|
+
def _assert_no_log
|
159
|
+
assert_no_log IP, LOG_PATH, LOG
|
160
|
+
end
|
161
|
+
|
162
|
+
# === 功能
|
163
|
+
# 验证没有新异常日志
|
164
|
+
# 简化版方法,减少参数传递
|
165
|
+
# 约束: helper中必须定义 IP, PORT, LOG_PATH, LOG, WFLOG等变量
|
166
|
+
# === example
|
167
|
+
# _assert_no_wflog
|
168
|
+
def _assert_no_wflog
|
169
|
+
assert_no_log IP, LOG_PATH, WFLOG
|
170
|
+
end
|
171
|
+
|
172
|
+
#=======================
|
173
|
+
# Data
|
174
|
+
#=======================
|
175
|
+
|
176
|
+
# === 功能
|
177
|
+
# 验证两个本地文件的md5相同
|
178
|
+
# === example
|
179
|
+
# assert_file_md5 "/home/space/space/data/file1", "/home/space/space/data/file2"
|
180
|
+
def assert_file_md5 file1, file2, msg=""
|
181
|
+
assert(same_file_md5(file1, file2), msg)
|
182
|
+
$log.info "assert file md5 success, #{file1}, #{file2}"
|
183
|
+
end
|
184
|
+
|
185
|
+
# ===功能
|
186
|
+
# 验证两个本地文件的内容相同
|
187
|
+
# ===example
|
188
|
+
# assert_file_same file1, file2
|
189
|
+
def assert_file_same file1, file2, msg=""
|
190
|
+
$log.debug "assert file same: file1 = #{file1}, file2 = #{file2}"
|
191
|
+
assert(same_file_contents(file1, file2), msg)
|
192
|
+
$log.info "assert file same success, #{file1}, #{file2}"
|
193
|
+
end
|
194
|
+
|
195
|
+
# === 功能:
|
196
|
+
# 验证两个本地文件中的content字段的内容相同
|
197
|
+
# === Example:
|
198
|
+
# assert_content "a.txt", "b.txt"
|
199
|
+
def assert_content file1, file2, msg=""
|
200
|
+
$log.debug "assert content same: file1 = #{file1}, file2 = #{file2}"
|
201
|
+
assert(same_content_value(file1, file2), msg)
|
202
|
+
$log.info "assert content same success, #{file1}, #{file2}"
|
203
|
+
end
|
204
|
+
|
205
|
+
# ===功能
|
206
|
+
# 验证两个本地文件的内容相同,比较文本
|
207
|
+
# 比较时忽略不可见字符
|
208
|
+
# ===example
|
209
|
+
# assert_file_same_by_str file1, file2
|
210
|
+
def assert_file_same_by_str file1, file2, msg=""
|
211
|
+
$log.debug "assert file same by string: file1 = #{file1}, file2 = #{file2}"
|
212
|
+
assert(same_file_str(file1, file2), msg)
|
213
|
+
$log.info "assert file same by string success, #{file1}, #{file2}"
|
214
|
+
end
|
215
|
+
|
216
|
+
# ===功能
|
217
|
+
# 验证file1中的内容是否被file2所包含
|
218
|
+
# 比较时忽略不可见字符
|
219
|
+
# ===example
|
220
|
+
# assert_file_include_by_str file1, file2
|
221
|
+
def assert_file_include_by_str file1, file2, msg=""
|
222
|
+
$log.debug "assert file same by string: file1 = #{file1}, file2 = #{file2}"
|
223
|
+
assert(include_file_str(file1, file2), msg)
|
224
|
+
$log.info "assert file same by string success, #{file1}, #{file2}"
|
225
|
+
end
|
226
|
+
|
227
|
+
# ===功能
|
228
|
+
# 验证(res)nshead文件对应key值的value是否符合预期
|
229
|
+
# ===参数
|
230
|
+
# - head_file
|
231
|
+
# - key
|
232
|
+
# - expect_value
|
233
|
+
# ===example
|
234
|
+
# assert_head_value file1, logid, 3423432
|
235
|
+
# author: chenjie
|
236
|
+
# date: 2009-7-9
|
237
|
+
def assert_head_value head_file, key, expect_value, msg=""
|
238
|
+
$log.debug "assert head value: head_file = #{head_file}, key = #{key}, expect_value = #{expect_value}"
|
239
|
+
value = get_conf '127.0.0.1', head_file, key
|
240
|
+
assert_equal expect_value, value, msg
|
241
|
+
$log.debug "assert head value success, head_file = #{head_file}, key = #{key}, expect_value = #{expect_value}"
|
242
|
+
end
|
243
|
+
|
244
|
+
# ===功能
|
245
|
+
# 验证两个本地文件的内容不同
|
246
|
+
# ===example
|
247
|
+
# assert_file_not_same file1, file2
|
248
|
+
def assert_file_not_same file1, file2, msg=""
|
249
|
+
assert(!same_file_contents(file1, file2), msg)
|
250
|
+
$log.info "assert file not same success, #{file1}, #{file2}"
|
251
|
+
end
|
252
|
+
|
253
|
+
# ===功能
|
254
|
+
# 验证文件内容匹配pattern
|
255
|
+
# ===example
|
256
|
+
# assert_file_match file1, "time"
|
257
|
+
def assert_file_match file, pattern, msg=""
|
258
|
+
assert(file_match?(file, pattern), msg)
|
259
|
+
$log.info "assert file match success, #{file}, #{pattern}"
|
260
|
+
end
|
261
|
+
|
262
|
+
# ===功能
|
263
|
+
# 验证文件内容匹配pattern n次
|
264
|
+
# ===example
|
265
|
+
# assert_file_match_times file1, "time", 3
|
266
|
+
def assert_file_match_times file, pattern, n, msg=""
|
267
|
+
$log.debug "assert file=#{file}, pattern=#{pattern} "
|
268
|
+
assert_equal(n, file_match_times(file, pattern), msg)
|
269
|
+
$log.info "assert file match times success, #{file}, pattern=#{pattern}, n=#{n}"
|
270
|
+
end
|
271
|
+
|
272
|
+
# === 功能:
|
273
|
+
# 验证文件是否存在
|
274
|
+
# === Example:
|
275
|
+
# assert_content "a.txt", "b.txt"
|
276
|
+
def assert_file_exist? host, file_path, msg="", user=USERNAME, password=PASSWORD
|
277
|
+
puts "assert_file_exist? host=#{host}, file_path=#{file_path}"
|
278
|
+
assert(file_exist?(host, file_path, user, password), msg )
|
279
|
+
end
|
280
|
+
|
281
|
+
# ===功能
|
282
|
+
# 验证short是否被long所包含
|
283
|
+
# 比较时忽略不可见字符
|
284
|
+
# ===example
|
285
|
+
# assert_include shortstring, longstring, ""
|
286
|
+
def assert_include short, long, msg
|
287
|
+
minclude = long.strip.chomp.scan(short.strip.chomp)
|
288
|
+
assert(minclude.size>0, msg)
|
289
|
+
end
|
290
|
+
|
291
|
+
#=======================
|
292
|
+
# Env
|
293
|
+
#=======================
|
294
|
+
|
295
|
+
# === 功能
|
296
|
+
# 验证进程启动
|
297
|
+
# === example
|
298
|
+
# assert_process_running host, "friend"
|
299
|
+
def assert_process_running host, module_name, msg="", user=USERNAME, password=PASSWORD
|
300
|
+
assert(is_process_running?(host, module_name, user, password), msg)
|
301
|
+
$log.info "assert process running success, host=#{host}, module=#{module_name}"
|
302
|
+
end
|
303
|
+
|
304
|
+
# ===功能
|
305
|
+
# 验证进程没有启动
|
306
|
+
# === example
|
307
|
+
# assert_process_not_running host, "friend"
|
308
|
+
def assert_process_not_running host, module_name, msg="", user=USERNAME, password=PASSWORD
|
309
|
+
assert(!is_process_running?(host, module_name, user, password), msg)
|
310
|
+
$log.info "assert process not running success, host=#{host}, module=#{module_name}"
|
311
|
+
end
|
312
|
+
|
313
|
+
# ===功能
|
314
|
+
# 验证进程启动线程数
|
315
|
+
# ===example
|
316
|
+
# assert_process_threads host, "friend", 3
|
317
|
+
def assert_process_threads host, module_name,n, msg="", user=USERNAME, password=PASSWORD
|
318
|
+
assert_equal(n, get_thread_num(host, module_name, user, password), msg)
|
319
|
+
$log.info "assert process threads success, host=#{host}, module=#{module_name}, n=#{n}"
|
320
|
+
end
|
321
|
+
|
322
|
+
end
|
323
|
+
|
324
|
+
|
325
|
+
|