bucky-core 0.10.17 → 0.10.20
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +1 -1
- data/README.md +2 -0
- data/exe/bucky +15 -22
- data/lib/bucky/core/test_core/test_case_loader.rb +1 -2
- data/lib/bucky/core/test_core/test_class_generator.rb +4 -3
- data/lib/bucky/core/test_core/test_manager.rb +62 -8
- data/lib/bucky/test_equipment/test_case/abst_test_case.rb +7 -0
- data/lib/bucky/test_equipment/verifications/status_checker.rb +1 -1
- data/lib/bucky/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: a8eba9ce6bd69f4ed90867a049e82f324128c64b53df120afbebf486142c457f
|
4
|
+
data.tar.gz: e32d0ec926283e7ea08ef362abec3835e4a1ad5f66e85300125ce32bb0341ff5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c02632d7578c12965152be6b08d94cbe7b7ef81b7cfcb95d17edd340988722cbb907fb79ca9c01c35954c7e56da00edb0bb59128e0bddb0afc6ceacacb80a4fc
|
7
|
+
data.tar.gz: 5b86f9033fe8144f8358e5cdf5f561c3f79e1d590492b0237700fe7e688205838baf8b4eb9b121c056d38428cd8c4a1012cb9537ebf8de14b5ba326a9d5d609d
|
data/.circleci/config.yml
CHANGED
@@ -27,7 +27,7 @@ jobs:
|
|
27
27
|
command: docker load -q -i ~/caches/images.tar
|
28
28
|
- run:
|
29
29
|
name: docker up
|
30
|
-
command: docker-compose -f docker-compose.system-test.yml up
|
30
|
+
command: docker-compose -f docker-compose.system-test.yml up -d
|
31
31
|
- run:
|
32
32
|
name: execute system testing
|
33
33
|
command: 'circleci tests glob system_testing/testing_code/*.bats | xargs -n 1 -I {} docker exec bucky-core bats "/bucky-core/"{} | circleci tests split'
|
data/README.md
CHANGED
@@ -98,6 +98,7 @@ ENV_FOO=foo bucky run -t e2e -d
|
|
98
98
|
-r, --re_test_count RE_TEST_COUNT # How many round you run tests
|
99
99
|
-l, --label LABEL_NAME
|
100
100
|
-m, --link_check_max_times MAX_TIMES # Works only with which category is linkstatus
|
101
|
+
-o, --out JSON_OUTPUT_FILE_PATH # Output summary report by json
|
101
102
|
```
|
102
103
|
|
103
104
|
### Rerun test
|
@@ -212,6 +213,7 @@ test_category: linkstatus
|
|
212
213
|
exclude_urls:
|
213
214
|
- https://example.com/fuga/?hoge=1 # PERFECT MATCHING
|
214
215
|
- https://example.com/fuga/* # PARTIAL MATCHING
|
216
|
+
- /https://example.com/.*\.html/ # REGULAR EXPRESSION MATCHING
|
215
217
|
cases:
|
216
218
|
- case_name: test_code_1 # Suite filename + number
|
217
219
|
desc: status check for top page
|
data/exe/bucky
CHANGED
@@ -89,7 +89,9 @@ end
|
|
89
89
|
opts.on('-m', '--link_check_max_times') do |v|
|
90
90
|
test_cond[:link_check_max_times] = v.to_i
|
91
91
|
end
|
92
|
-
|
92
|
+
opts.on('-o', '--out JSON_OUTPUT_FILE_PATH') do |v|
|
93
|
+
test_cond[:out] = v
|
94
|
+
end
|
93
95
|
lint_cond = {}
|
94
96
|
opts.on('-C', '--category CATEGORY_NAME') do |v|
|
95
97
|
lint_cond[:lint_category] = v
|
@@ -124,42 +126,33 @@ def bucky_home?
|
|
124
126
|
File.exist?('.bucky_home')
|
125
127
|
end
|
126
128
|
|
127
|
-
|
128
|
-
gem_script_dir = __dir__
|
129
|
-
|
130
|
-
if ARGV == RUN_COMMAND
|
131
|
-
error_and_exit('Not bucky project dirctory here.') unless bucky_home?
|
132
|
-
|
133
|
-
$bucky_home_dir = Dir.pwd
|
129
|
+
def setup_test_cond(test_cond)
|
134
130
|
# Default conditions setting conditions setting
|
135
131
|
test_cond[:test_category] ||= 'e2e'
|
136
132
|
test_cond[:re_test_count] = test_cond[:re_test_count] ? test_cond[:re_test_count].to_i : 1
|
137
133
|
test_cond[:link_check_max_times] ||= 3
|
138
134
|
# Change to array e.g.--suite_id 1,2,3 -> :suite_id=>[1,2,3]
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
135
|
+
%i[suite_name case label xlabel device].each do |k|
|
136
|
+
test_cond[k] = test_cond[k].split(',') unless test_cond[k].nil?
|
137
|
+
end
|
138
|
+
test_cond
|
139
|
+
end
|
143
140
|
|
144
|
-
|
141
|
+
current_dir = Dir.pwd
|
142
|
+
gem_script_dir = __dir__
|
143
|
+
|
144
|
+
if ARGV[0].end_with? 'run'
|
145
|
+
error_and_exit('Not bucky project dirctory here.') unless bucky_home?
|
145
146
|
$bucky_home_dir = Dir.pwd
|
146
|
-
# Default conditions setting conditions setting
|
147
|
-
test_cond[:test_category] ||= 'e2e'
|
148
|
-
test_cond[:link_check_max_times] ||= 3
|
149
|
-
test_cond[:re_test_count] = test_cond[:re_test_count] ? test_cond[:re_test_count].to_i : 1
|
150
|
-
# Change to array e.g.--suite_id 1,2,3 -> :suite_id=>[1,2,3]
|
151
|
-
test_cond.each { |k, v| test_cond[k] = v.split(',') if v.instance_of?(String) }
|
152
147
|
require_relative '../lib/bucky/core/test_core/test_manager'
|
153
|
-
Bucky::Core::TestCore::TestManager.new(test_cond).
|
148
|
+
Bucky::Core::TestCore::TestManager.new(setup_test_cond(test_cond)).send(ARGV[0])
|
154
149
|
Bucky::Core::TestCore::ExitHandler.instance.bucky_exit
|
155
|
-
|
156
150
|
elsif ARGV == LINT_COMMAND
|
157
151
|
$bucky_home_dir = Dir.pwd
|
158
152
|
# Default conditions setting
|
159
153
|
lint_cond[:lint_category] ||= 'config'
|
160
154
|
require_relative '../lib/bucky/tools/lint'
|
161
155
|
Bucky::Tools::Lint.check(lint_cond[:lint_category])
|
162
|
-
|
163
156
|
elsif ARGV[0..0] == NEW_COMMAND
|
164
157
|
error_and_exit('No test app name.') if ARGV.length < 2
|
165
158
|
|
@@ -34,9 +34,8 @@ module Bucky
|
|
34
34
|
testcodes = []
|
35
35
|
service = (test_cond[:service] || ['*']).first
|
36
36
|
device = (test_cond[:device] || ['*']).first
|
37
|
-
category = (test_cond[:test_category] || ['*']).first
|
38
37
|
|
39
|
-
Dir.glob("#{$bucky_home_dir}/services/#{service}/#{device}/scenarios/#{
|
38
|
+
Dir.glob("#{$bucky_home_dir}/services/#{service}/#{device}/scenarios/#{test_cond[:test_category]}/*.yml").each do |testcode_file|
|
40
39
|
testcodes << load_testcode_in_file(testcode_file, test_cond)
|
41
40
|
end
|
42
41
|
# Delete nil element
|
@@ -46,7 +46,7 @@ module Bucky
|
|
46
46
|
end
|
47
47
|
|
48
48
|
# Genrate test class by test suite and test case data
|
49
|
-
def generate_test_class(data,
|
49
|
+
def generate_test_class(data: [], linkstatus_url_log: {}, w_pipe: {})
|
50
50
|
test_cond = @test_cond
|
51
51
|
# Common proccessing
|
52
52
|
# e.g.) TestSampleAppPcE2e1, TestSampleAppPcHttpstatus1
|
@@ -63,6 +63,7 @@ module Bucky
|
|
63
63
|
match_obj = /\Atest_(.+)\(.+::(Test.+)\)\z/.match(original_name)
|
64
64
|
"#{match_obj[1]}(#{match_obj[2]})"
|
65
65
|
end
|
66
|
+
define_method(:w_pipe, proc { w_pipe })
|
66
67
|
|
67
68
|
# Class structure is different for each test category
|
68
69
|
case data[:test_category]
|
@@ -74,8 +75,8 @@ module Bucky
|
|
74
75
|
define_method(method_name) do
|
75
76
|
puts "\n#{simple_test_class_name(name)}"
|
76
77
|
t_case[:urls].each do |url|
|
77
|
-
|
78
|
-
|
78
|
+
linkstatus_check_args = { url: url, device: data[:suite][:device], exclude_urls: data[:suite][:exclude_urls], link_check_max_times: test_cond[:link_check_max_times], url_log: linkstatus_url_log }
|
79
|
+
linkstatus_check(linkstatus_check_args)
|
79
80
|
end
|
80
81
|
end
|
81
82
|
)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'json'
|
4
4
|
require_relative '../test_core/test_case_loader'
|
5
5
|
require_relative '../../utils/config'
|
6
6
|
require_relative './test_class_generator'
|
@@ -26,6 +26,8 @@ module Bucky
|
|
26
26
|
# If child process dead, available workers increase
|
27
27
|
Signal.trap('CLD') { available_workers += 1 }
|
28
28
|
|
29
|
+
r_pipe, w_pipe = IO.pipe
|
30
|
+
|
29
31
|
data_set.each do |data|
|
30
32
|
# Wait until worker is available and handle exit code from previous process
|
31
33
|
unless available_workers.positive?
|
@@ -34,28 +36,51 @@ module Bucky
|
|
34
36
|
end
|
35
37
|
# Workers decrease when start working
|
36
38
|
available_workers -= 1
|
37
|
-
fork { block.call(data) }
|
39
|
+
fork { block.call(data, w_pipe) }
|
38
40
|
end
|
39
41
|
# Handle all exit code in waitall
|
40
42
|
Process.waitall.each do |child|
|
41
43
|
Bucky::Core::TestCore::ExitHandler.instance.raise unless child[1].exitstatus.zero?
|
42
44
|
end
|
45
|
+
|
46
|
+
w_pipe.close
|
47
|
+
results_set = collect_results_set(r_pipe)
|
48
|
+
r_pipe.close
|
49
|
+
|
50
|
+
results_set
|
43
51
|
end
|
44
52
|
|
45
53
|
def parallel_distribute_into_workers(data_set, max_processes, &block)
|
46
54
|
# Group the data by remainder of index
|
47
55
|
data_set_grouped = data_set.group_by.with_index { |_elem, index| index % max_processes }
|
56
|
+
r_pipe, w_pipe = IO.pipe
|
48
57
|
# Use 'values' method to get only hash's key into an array
|
49
58
|
data_set_grouped.values.each do |data_for_pre_worker|
|
50
59
|
# Number of child process is equal to max_processes (or equal to data_set length when data_set length is less than max_processes)
|
51
60
|
fork do
|
52
|
-
data_for_pre_worker.each { |data| block.call(data) }
|
61
|
+
data_for_pre_worker.each { |data| block.call(data, w_pipe) }
|
53
62
|
end
|
54
63
|
end
|
55
64
|
# Handle all exit code in waitall
|
56
65
|
Process.waitall.each do |child|
|
57
66
|
Bucky::Core::TestCore::ExitHandler.instance.raise unless child[1].exitstatus.zero?
|
58
67
|
end
|
68
|
+
|
69
|
+
w_pipe.close
|
70
|
+
results_set = collect_results_set(r_pipe)
|
71
|
+
r_pipe.close
|
72
|
+
|
73
|
+
results_set
|
74
|
+
end
|
75
|
+
|
76
|
+
def collect_results_set(r_pipe)
|
77
|
+
results_set = {}
|
78
|
+
r_pipe.each_line do |line|
|
79
|
+
r = JSON.parse(line)
|
80
|
+
results_set[r['test_class_name']] = r
|
81
|
+
end
|
82
|
+
|
83
|
+
results_set
|
59
84
|
end
|
60
85
|
end
|
61
86
|
|
@@ -69,6 +94,20 @@ module Bucky
|
|
69
94
|
@tdo = Bucky::Core::Database::TestDataOperator.new
|
70
95
|
@start_time = Time.now
|
71
96
|
$job_id = @tdo.save_job_record_and_get_job_id(@start_time, @test_cond[:command_and_option])
|
97
|
+
@json_report = {
|
98
|
+
summary: {
|
99
|
+
cases_count: 0,
|
100
|
+
success_count: 0,
|
101
|
+
failure_count: 0,
|
102
|
+
job_id: $job_id,
|
103
|
+
test_category: test_cond[:test_category],
|
104
|
+
device: test_cond[:device],
|
105
|
+
labels: test_cond[:label],
|
106
|
+
exclude_labels: test_cond[:xlabel],
|
107
|
+
rerun_job_id: test_cond[:job],
|
108
|
+
round_count: 0
|
109
|
+
}
|
110
|
+
}
|
72
111
|
end
|
73
112
|
|
74
113
|
def run
|
@@ -102,25 +141,40 @@ module Bucky
|
|
102
141
|
e2e_parallel_num = Bucky::Utils::Config.instance[:e2e_parallel_num]
|
103
142
|
linkstatus_parallel_num = Bucky::Utils::Config.instance[:linkstatus_parallel_num]
|
104
143
|
tcg = Bucky::Core::TestCore::TestClassGenerator.new(@test_cond)
|
105
|
-
case @test_cond[:test_category]
|
106
|
-
when 'e2e' then parallel_new_worker_each(test_suite_data, e2e_parallel_num) { |data| tcg.generate_test_class(data) }
|
144
|
+
case @test_cond[:test_category]
|
145
|
+
when 'e2e' then results_set = parallel_new_worker_each(test_suite_data, e2e_parallel_num) { |data, w_pipe| tcg.generate_test_class(data: data, w_pipe: w_pipe) }
|
107
146
|
when 'linkstatus' then
|
108
|
-
|
109
|
-
parallel_distribute_into_workers(test_suite_data, linkstatus_parallel_num) { |data| tcg.generate_test_class(data,
|
147
|
+
linkstatus_url_log = {}
|
148
|
+
results_set = parallel_distribute_into_workers(test_suite_data, linkstatus_parallel_num) { |data, w_pipe| tcg.generate_test_class(data: data, linkstatus_url_log: linkstatus_url_log, w_pipe: w_pipe) }
|
110
149
|
end
|
150
|
+
|
151
|
+
results_set
|
111
152
|
end
|
112
153
|
|
113
154
|
def execute_test
|
155
|
+
all_round_results = []
|
114
156
|
@re_test_count.times do |i|
|
115
157
|
Bucky::Core::TestCore::ExitHandler.instance.reset
|
116
158
|
$round = i + 1
|
159
|
+
@json_report[:summary][:round_count] = $round
|
117
160
|
test_suite_data = load_test_suites
|
118
|
-
do_test_suites(test_suite_data)
|
161
|
+
all_round_results.append(do_test_suites(test_suite_data))
|
119
162
|
@test_cond[:re_test_cond] = @tdo.get_ng_test_cases_at_last_execution(
|
120
163
|
is_error: 1, job_id: $job_id, round: $round
|
121
164
|
)
|
122
165
|
break if @test_cond[:re_test_cond].empty?
|
123
166
|
end
|
167
|
+
|
168
|
+
return unless @test_cond[:out]
|
169
|
+
|
170
|
+
@json_report[:summary][:cases_count] = all_round_results[0].sum { |_case, res| res[:case_count] }
|
171
|
+
@json_report[:summary][:failure_count] = all_round_results[-1].sum { |_case, res| res[:failure_count] }
|
172
|
+
@json_report[:summary][:success_count] = @json_report[:summary][:cases_count] - @json_report[:summary][:failure_count]
|
173
|
+
|
174
|
+
File.open(@test_cond[:out], 'w') do |f|
|
175
|
+
f.puts(@json_report.to_json)
|
176
|
+
puts "\nSave report : #{@test_cond[:out]}\n"
|
177
|
+
end
|
124
178
|
end
|
125
179
|
end
|
126
180
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'test/unit'
|
4
|
+
require 'json'
|
4
5
|
require_relative '../../core/test_core/test_result'
|
5
6
|
|
6
7
|
module Bucky
|
@@ -25,6 +26,12 @@ module Bucky
|
|
25
26
|
def run(result)
|
26
27
|
super
|
27
28
|
@@this_result.result = result unless $debug
|
29
|
+
w_pipe.puts({
|
30
|
+
test_class_name: self.class.name,
|
31
|
+
cases_count: result.run_count,
|
32
|
+
success_count: result.pass_count,
|
33
|
+
failure_count: result.run_count - result.pass_count
|
34
|
+
}.to_json)
|
28
35
|
end
|
29
36
|
|
30
37
|
def setup
|
data/lib/bucky/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bucky-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
4
|
+
version: 0.10.20
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- NaotoKishino
|
@@ -13,7 +13,7 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: exe
|
15
15
|
cert_chain: []
|
16
|
-
date: 2022-
|
16
|
+
date: 2022-06-12 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: awesome_print
|