Module: SomePatternHelper
- Defined in:
- lib/patterns/some_pattern.rb
Instance Method Summary collapse
-
#conf_test_pattern(host = HOST, user = USERNAME, password = PASSWORD, modulename, conf_items) ⇒ Object
功能: 配置文件异常测试模式 对指定的配置项进行异常测试 默认的用例集: CaseHouse.get_instance.get_all_number 所有可能的数字边界 CaseHouse.get_instance.rand_string(10,“aA0$”) 随机字符串 CaseHouse.get_instance.rand_string(1,“B”) 空白.
-
#mcpack_test_pattern(mctxt) ⇒ Object
core_check.
Instance Method Details
#conf_test_pattern(host = HOST, user = USERNAME, password = PASSWORD, modulename, conf_items) ⇒ Object
功能:
配置文件异常测试模式对指定的配置项进行异常测试默认的用例集: CaseHouse.get_instance.get_all_number 所有可能的数字边界CaseHouse.get_instance.rand_string(10,“aA0$”) 随机字符串CaseHouse.get_instance.rand_string(1,“B”) 空白
参数解释:
-
host 机器
-
user 用户名
-
password 密码
-
modulename 模块的名字,重启模块需要模块名
-
conf_items 需要进行测试的配置项的名字,是个数组
外部变量:
当用户需要自己定义额外的测试用例集时,可使用下面的变量CONF_TEST_CASE 数组类型
Example:
items=[“name1”, “name2”] CONF_TEST_CASE=[123, “mycase”] conf_test_pattern(“frdtransform”, items) core_check
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/patterns/some_pattern.rb', line 105 def conf_test_pattern(host=HOST, user=USERNAME, password=PASSWORD, modulename, conf_items) bak_conf host, user, password, CONFPATH, "BAK_CONF_BY_CONF_TEST_PATTERN" conf_items.each{|item| CaseHouse.get_instance.get_all_number.each{|item_value| puts "#{item} #{item_value}" modify_conf_single host, user, password, CONFPATH, item, item_value.to_s ssh_cmd host, user, password, "killall -9 #{modulename}" sleep 3 } [ CaseHouse.get_instance.rand_string(10,"aA0$") ].each{|item_value| puts "#{item} #{item_value}" modify_conf_single host, user, password, CONFPATH, item, item_value ssh_cmd host, user, password, "killall -9 #{modulename}" sleep 3 } [ CaseHouse.get_instance.rand_string(1,"B") ].each{|item_value| puts "#{item} #{item_value}" modify_conf_single host, user, password, CONFPATH, item, item_value ssh_cmd host, user, password, "killall -9 #{modulename}" sleep 3 } if (CONF_TEST_CASE.size>0) CONF_TEST_CASE.each{|item_value| puts "#{item} #{item_value}" modify_conf_single host, user, password, CONFPATH, item, item_value ssh_cmd host, user, password, "killall -9 #{modulename}" sleep 3 } end } recover_conf host, user, password, CONFPATH, "BAK_CONF_BY_CONF_TEST_PATTERN" end |
#mcpack_test_pattern(mctxt) ⇒ Object
core_check
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/patterns/some_pattern.rb', line 40 def mcpack_test_pattern(mctxt) tmptxt="#{mctxt}" ret=[] while(tmptxt=~ /"([^"]+)":\(([^\)]+)\)([^ ,}{\[\]]*)/) key=$1 type=$2 value=$3 tmptxt.sub!(/#{key}/,"") CaseHouse.get_instance.get_all_number.each{|line| ret.push mctxt.sub(/"#{key}":\(#{type}\)#{value}/, "\"#{key}\":\(#{type}\)#{line}") } if MCPACK_INTERFACE_TEST_CASE.size > 0 MCPACK_INTERFACE_TEST_CASE.each{|line| ret.push mctxt.sub(/"#{key}":\(#{type}\)#{value}/, "\"#{key}\":\(#{type}\)#{line}") } end ret.push mctxt.sub(/"#{key}":\(#{type}\)#{value}/, "") end while(tmptxt=~/"([^"]+)":\"([^ ",}{\[\]]*)\"/) key=$1 value=$2 tmptxt.sub!(/#{key}/,"") txtbig="x"*10000 txteng="xxxxxxxxxx" txtchi="中文测试" txtnull="" ret.push mctxt.sub(/"#{key}":"#{value}"/, "\"#{key}\":\"#{txtbig}\"") ret.push mctxt.sub(/"#{key}":"#{value}"/, "\"#{key}\":\"#{txteng}\"") ret.push mctxt.sub(/"#{key}":"#{value}"/, "\"#{key}\":\"#{txtchi}\"") ret.push mctxt.sub(/"#{key}":"#{value}"/, "\"#{key}\":\"#{txtnull}\"") if MCPACK_INTERFACE_TEST_CASE.size > 0 MCPACK_INTERFACE_TEST_CASE.each{|line| ret.push mctxt.sub(/"#{key}":"#{value}"/, "\"#{key}\":\"#{line}\"") } end ret.push mctxt.sub(/"#{key}":\(#{type}\)#{value}/, "") end ret.push mctxt.gsub(/}/,",\"addbyMcpackPatternStr\":\"xxxx\",\"addbyMcpackPatternNum\":(uint32)0}") return ret end |