actir 1.4.1.3 → 1.4.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f893b2a08e16d02bda24b542460e64593346ee4e
4
- data.tar.gz: 4473e22322a40df9acd73d4de8bdebbc00bf5b05
3
+ metadata.gz: b43d744c66c2dd1e24f9e64b7d2646636c15a793
4
+ data.tar.gz: 23f165b5dd8b7ccf7e198d6d8f10c4b56395c2f1
5
5
  SHA512:
6
- metadata.gz: 9b5f36f880aaca09b07df9eec89dfe54aa62c615cffe6a6c7e5290fdf178610ce9d5bbb43ab83e6d0cd6b21ecbe37523d80486491ac70f9b422b8bb307138759
7
- data.tar.gz: bf237b98db9052f8a5b75632cf6211e0630611b03bf3ba496e2bedbce45381656329057ec7c0f173ecbad65e8d30ae9429c35169a4050c42fafb78067cf11f7a
6
+ metadata.gz: 6b47142432f0de33ffb80f45f402c6b0ea78714b7edd4c108fb243e8d45b795c154be3b236b70ea7c7e3fd8770254a2bef290a82968e0dc3aec98d708b39f47b
7
+ data.tar.gz: 4b7c59ff5a59442be44fa29abce1b2005fe59ca03bc3d0b8419b3645602e7cbc96e97b052b335f0afaced329e96802faa49aef9917285ca2b4af510b96004910
@@ -34,18 +34,6 @@ module Actir
34
34
  def run_tests_in_parallel(num_processes, options)
35
35
  test_results = nil
36
36
 
37
- #修改全局变量$env至对应的预发布环境的名字
38
- # if options[:pre_name]
39
- # # 不等于当前的预发环境
40
- # if options[:pre_name] != $env
41
- # $env = options[:pre_name]
42
- # end
43
- # else
44
- # if options[:pre_name] != $env
45
- # $env = "online"
46
- # end
47
- # end
48
-
49
37
  report_time_taken do
50
38
  groups = @runner.tests_in_groups(options[:files], num_processes, options)
51
39
 
@@ -53,22 +41,26 @@ module Actir
53
41
  # @Date : 2015.3.9
54
42
  # 远程执行模式下获取服务器IP和端口号
55
43
  address = []
56
- if $mode == :remote
57
- address = Actir::Remote.get_remote_address(num_processes)
58
- num_processes = address.size
59
- end
44
+ # if $mode == :remote
45
+ # address = Actir::Remote.get_remote_address(num_processes)
46
+ # num_processes = address.size
47
+ # end
60
48
 
61
49
  #更新百度支付-百付宝的cookies
62
50
  #-u为强制更新,若没有加强制更新命令,则每天自动更新一次
63
- if options[:update] || !(Actir::Config.is_same_day?("cookies", Actir::CookiesBaidu.cookies_path))
64
- begin
65
- Actir::CookiesBaidu.update_all
66
- rescue Exception => e
67
- #若更新baidu_cookies失败,则关闭浏览器,打印错误信息,并中断测试执行
68
- Actir::CookiesBaidu.clear_after_failure
69
- puts "Exception: #{e.message} in"
70
- puts e.backtrace
71
- abort "update baidu cookies failed!!!"
51
+ #qatest模式则不需要更新baiducookies,qatest环境的百度支付已mock
52
+ if $env == "online"
53
+ Actir::CookiesBaidu.init
54
+ if options[:update] || !(Actir::Config.is_same_day?("cookies", Actir::CookiesBaidu.directory))
55
+ begin
56
+ Actir::CookiesBaidu.update_cookies("card1")
57
+ rescue Exception => e
58
+ #若更新baidu_cookies失败,则关闭浏览器,打印错误信息,并中断测试执行
59
+ Actir::CookiesBaidu.clear_after_failure
60
+ puts "Exception: #{e.message} in"
61
+ puts e.backtrace
62
+ abort "update baidu cookies failed!!!"
63
+ end
72
64
  end
73
65
  end
74
66
 
@@ -77,7 +69,7 @@ module Actir
77
69
  #报用例数
78
70
  report_number_of_tests(groups)
79
71
  #报执行环境
80
- report_address_of_env(address)
72
+ # report_address_of_env(address)
81
73
  #并发执行不同group中的测试用例
82
74
  test_results = execute_in_parallel(groups, groups.size, options) do |group|
83
75
  p_num = groups.index(group)
@@ -179,7 +171,7 @@ module Actir
179
171
  @runner = load_runner("test")
180
172
  OptionParser.new do |opts|
181
173
  opts.banner = <<-BANNER.gsub(/^ /, '')
182
- Run all tests in parallel
174
+ Run all testcase in parallel
183
175
  Usage: actir [switches] [--] [files & folders] [-] [testcase_name]
184
176
  Options are:
185
177
  BANNER
@@ -192,53 +184,19 @@ module Actir
192
184
  # default - filesize
193
185
  # TEXT
194
186
  # ) { |type| options[:group_by] = type.to_sym }
187
+ opts.on("-e [online][qatest]", String, "set environment to run testcase, default: online") { |env| env = "online" if ((env != "qatest" && env != "online")|| (env == nil)); $env = env;}
195
188
  opts.on("-r [TIMES]", "--rerun [TIMES]", Integer, "rerun times for failure&error testcase, default: 0") { |n| options[:rerun] = n }
196
- #opts.on("-m [FLOAT]", "--multiply-processes [FLOAT]", Float, "use given number as a multiplier of processes to run") { |multiply| options[:multiply] = multiply }
197
- # opts.on("-i", "--isolate",
198
- # "Do not run any other tests in the group used by --single(-s)") do |pattern|
199
- # options[:isolate] = true
200
- # end
201
- opts.on("-e", "--exec [COMMAND]", "execute this code parallel") { |path| options[:execute] = path }
202
- # opts.on("--serialize-stdout", "Serialize stdout output, nothing will be written until everything is done") { options[:serialize_stdout] = true }
203
- # opts.on("--combine-stderr", "Combine stderr into stdout, useful in conjunction with --serialize-stdout") { options[:combine_stderr] = true }
204
- # opts.on("--non-parallel", "execute same commands but do not in parallel, needs --exec") { options[:non_parallel] = true }
205
- # opts.on("--nice", "execute test commands with low priority") { options[:nice] = true }
189
+ opts.on("-u", "--update", "Update Baifubao's cookies") { options[:update] = true }
206
190
  opts.on("--verbose", "Print more output") { options[:verbose] = true }
207
191
  opts.on("--log", "record exec result to logfile") { options[:log] = true}
208
192
  opts.on("--report", "make a report to show the test result") { options[:report] = true}
209
193
  # opts.on("--remote", "run testcase in remote environment") { options[:mode] = :remote }
210
194
  # opts.on("--local", "run testcase in local environment") { options[:mode] = :local }
211
- # # 填写预发环境,目前只支持bjpre2-4,别的后续再添加
212
- # opts.on("-p", "--pre [PRE]", <<-TEXT.gsub(/^ /, '')
213
- # set pre environment to run testcase:
214
- # bjpre2
215
- # bjpre3
216
- # bjpre4
217
- # TEXT
218
- # ) { |pre| pre = "online" if ( pre != "bjpre2" && pre != "bjpre3" && pre != "bjpre4"); options[:pre_name] = pre }
219
- #add by Hub
220
- #-u commnd, update baifubao's cookies
221
- opts.on("-u", "--update", "Update Baifubao's cookies") { options[:update] = true }
222
- #add by Hub
223
- #-s commnd, show test mode,and remote env ipaddress
224
- # opts.on("-s", "--show [PATH]", "Show Test Mode") do |path|
225
- # abort "Please input project directory path!" if path == nil
226
- # $project_path = File.join(Dir.pwd, path)
227
- # puts division_str
228
- # if Actir::Config.get("config.test_mode.env") == :local
229
- # puts "mode : Local"
230
- # else
231
- # puts "mode : Remote"
232
- # node_name = Actir::Config.get("config.test_mode.docker.name")
233
- # address = Actir::Remote.get_remote_address
234
- # puts "node_num : " + address.size.to_s
235
- # address.each_with_index do |address, i|
236
- # puts $env + node_name + (i+1).to_s + " : " + address
237
- # end
238
- # end
239
- # puts division_str
240
- # exit
241
- # end
195
+ # opts.on("-e", "--exec [COMMAND]", "execute this code parallel") { |path| options[:execute] = path }
196
+ # opts.on("--serialize-stdout", "Serialize stdout output, nothing will be written until everything is done") { options[:serialize_stdout] = true }
197
+ # opts.on("--combine-stderr", "Combine stderr into stdout, useful in conjunction with --serialize-stdout") { options[:combine_stderr] = true }
198
+ # opts.on("--non-parallel", "execute same commands but do not in parallel, needs --exec") { options[:non_parallel] = true }
199
+ # opts.on("--nice", "execute test commands with low priority") { options[:nice] = true }
242
200
  opts.on("-h", "--help", "Show this.") { puts opts; exit }
243
201
  end.parse!(argv)
244
202
 
@@ -1,16 +1,59 @@
1
- require 'watir-webdriver'
2
-
3
1
  module Actir
4
2
  class CookiesBaidu
5
3
 
6
4
  class << self
7
5
 
6
+ # cookies文件初始化
7
+ def init
8
+ need_init_cookies = false
9
+
10
+ #判断文件是否存在
11
+ if file_exists?
12
+ # 读取下配置文件中是否真的有cookies数据,如果没有一样要更新
13
+ cookies = get_cookies("card1")
14
+ # 判断存在的cookies文件是否有规范的cookies内容
15
+ if cookies == nil
16
+ need_init_cookies = true
17
+ else
18
+ if cookies.has_key?(baifubao_BDUSS) && cookies.has_key?(baifubao_STOKEN)
19
+ if cookies[baifubao_BDUSS] == nil || cookies[baifubao_STOKEN] == nil
20
+ need_init_cookies = true
21
+ else
22
+ need_init_cookies = false
23
+ end
24
+ else
25
+ need_init_cookies = true
26
+ end
27
+ end
28
+
29
+ else
30
+ if directory_exists?
31
+ #文件不存在则看目录是否存在
32
+ #目录存在则创建文件
33
+ need_init_cookies = true
34
+ else
35
+ #目录和文件都不存在则创建目录再创建文件
36
+ Dir.mkdir(directory)
37
+ need_init_cookies = true
38
+ end
39
+ end
40
+
41
+ if need_init_cookies == true
42
+ file = File.new(directory + file_name, "w")
43
+ file.syswrite(init_content)
44
+ file.close
45
+ # 暂时先只更新一张卡吧
46
+ update_cookies("card1")
47
+ end
48
+
49
+ end
50
+
8
51
  # 更新百度账号所有的配置文件
9
52
  def update_all(address = [])
10
53
  baidu_card = Actir::Config.get(baifubao_key)
11
54
  # 确认目前可用的卡的数目和cookies文件上的是否匹配
12
55
  # TODO 先不实现,cookies文件上的cards数量过多目前看不影响
13
- # baidu_card_cookies = Actir::Config.get("cookies", cookies_path)
56
+ # baidu_card_cookies = Actir::Config.get("cookies", directory)
14
57
  # if baidu_card_cookies != nill && baidu_card != nil
15
58
  # if baidu_card_cookies.size > baidu_card.size
16
59
  #
@@ -27,7 +70,7 @@ module Actir
27
70
  def re_available
28
71
  #每次登陆都判断一下cookies文件的上一次修改时间和当前时间
29
72
  #如果日期不同,则刷新所有的pay文件中baidu-card的状态
30
- unless Actir::Config.is_same_day?("cookies", cookies_path)
73
+ unless Actir::Config.is_same_day?("cookies", directory)
31
74
  Actir::Config.lock("pay") do
32
75
  str_array = IO.readlines(baifubao_account_file)
33
76
  str_array.each_with_index do |line, index|
@@ -55,10 +98,10 @@ module Actir
55
98
  baidu_card.each do |key, value|
56
99
  if value["available"] == true
57
100
  # 顺便取一下cookies
58
- baidu_card_cookies = Actir::Config.get("cookies." + key, cookies_path)
101
+ baidu_card_cookies = Actir::Config.get("cookies." + key, directory)
59
102
  # value["BAIDUID"] = baidu_card_cookies["BAIDUID"]
60
- value["BDUSS"] = baidu_card_cookies["BDUSS"]
61
- value["STOKEN"] = baidu_card_cookies["STOKEN"]
103
+ value[baifubao_BDUSS] = baidu_card_cookies[baifubao_BDUSS]
104
+ value[baifubao_STOKEN] = baidu_card_cookies[baifubao_STOKEN]
62
105
  #有可用的卡,取出cookies等参数
63
106
  card.store(key, value)
64
107
  break
@@ -69,18 +112,10 @@ module Actir
69
112
  end
70
113
 
71
114
  # 设置不可用的卡
72
- # 入参传入卡的key
73
115
  def set_useless_card(card)
74
116
  Actir::Config.set(baifubao_key + "." + card + "." + "available", "false")
75
117
  end
76
118
 
77
- # 更新baidu_cookies失败后的清理操作。目前需要手动调用,后续优化
78
- def clear_after_failure
79
- if @browser != nil
80
- @browser.close
81
- end
82
- end
83
-
84
119
  # 更新配置文件中的baidu_cookies
85
120
  def update_cookies(card, address = [])
86
121
  #打开百付宝
@@ -124,29 +159,51 @@ module Actir
124
159
  def get_baifubao_cookies
125
160
  sleep 3
126
161
  # id = @browser.cookies[:BAIDUID][:value]
127
- ss = @browser.cookies[:BDUSS][:value]
128
- stoken = @browser.cookies[:STOKEN][:value]
162
+ ss = @browser.cookies[baifubao_BDUSS.to_sym][:value]
163
+ stoken = @browser.cookies[baifubao_STOKEN.to_sym][:value]
129
164
  @browser.close
130
165
  #cookies = " BAIDUID:\s\s\s\s\s\s\"" + id + "\"\n BDUSS:\s\s\s\s\s\s\s\s\"" + ss + "\"\n"
131
166
  #以hash形式返回
132
167
  # {:BAIDUID => id, :BDUSS => ss }
133
- {:BDUSS => ss, :STOKEN => stoken}
168
+ {baifubao_BDUSS.to_sym => ss, baifubao_STOKEN.to_sym => stoken}
169
+ end
170
+
171
+ # 更新baidu_cookies失败后的清理操作。目前需要手动调用,后续优化
172
+ def clear_after_failure
173
+ if @browser != nil
174
+ @browser.close
175
+ end
134
176
  end
135
177
 
136
178
  def modify_cookies(card, cookies)
137
179
  cookies.each do |key, value|
138
- Actir::Config.set("cookies" + "." + card + "." + key.to_s , "\"" + value.to_s + "\"", cookies_path)
180
+ Actir::Config.set("cookies" + "." + card + "." + key.to_s , "\"" + value.to_s + "\"", directory)
139
181
  end
140
182
  end
141
183
 
142
- # 配置文件的上一级路径
143
- def cookies_path
144
- File.join(File.dirname(__FILE__), "cookies")
184
+ def get_cookies(card)
185
+ Actir::Config.get("cookies" + "." + card, directory)
186
+ end
187
+
188
+ def file_exists?
189
+ File::exists?(directory + file_name)
190
+ end
191
+
192
+ def directory_exists?
193
+ File::directory?(directory)
194
+ end
195
+
196
+ # 获取cookies文件的路径
197
+ # 因为涉及到权限问题,路径需要放在个人账号目录下
198
+ # 通过whoami命令获取当前账户名称
199
+ # 暂时存放在/User/xx/目录下
200
+ def directory
201
+ user_name = `whoami`
202
+ return "/Users/" + user_name.chomp + "/cookies/"
145
203
  end
146
204
 
147
- # 配置文件相对路径
148
- def cookies_file
149
- File.join(File.dirname(__FILE__), "cookies", "/cookies.yaml")
205
+ def file_name
206
+ "cookies.yaml"
150
207
  end
151
208
 
152
209
  # 百度账号配置文件
@@ -154,6 +211,25 @@ module Actir
154
211
  File.join(Actir::Config.default_config_dir, "/pay.yaml")
155
212
  end
156
213
 
214
+ # 默认的配置文件内容,cookies的key
215
+ def init_content
216
+ "card1:\n" +
217
+ " " + baifubao_BDUSS + ": \n" +
218
+ " " + baifubao_STOKEN + ": \n"
219
+ end
220
+
221
+
222
+ private
223
+
224
+
225
+ def baifubao_BDUSS
226
+ "BDUSS"
227
+ end
228
+
229
+ def baifubao_STOKEN
230
+ "STOKEN"
231
+ end
232
+
157
233
  def baifubao_key
158
234
  "pay.baifubao"
159
235
  end
@@ -1,3 +1,3 @@
1
1
  module Actir
2
- VERSION = "1.4.1.3"
2
+ VERSION = "1.4.2"
3
3
  end
metadata CHANGED
@@ -1,111 +1,111 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: actir
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1.3
4
+ version: 1.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - hub
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-18 00:00:00.000000000 Z
11
+ date: 2016-05-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: test-unit
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '3.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '3.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: watir-webdriver
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: 0.6.11
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: 0.6.11
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: selenium-webdriver
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '2.45'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '2.45'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: parallel
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: '1.4'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '1.4'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: facets
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ~>
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
75
  version: '2.9'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ~>
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '2.9'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: bundler
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ~>
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
89
  version: '1.7'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ~>
94
+ - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '1.7'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: rake
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ~>
101
+ - - "~>"
102
102
  - !ruby/object:Gem::Version
103
103
  version: '10.0'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ~>
108
+ - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: '10.0'
111
111
  description: Distribut automated testing framework for Web or App.
@@ -117,8 +117,8 @@ executables:
117
117
  extensions: []
118
118
  extra_rdoc_files: []
119
119
  files:
120
- - .gitignore
121
- - .travis.yml
120
+ - ".gitignore"
121
+ - ".travis.yml"
122
122
  - CODE_OF_CONDUCT.md
123
123
  - Gemfile
124
124
  - README.md
@@ -143,9 +143,7 @@ files:
143
143
  - lib/actir/parallel_tests/test/result.rb
144
144
  - lib/actir/parallel_tests/test/runner.rb
145
145
  - lib/actir/remote.rb
146
- - lib/actir/script/cookies/cookies.yaml
147
146
  - lib/actir/script/cookies_baidu.rb
148
- - lib/actir/script/cookies_file.rb
149
147
  - lib/actir/version.rb
150
148
  - lib/actir/webdriver/browser.rb
151
149
  - lib/actir/webdriver/browser_options.rb
@@ -162,17 +160,17 @@ require_paths:
162
160
  - lib
163
161
  required_ruby_version: !ruby/object:Gem::Requirement
164
162
  requirements:
165
- - - '>='
163
+ - - ">="
166
164
  - !ruby/object:Gem::Version
167
165
  version: '0'
168
166
  required_rubygems_version: !ruby/object:Gem::Requirement
169
167
  requirements:
170
- - - '>='
168
+ - - ">="
171
169
  - !ruby/object:Gem::Version
172
170
  version: '0'
173
171
  requirements: []
174
172
  rubyforge_project:
175
- rubygems_version: 2.4.7
173
+ rubygems_version: 2.4.3
176
174
  signing_key:
177
175
  specification_version: 4
178
176
  summary: Application Concurrence Test in Ruby.
@@ -1,12 +0,0 @@
1
- card1:
2
- BDUSS: "VEU1hqU3Z5dFZHcm9HSjJRSVhwWFp4QXVRRFRuaEtXM1JEU0NjNEl0Y1kzenRYQUFBQUFBJCQAAAAAAAAAAAEAAAD-BrRddGVzdHdsMjAxNAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABhSFFcYUhRXc0"
3
- STOKEN: "1b54ebe1214d9a3d8eb4613888466a03f54bdd9ffce389416d360761d5b39b0d"
4
- card2:
5
- BDUSS:
6
- STOKEN:
7
- card3:
8
- BDUSS:
9
- STOKEN:
10
- card4:
11
- BDUSS:
12
- STOKEN:
@@ -1,25 +0,0 @@
1
- module Actir
2
- class CookiesFile
3
- class << self
4
-
5
- # 获取cookies文件的路径
6
- # 因为涉及到权限问题,路径需要放在个人账号目录下
7
- # 通过whoami命令获取当前账户名称
8
- # 暂时存放在/User/xx/目录下
9
- def path
10
- user_name = `whoami`
11
- return "/Users/" + user_name + "/"
12
- end
13
-
14
- def name
15
- return "cookies.yaml"
16
- end
17
-
18
- def exists?
19
- File::exists?(path + name)
20
- end
21
-
22
- end
23
-
24
- end
25
- end