tes-request 0.11 → 0.12
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 +4 -4
- data/lib/tes/request/rspec/distribute.rb +25 -25
- data/lib/tes/request/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9d21fe3a21348ae9f66ebb0df7ed5c2abb0ee2fd4557fb1d94d466dccdcacd01
|
4
|
+
data.tar.gz: f62fc78836dfcff2a9c396d8b0ff01b6faffd4db30b336539b6fb6235b7fa625
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3cfd26da444df310cc3c944a8532506e994feab473b4af862ce22b35661afdb1f7c770363bb2100fc03e5443354c76298579a49d288120d8ce3d572bc381d475
|
7
|
+
data.tar.gz: 0195a973dcb123132510993c85a48b6dbff6d8528d60c661337e216ba29810188edc882fee80544d259b07f7d72c88cf3710f97c185aa194fd9b4214dda1f142
|
@@ -16,7 +16,7 @@ module Tes
|
|
16
16
|
|
17
17
|
# @param [String] project_dir 测试项目的根目录路径
|
18
18
|
# @param [String] ci_yaml_file 测试项目内的描述spec测试的配置文件路径(相对`project_dir`)
|
19
|
-
def initialize(project_dir, ci_yaml_file
|
19
|
+
def initialize(project_dir, ci_yaml_file = @@ci_yaml_file)
|
20
20
|
@project_dir = project_dir
|
21
21
|
@ci_cfg = YAML.load_file(File.join(@project_dir, ci_yaml_file))
|
22
22
|
end
|
@@ -29,7 +29,7 @@ module Tes
|
|
29
29
|
# @param [Hash] res_addition_attr_map 资源属性需要调整的映射表
|
30
30
|
# @param [Hash,nil] adapt_pool
|
31
31
|
# @return [Array<Hash>]
|
32
|
-
def distribute_jobs(type, count, res_addition_attr_map={}, adapt_pool = {})
|
32
|
+
def distribute_jobs(type, count, res_addition_attr_map = {}, adapt_pool = {})
|
33
33
|
task_cfg = get_rspec_task(type)
|
34
34
|
spec_paths = spec_files(type)
|
35
35
|
rspec_parser = Tes::Request::RSpec::ProfileParser.new(spec_paths)
|
@@ -83,16 +83,16 @@ module Tes
|
|
83
83
|
end
|
84
84
|
|
85
85
|
private
|
86
|
+
|
86
87
|
# 生产任务碎片,尽量接近传递的参数值
|
87
88
|
# @param [Fixnum] minimum_pieces
|
88
89
|
# @return [Array]
|
89
90
|
def gen_pieces(profiles, minimum_pieces)
|
90
91
|
common_jobs = []
|
91
92
|
standalone_jobs = []
|
92
|
-
|
93
93
|
min_spec_count = profiles.size / minimum_pieces
|
94
94
|
|
95
|
-
profiles.each do |to_merge_spec|
|
95
|
+
profiles.sort_by {rand}.each do |to_merge_spec|
|
96
96
|
# 0. 任务发布要求的特殊处理
|
97
97
|
if to_merge_spec[:distribute] && to_merge_spec[:distribute][:standalone]
|
98
98
|
standalone_jobs << {profile: to_merge_spec[:profile], specs: [to_merge_spec]}
|
@@ -100,31 +100,31 @@ module Tes
|
|
100
100
|
end
|
101
101
|
|
102
102
|
# 1. 优先相同要求的归并
|
103
|
-
join_piece = common_jobs.
|
103
|
+
join_piece = common_jobs.select do |piece|
|
104
104
|
piece[:specs].size <= min_spec_count and
|
105
105
|
piece[:profile] == to_merge_spec[:profile]
|
106
|
-
end
|
106
|
+
end.sample
|
107
107
|
if join_piece
|
108
108
|
join_piece[:specs] << to_merge_spec
|
109
109
|
else
|
110
110
|
# 2. 然后再是资源多少不同的归并
|
111
|
-
super_piece = common_jobs.
|
111
|
+
super_piece = common_jobs.select do |piece|
|
112
112
|
if piece[:specs].size <= min_spec_count
|
113
113
|
cr = piece[:profile] <=> to_merge_spec[:profile]
|
114
114
|
cr && cr >= 0
|
115
115
|
else
|
116
116
|
false
|
117
117
|
end
|
118
|
-
end
|
118
|
+
end.sample
|
119
119
|
if super_piece
|
120
120
|
super_piece[:specs] << to_merge_spec
|
121
121
|
else
|
122
122
|
# 3. 可整合计算的的归并,但要求已经达到的任务分片数已经达到了要求那么大,否则直接以新建来搞
|
123
123
|
if common_jobs.size >= minimum_pieces
|
124
|
-
merge_piece = common_jobs.
|
124
|
+
merge_piece = common_jobs.select do |piece|
|
125
125
|
piece[:specs].size <= min_spec_count and
|
126
126
|
piece[:profile].merge_able?(to_merge_spec[:profile])
|
127
|
-
end
|
127
|
+
end.sample
|
128
128
|
if merge_piece
|
129
129
|
merge_piece[:profile] = merge_piece[:profile] + to_merge_spec[:profile]
|
130
130
|
merge_piece[:specs] << to_merge_spec
|
@@ -164,7 +164,7 @@ module Tes
|
|
164
164
|
end
|
165
165
|
|
166
166
|
# @return [Array<String>]
|
167
|
-
def filter_spec_by_path(pattern, exclude_pattern=nil)
|
167
|
+
def filter_spec_by_path(pattern, exclude_pattern = nil)
|
168
168
|
pattern_filter_lab = ->(p) do
|
169
169
|
spec_info = get_spec_path_info(p)
|
170
170
|
direct_return = (spec_info[:locations] or spec_info[:ids])
|
@@ -172,24 +172,24 @@ module Tes
|
|
172
172
|
end
|
173
173
|
|
174
174
|
ret = case pattern
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
175
|
+
when String
|
176
|
+
pattern_filter_lab.call(pattern)
|
177
|
+
Dir[File.join(@project_dir, pattern)]
|
178
|
+
when Array
|
179
|
+
pattern.inject([]) {|t, ep| t + pattern_filter_lab.call(ep)}
|
180
|
+
else
|
181
|
+
raise('Error pattern type')
|
182
182
|
end
|
183
183
|
|
184
184
|
return ret unless exclude_pattern
|
185
185
|
|
186
186
|
case exclude_pattern
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
187
|
+
when String
|
188
|
+
ret -= Dir[File.join(@project_dir, exclude_pattern)]
|
189
|
+
when Array
|
190
|
+
ret -= exclude_pattern.inject([]) {|t, ep| t + Dir[File.join(@project_dir, ep)]}
|
191
|
+
else
|
192
|
+
raise('Error exclude_pattern type')
|
193
193
|
end
|
194
194
|
|
195
195
|
ret
|
@@ -203,7 +203,7 @@ module Tes
|
|
203
203
|
# 或者
|
204
204
|
# type=res_type,res_attr1=2,res_attr3>=4
|
205
205
|
# @return [Array<String>] 按照`res_exclude_pattern` 剔除后的 `spec_paths`
|
206
|
-
def exclude_spec_by_resource(spec_paths, res_exclude_patterns=[])
|
206
|
+
def exclude_spec_by_resource(spec_paths, res_exclude_patterns = [])
|
207
207
|
return spec_paths if res_exclude_patterns.empty?
|
208
208
|
|
209
209
|
spec_paths.reject do |spec_path|
|
data/lib/tes/request/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tes-request
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.12'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- wuhuizuo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-07-
|
11
|
+
date: 2018-07-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: java-properties
|