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,141 @@
1
+ #!/usr/bin/env ruby
2
+ # coding: utf-8
3
+ #
4
+ # Author:: yzm
5
+ # Date:: 2016-03-16 10:54:56 +0800
6
+ ###########################################
7
+
8
+
9
+
10
+ # 实现mtop请求的核心模块
11
+ require 'common/http/http_helper'
12
+ require 'common/json_helper'
13
+
14
+ module MtopHelper
15
+
16
+ # === 功能:
17
+ # 发起mtop请求,请求方式为get
18
+ # === 参数解释:
19
+ # - opts{:api_name => 'api名称', :api_version => '版本', :api_data => '数据', :env_type => 'waptest'/'wapa'/'m'}
20
+ #
21
+ #
22
+ # === Example:
23
+ # Example #1:
24
+ #
25
+ # opts = {
26
+ # :api_name => 'mtop.trip.hotel.hotelSearch',
27
+ # :api_version => '1.0',
28
+ # :api_data => '{"cityCode":"110100","checkIn":"2016-03-20","checkOut":"2016-03-21","radius":"-1","order":"0","dir":"0","pageNo":"1","pageSize":"20","offset":"-1","sellerId":"-1","isKeZhan":"0","priceMin":"0","priceMax":"-1","labels":"0","isSug":"0","isB2G":"0","isNeedSelectData":"0","filterByPayment":"0","isDisplayMultiRate":"0","useTemplate":"0","filterLaterPay":"0","isIncludePayLater":"1"}',
29
+ # :env_type => 'waptest'
30
+ # }
31
+ #
32
+ # mtop_get opts
33
+ #
34
+ def mtop_get(opts={})
35
+ operator = MtopV4.new opts
36
+ operator.to_get
37
+ operator.request
38
+ end
39
+
40
+ # === 功能:
41
+ # 发起mtop请求,请求方式为post
42
+ # === 参数解释:
43
+ # - opts{:api_name => 'api名称', :api_version => '版本', :api_data => '数据', :env_type => 'waptest'/'wapa'/'m'}
44
+ #
45
+ #
46
+ # === Example:
47
+ # Example #1:
48
+ # opts = {
49
+ # :api_name => 'mtop.trip.hotel.hotelSearch',
50
+ # :api_version => '1.0',
51
+ # :api_data => '{"cityCode":"110100","checkIn":"2016-03-20","checkOut":"2016-03-21","radius":"-1","order":"0","dir":"0","pageNo":"1","pageSize":"20","offset":"-1","sellerId":"-1","isKeZhan":"0","priceMin":"0","priceMax":"-1","labels":"0","isSug":"0","isB2G":"0","isNeedSelectData":"0","filterByPayment":"0","isDisplayMultiRate":"0","useTemplate":"0","filterLaterPay":"0","isIncludePayLater":"1"}',
52
+ # :env_type => 'waptest'
53
+ # }
54
+ # mtop_post opts
55
+ #
56
+ def mtop_post(opts={})
57
+ operator = MtopV4.new opts
58
+ operator.to_post
59
+ operator.request
60
+ end
61
+
62
+ class MtopV4
63
+ include HttpHelper
64
+ include JsonHelper
65
+ def initialize(opts = {})
66
+
67
+
68
+ mtop_info = parse_json(get('http://qacenter.alitrip.net/tools/GetMtopInfoAction.do'))
69
+ fail 'GetMtopInfo Fail' if mtop_info['success'] != true
70
+
71
+ @@MTOP_CONFIG = mtop_info['data']
72
+
73
+ if opts.is_a? Hash
74
+ opts = MtopV4.symbolize_keys opts
75
+ @api_name = opts[:api_name] || nil
76
+ @api_version = opts[:api_version] || '*'
77
+ @api_data = opts[:api_data] || {}
78
+ @env_type = opts[:env_type] || 'wapa'
79
+ @ecode_need = opts[:ecode_need] || false
80
+ @user_data = opts[:user_data] || nil
81
+ @http_method = opts[:http_method] || 'POST'
82
+
83
+ @base_url = @@MTOP_CONFIG[@env_type]['url']
84
+ @app_key = @@MTOP_CONFIG[@env_type]['app_key']
85
+ @app_secret = @@MTOP_CONFIG[@env_type]['app_secret']
86
+
87
+ @ttid = @@MTOP_CONFIG['ttid']
88
+ @devid = @@MTOP_CONFIG['devid']
89
+ @req_header = {
90
+ 'm-t' => Time.now.to_i.to_s,
91
+ 'm-appkey' => @app_key,
92
+ 'm-ttid' => @ttid,
93
+ 'm-pv' => '3.0',
94
+ 'm-devid' => @devid
95
+ }
96
+ @cookies = {}
97
+ end
98
+ end
99
+ def to_post
100
+ @http_method = 'POST'
101
+ end
102
+ def to_get
103
+ @http_method = 'GET'
104
+ end
105
+ def update(opts={})
106
+ opts = MtopV4.symbolize_keys opts
107
+ @api_name = opts[:api_name] || nil
108
+ @api_version = opts[:api_version] || '*'
109
+ @api_data = opts[:api_data] || {}
110
+ @env_type = opts[:env_type] || 'waptest'
111
+ @http_method = opts[:http_method] || 'GET'
112
+ end
113
+ def request
114
+ @req_header.store 'm-sign', sign()
115
+ if @http_method === 'GET'
116
+ @url = "http://#{@base_url}/gw/#{@api_name}/#{@api_version}/?data=#{@api_data.to_s}&type=originaljson"
117
+ get @url, parse_json(@api_data), @req_header
118
+ elsif @http_method === 'POST'
119
+ @url = "http://#{@base_url}/gw/#{@api_name}/#{@api_version}/"
120
+ data = {"data" => @api_data};
121
+ post @url, data, @req_header, {}
122
+ end
123
+ parse_json @response.body
124
+ end
125
+
126
+ def sign
127
+ OpenSSL::HMAC.hexdigest('sha1', @app_secret.to_s, ['', @app_key, @api_data.to_s, @req_header['m-t'], @api_name, @api_version, '', @ttid, @devid, '', ''].join('&').to_s)
128
+ end
129
+
130
+ def self.symbolize_keys(hash)
131
+ fail 'symbolize_keys requires a hash' unless hash.is_a? Hash
132
+ result = {}
133
+ hash.each do |key, value|
134
+ key = key.to_sym rescue key # rubocop:disable Style/RescueModifier
135
+ result[key] = value.is_a?(Hash) ? symbolize_keys(value) : value
136
+ end
137
+ result
138
+ end
139
+ end
140
+ end
141
+
@@ -0,0 +1,49 @@
1
+ #!/usr/bin/env ruby
2
+ # coding: utf-8
3
+ #
4
+ # Author:: hanyu
5
+ # Date:: 2009.5.7
6
+
7
+
8
+ require 'yaml'
9
+
10
+ # 读取配置,配置文件以YAML的格式进行存储
11
+ #
12
+ # 提供环境切换机制,如下
13
+ #
14
+ # #读取sz00.yml
15
+ # env: sz00
16
+ module ConfigHelper
17
+ # 全局的配置
18
+ if File.exist? "#{$WORK_ROOT}/conf/super_test.yml"
19
+ CONF = YAML.load_file "#{$WORK_ROOT}/conf/super_test.yml"
20
+ $log.debug "load [#{$WORK_ROOT}/conf/super_test.yml] success!"
21
+ elsif File.exist? "#{$SUPER_ROOT}/conf/super_test.yml"
22
+ CONF = YAML.load_file "#{$SUPER_ROOT}/conf/super_test.yml"
23
+ $log.debug "load [#{$SUPER_ROOT}/conf/super_test.yml] success!"
24
+ else
25
+ raise "[conf/super_test.yml] is not exist!"
26
+ end
27
+
28
+
29
+ $log.debug "load super_test.yml success"
30
+ CONF['env'] = ENV['SUPER_ENV'] unless ENV['SUPER_ENV'].nil?
31
+ if File.exist? "#{$WORK_ROOT}/conf/#{CONF['env']}.yml"
32
+ # 环境相关的配置
33
+ ENV = ENV.to_hash.merge YAML.load_file("#{$WORK_ROOT}/conf/#{CONF['env']}.yml")
34
+ $log.debug "load [#{$WORK_ROOT}/conf/#{CONF['env']}.yml] success!"
35
+ elsif File.exist? "#{$SUPER_ROOT}/conf/#{CONF['env']}.yml"
36
+ # 环境相关的配置
37
+ ENV = ENV.to_hash.merge YAML.load_file("#{$SUPER_ROOT}/conf/#{CONF['env']}.yml")
38
+ $log.debug "load [#{$SUPER_ROOT}/conf/#{CONF['env']}.yml] success!"
39
+ else
40
+ raise "env[#{CONF['env']}.yml] is not exist!"
41
+ end
42
+ end
43
+
44
+
45
+ if __FILE__ == $0
46
+ puts ConfigHelper::CONF
47
+ puts ConfigHelper::ENV
48
+ end
49
+
@@ -0,0 +1,77 @@
1
+ #!/usr/bin/env ruby
2
+ # coding: utf-8
3
+ #
4
+ # Author:: hanyu
5
+ # Date:: 2009.5.7
6
+
7
+ # SHOULD gem install log4r
8
+ require 'log4r'
9
+
10
+
11
+ # 日志打印
12
+ #
13
+ # === Example
14
+ # require 'log_helper'
15
+ #
16
+ # $log.info "o了"
17
+ module MylogHelper
18
+ include Log4r
19
+
20
+ #第一步,配置log
21
+ log = Logger.new "mylog"
22
+ f = PatternFormatter.new(:pattern => "%5l %d %m")
23
+ file = FileOutputter.new('fileOutputter', :filename => "#{$WORK_ROOT}/log/super_test.log",:trunc => false)
24
+ file.only_at DEBUG,INFO
25
+ file.formatter = f
26
+ log.add file
27
+
28
+ file_wf = FileOutputter.new('fileOutputter', :filename => "#{$WORK_ROOT}/log/super_test.log.wf",:trunc => false)
29
+ file_wf.only_at WARN,ERROR,FATAL
30
+ file_wf.formatter = f
31
+ log.add file_wf
32
+ $log = log
33
+
34
+ # 设置日志等级
35
+ #
36
+ # 可用等级:debug/info/warn/error/fatal
37
+ #
38
+ # Example:
39
+ #
40
+ # require 'log_helper'
41
+ #
42
+ # Loghelper::set_level "warn"
43
+ #
44
+ # $log.debug "test deb"
45
+ # $log.info "test info"
46
+ #
47
+ # #上面的日志不会打印,下面的信息才会打印
48
+ #
49
+ # $log.warn "test warn"
50
+ # $log.error "test error"
51
+ # $log.fatal "test fatal"
52
+ def self.set_level(level)
53
+ case level.downcase
54
+ when "debug"
55
+ $log.level = DEBUG
56
+ when "info"
57
+ $log.level = INFO
58
+ when "warn"
59
+ $log.level = WARN
60
+ when "error"
61
+ $log.level = ERROR
62
+ when "fatal"
63
+ $log.level = FATAL
64
+ else
65
+ raise "bad log level"
66
+ end
67
+ end
68
+ end
69
+
70
+ if __FILE__ == $0
71
+ Myloghelper::set_level "debug"
72
+ $log.debug "test deb"
73
+ $log.info "test info"
74
+ $log.warn "test warn"
75
+ $log.error "test error"
76
+ $log.fatal "test fatal"
77
+ end
@@ -0,0 +1,121 @@
1
+ #!/usr/bin/env ruby
2
+ # coding: utf-8
3
+ #
4
+ # Author:: hanyu
5
+ # Date:: 2009.9.12
6
+
7
+
8
+
9
+ # Pairwise (a.k.a. all-pairs) testing is an effective test case generation technique that
10
+ # is based on the observation that most faults are caused by interactions of at most two factors.
11
+ # Pairwise-generated test suites cover all combinations of two therefore are much
12
+ # smaller than exhaustive ones yet still very effective in finding defects.
13
+ #
14
+ #
15
+ # Based on jenny, http://burtleburtle.net/bob/math/jenny.html
16
+ # Thanks Bob Jenkins :)
17
+ #
18
+ module Pairwise
19
+
20
+ # 给定几个数组,按照pairwise算法,从中挑出最小的case集
21
+ # 借助jenny实现pairwise
22
+ def self.jenny(*arrs)
23
+ raise "the number of arguments must > 1" unless arrs.size > 1
24
+ cmd = "jenny -n2"
25
+ arrs.each do |arr|
26
+ raise "argument[#{arr}] must be an Array!" unless arr.is_a?(Array)
27
+ raise "Array[#{arr}]'s size[#{arr.size}] must between in [2,51]" unless arr.size>1 and arr.size<52
28
+ cmd << " #{arr.size}"
29
+ end
30
+
31
+ # 如果包含排除的组合列表
32
+ if block_given?
33
+ #TODO
34
+ end
35
+
36
+ # 开始执行jenny,并获取返回数据
37
+ #p "cmd:#{cmd}"
38
+ result = `#{cmd}`
39
+ pair = []
40
+ result.each_line do |line|
41
+ line.strip!
42
+ la = []
43
+ index = 0
44
+ line.split(" ").each do |str|
45
+ if str[1].ord >= 97 and str[1].ord <=122
46
+ la << arrs[index][str[1].ord-97]
47
+ elsif str[1].ord >= 65 and str[1].ord <= 90
48
+ la << arrs[index][str[1].ord-65+26]
49
+ else
50
+ raise "why you got this str[#{str}] ?"
51
+ end
52
+ index = index + 1
53
+ end
54
+ pair << la
55
+ end
56
+ return pair
57
+ end
58
+
59
+ # === 功能:
60
+ # 给定几个数组,按照pairwise算法,从中挑出最小的case集
61
+ #
62
+ # === 参数解释:
63
+ # - *arrs 可以跟若干个数组参数
64
+ #
65
+ # === Example:
66
+ # Example #1:
67
+ #
68
+ # type_arr = %w{Primary Logical Single Span Stripe Mirror}
69
+ # size_arr = %w{10 100 500 5000 10000 40000}
70
+ # system_arr = %w{FAT FAT32 NTFS}
71
+ # compression_arr = %w{on off}
72
+ #
73
+ # pair = Pairwise.gen(type_arr,size_arr,system_arr,compression_arr)
74
+ #
75
+ # puts pair.size #=> 36
76
+ # p pair #=> [["Primary", "5000", "NTFS", "off"], ...]
77
+ #
78
+ # pair.each do |type,size,system,compression| #=> 可以遍历
79
+ # puts type,size,system,compression
80
+ # end
81
+ #
82
+ def self.gen(*arrs)
83
+ jenny(*arrs)
84
+ end
85
+
86
+ # 与gen一样
87
+ def self.generate(*arrs)
88
+ jenny(*arrs)
89
+ end
90
+
91
+ end
92
+
93
+
94
+
95
+ if __FILE__ == $0
96
+ NAMES = %w{aa fd fef}
97
+ PASSS = %w{1234 34 456 546 678 123 345 654 7653 2345 2345 54 345 43 123 765 76 76 87654 2345 54 9 78 56 34 3 456 765 76 76 876 23 4 56 546 56 5456 545 46 78 9 09 87 65 6 67 9 8 7654 32 34235 678 98 7 6543 2 34 567 8 6 5432 34 567 8 654 3 3 45 67 54 3 45}
98
+
99
+ class MyTest
100
+
101
+ def test2
102
+ ENV['PATH'] = ENV['PATH'] + ":#{ENV['HOME']}/app-test/search/space/super-test/tool"
103
+ re = (Pairwise.jenny NAMES, PASSS, [1,2,3,4,5],[Object.new,Object.new])
104
+ p re
105
+ p re.size
106
+ end
107
+
108
+ def test1
109
+ ENV['PATH'] = ENV['PATH'] + ":#{ENV['HOME']}/app-test/search/space/super-test/tool"
110
+ type_arr = %w{Primary Logical Single Span Stripe Mirror}
111
+ size_arr = %w{10 100 500 5000 10000 40000}
112
+ system_arr = %w{FAT FAT32 NTFS}
113
+ compression_arr = %w{on off}
114
+ pair = Pairwise.jenny(type_arr,size_arr,system_arr,compression_arr)
115
+ puts pair.size
116
+ p pair
117
+ end
118
+ end
119
+ MyTest.new.test1
120
+ end
121
+
@@ -0,0 +1,89 @@
1
+ #!/usr/bin/env ruby
2
+ # coding: utf-8
3
+ #
4
+ # Author:: hanyu
5
+ # Date:: 2009.9.4
6
+
7
+
8
+ # QueryHouse 以线上50w+的真实query集为基础,随机选出N条数据,
9
+ # 50w 是目前的数据量,欢迎对这个数据进行增加、删除、修改、优化,
10
+ # QueryHouse 支持随机读数据文件,所以不用担心数据量太大对程序照成性能或资源上的影响 :)
11
+ # QueryHouse 是一个单例类,使用时可以直接调用其静态方法
12
+ #
13
+ class QueryHouse
14
+
15
+ private_class_method :new
16
+ @@instance = nil
17
+ def self.get_instance
18
+ @@instance = new("#{$SUPER_ROOT}/data/query.house") unless @@instance
19
+ @@instance
20
+ end
21
+
22
+ def initialize query_file
23
+ raise "query.house[#{query_file}] not exist!" unless File.file? query_file
24
+ @query_file = File.new query_file, "r"
25
+ @byte_size = File.size @query_file
26
+ #@size = @query_file.read.count "\n"
27
+ end
28
+
29
+
30
+ # === 功能:
31
+ # 随机取得一个query,一般情况请使用get_query静态方法
32
+ #
33
+ # === 参数解释:
34
+ # - return 返回一个随机query,String类型,
35
+ # - raise 如果失败就抛异常
36
+ #
37
+ # === Example:
38
+ # qs = QueryHouse.get_instance
39
+ # p qs.get_a_rand_query #=> "gp超霸电池"
40
+ #
41
+ def get_a_rand_query
42
+ # 最多尝试3次
43
+ 3.times do
44
+ @query_file.seek rand(@byte_size)
45
+ # 跳过seek所在的一行
46
+ @query_file.gets
47
+ line = @query_file.gets
48
+ return line.rstrip.force_encoding("gbk") unless line.nil?
49
+ end
50
+ raise "Sorry! I can't get any query from file[#{@query_file}]"
51
+ end
52
+
53
+ # === 功能:
54
+ # 随机取得n个query,静态方法哦!!!
55
+ #
56
+ # === 参数解释:
57
+ # - n query数量,默认为1
58
+ # - return query的数组
59
+ # - raise 如果失败就抛异常
60
+ #
61
+ # === Example:
62
+ # p QueryHouse.get_n_query 3 #=> ["gp超霸电池","乔四爷的坑(4)","经典励志格言"]
63
+ #
64
+ def self.get_n_query n=1
65
+ instance = get_instance
66
+ arr = []
67
+ n.times do
68
+ arr << instance.get_a_rand_query
69
+ end
70
+ return arr
71
+ end
72
+
73
+ # === 功能:
74
+ # 随机取得一个query,静态方法哦!!!
75
+ #
76
+ # === 参数解释:
77
+ # - return 一个query,String类型
78
+ # - raise 如果失败就抛异常
79
+ #
80
+ # === Example:
81
+ # p QueryHouse.get_a_query #=> "gp超霸电池"
82
+ #
83
+ def self.get_a_query
84
+ get_instance.get_a_rand_query
85
+ end
86
+
87
+ end
88
+
89
+