bucky-core 0.9.7 → 0.9.8

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: 75c6b90d28c08c2ee93798f1d8ee09eaf3bafb2d
4
- data.tar.gz: e2845d4e3bb5d7bc75aeee7eeb70d49000bcd0ff
3
+ metadata.gz: b95714bd12694e6553a7508e5ce8424c65016a3c
4
+ data.tar.gz: 122c0438f73abb49378de85057b76bb484cb5dfe
5
5
  SHA512:
6
- metadata.gz: 2ee036a2a7adf6fe1726538473cea08430d6ef3235eee2728c3cdd1ae966d38f49bb7c89cac8ba500710cf47d413f6921807c6ea3879f9c439602544e27d2b92
7
- data.tar.gz: 94b0df01aa34d8f9c546d8b7e473b8fc009bd624b9dc75b8bed72511010729f537a34cbd26661a2f859b0c5a66fafbaad151f97ac0b48da8c373f9b7df2e7443
6
+ metadata.gz: 466c39aa4ab15ad570b47f2f3dd453b9e5119517c0ea15d6e84b9a7e948a7aa697659812224cf55b7527e6e85b41381720842f2b8718b0c052bfc75712b202e4
7
+ data.tar.gz: 4535e3f1e50b7ad9b74612872b3bba0a6d8cbea650fbaa018b8f4baebcaac8757a5c31ef0827121e48c0e47d82bfccf2b47e0b510978aacb3ae1bde3224abbc9
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bucky-core (0.9.5)
4
+ bucky-core (0.9.7)
5
5
  color_echo (~> 3.1)
6
6
  json (~> 2.1)
7
7
  nokogiri (~> 1.8)
@@ -1,4 +1,3 @@
1
- :parallel_num: 4
2
1
  :test_result_path: './system/test_results/'
3
2
  :log_path: './system/logs/'
4
3
  :screen_shot_path: './system/evidences/screen_shots/'
@@ -2,6 +2,7 @@
2
2
  :selenium_port: '4444' # Default selenium port
3
3
  :browser: :chrome # Only chrome
4
4
  :headless: false
5
+ :e2e_parallel_num: 1
5
6
  :sp_device_name: :iphone
6
7
  :tablet_device_name: :ipad
7
8
  :device_name_on_chrome:
@@ -1,3 +1,4 @@
1
- :linkstatus_parallel_num: 8
1
+ :linkstatus_parallel_num: 1
2
+ :linkstatus_thread_num: 4
2
3
  :linkstatus_open_timeout: 60
3
4
  :linkstatus_read_timeout: 60
@@ -1,4 +1,3 @@
1
- :parallel_num: 4
2
1
  :test_result_path: './system/test_results/'
3
2
  :log_path: './system/logs/'
4
3
  :screen_shot_path: './system/evidences/screen_shots/'
@@ -2,6 +2,7 @@
2
2
  :selenium_port: '4444' # default selenium port
3
3
  :browser: :chrome # Only chrome
4
4
  :headless: false
5
+ :e2e_parallel_num: 1
5
6
  :sp_device_name: :iphone
6
7
  :tablet_device_name: :ipad
7
8
  :device_name_on_chrome:
@@ -1,3 +1,4 @@
1
- :linkstatus_parallel_num: 8
1
+ :linkstatus_parallel_num: 1
2
+ :linkstatus_thread_num: 4
2
3
  :linkstatus_open_timeout: 60
3
4
  :linkstatus_read_timeout: 60
@@ -45,7 +45,7 @@ module Bucky
45
45
  end
46
46
 
47
47
  # Genrate test class by test suite and test case data
48
- def generate_test_class(data, link_status_url_log)
48
+ def generate_test_class(data, link_status_url_log = {})
49
49
  test_cond = @test_cond
50
50
  # Common proccessing
51
51
  # e.g.) TestSampleAppPcE2e1, TestSampleAppPcHttpstatus1
@@ -8,7 +8,50 @@ require_relative './test_class_generator'
8
8
  module Bucky
9
9
  module Core
10
10
  module TestCore
11
+ module ParallelHelper
12
+ parent_pid = Process.pid
13
+
14
+ # Terminate parent and child process when getting interrupt signal
15
+ Signal.trap('INT') do
16
+ Process.kill('TERM', -1 * parent_pid)
17
+ end
18
+
19
+ private
20
+
21
+ def parallel_new_worker_each(data_set, max_processes, &block)
22
+ # Max parallel workers number
23
+ available_workers = max_processes
24
+
25
+ # If child process dead, available workers increase
26
+ Signal.trap('CLD') { available_workers += 1 }
27
+
28
+ data_set.each do |data|
29
+ # Wait until worker is available
30
+ Process.wait unless available_workers.positive?
31
+ # Workers decrease when start working
32
+ available_workers -= 1
33
+ fork { block.call(data) }
34
+ end
35
+ Process.waitall
36
+ end
37
+
38
+ def parallel_distribute_into_workers(data_set, max_processes, &block)
39
+ # Group the data by remainder of index
40
+ data_set_grouped = data_set.group_by.with_index { |_elem, index| index % max_processes }
41
+ # Use 'values' method to get only hash's key into an array
42
+ data_set_grouped.values.each do |data_for_pre_worker|
43
+ # Number of child process is equal to max_processes (or equal to data_set length when data_set length is less than max_processes)
44
+ fork do
45
+ data_for_pre_worker.each { |data| block.call(data) }
46
+ end
47
+ end
48
+ Process.waitall
49
+ end
50
+ end
51
+
11
52
  class TestManager
53
+ include ParallelHelper
54
+
12
55
  # Keep test conditions and round number
13
56
  def initialize(test_cond)
14
57
  @test_cond = test_cond
@@ -45,8 +88,17 @@ module Bucky
45
88
 
46
89
  # Generate and execute test
47
90
  def do_test_suites(test_suite_data)
48
- parallel_num = Bucky::Utils::Config.instance[:parallel_num]
49
- parallel_helper(test_suite_data, parallel_num)
91
+ # For checking on linkstatus
92
+ e2e_parallel_num = Bucky::Utils::Config.instance[:e2e_parallel_num]
93
+ linkstatus_parallel_num = Bucky::Utils::Config.instance[:linkstatus_parallel_num]
94
+ tcg = Bucky::Core::TestCore::TestClassGenerator.new(@test_cond)
95
+
96
+ case @test_cond[:test_category][0]
97
+ when 'e2e' then parallel_new_worker_each(test_suite_data, e2e_parallel_num) { |data| tcg.generate_test_class(data) }
98
+ when 'linkstatus' then
99
+ link_status_url_log = {}
100
+ parallel_distribute_into_workers(test_suite_data, linkstatus_parallel_num) { |data| tcg.generate_test_class(data, link_status_url_log) }
101
+ end
50
102
  end
51
103
 
52
104
  def execute_test
@@ -60,31 +112,6 @@ module Bucky
60
112
  break if @test_cond[:re_test_cond].empty?
61
113
  end
62
114
  end
63
-
64
- def parallel_helper(test_suite_data, max_processes)
65
- # Max parallel workers number
66
- available_workers = max_processes
67
- # For checking on linkstatus
68
- link_status_url_log = {}
69
- parent_pid = Process.pid
70
- tcg = Bucky::Core::TestCore::TestClassGenerator.new(@test_cond)
71
-
72
- # If child process dead, available workers increase
73
- Signal.trap('CLD') { available_workers += 1 }
74
- # Terminate parent and child process when getting interrupt signal
75
- Signal.trap('INT') do
76
- Process.kill('TERM', -1 * parent_pid)
77
- end
78
-
79
- test_suite_data.each do |data|
80
- # Wait until worker is available
81
- Process.wait unless available_workers.positive?
82
- # Workers decrease when start working
83
- available_workers -= 1
84
- fork { tcg.generate_test_class(data, link_status_url_log) }
85
- end
86
- Process.waitall
87
- end
88
115
  end
89
116
  end
90
117
  end
@@ -90,7 +90,7 @@ module Bucky
90
90
  links = exclude(links, exclude_urls) unless exclude_urls.nil?
91
91
 
92
92
  errors = []
93
- Parallel.each(links.uniq, in_threads: Bucky::Utils::Config.instance[:linkstatus_parallel_num]) do |link|
93
+ Parallel.each(links.uniq, in_threads: Bucky::Utils::Config.instance[:linkstatus_thread_num]) do |link|
94
94
  http_status_check_args[:url] = link
95
95
  http_status_check_args[:redirect_url_list] = []
96
96
  link_response = http_status_check(http_status_check_args)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Bucky
4
4
  module Version
5
- VERSION = '0.9.7'
5
+ VERSION = '0.9.8'
6
6
  end
7
7
  end
@@ -1,4 +1,3 @@
1
- :parallel_num: 4
2
1
  :test_result_path: './system/test_results/'
3
2
  :log_path: './system/logs/'
4
3
  :screen_shot_path: './system/evidences/screen_shots/'
@@ -2,6 +2,7 @@
2
2
  :selenium_port: '4444' # Default selenium port
3
3
  :browser: :chrome # Only chrome
4
4
  :headless: false
5
+ :e2e_parallel_num: 1
5
6
  :sp_device_name: :iphone
6
7
  :tablet_device_name: :ipad
7
8
  :device_name_on_chrome:
@@ -1,3 +1,4 @@
1
- :linkstatus_parallel_num: 8
1
+ :linkstatus_parallel_num: 1
2
+ :linkstatus_thread_num: 4
2
3
  :linkstatus_open_timeout: 60
3
4
  :linkstatus_read_timeout: 60
@@ -1,4 +1,3 @@
1
- :parallel_num: 4
2
1
  :test_result_path: './system/test_results/'
3
2
  :log_path: './system/logs/'
4
3
  :screen_shot_path: './system/evidences/screen_shots/'
@@ -2,6 +2,7 @@
2
2
  :selenium_port: '4444' # Default selenium port
3
3
  :browser: :chrome # Only chrome
4
4
  :headless: false
5
+ :e2e_parallel_num: 1
5
6
  :sp_device_name: :iphone
6
7
  :tablet_device_name: :ipad
7
8
  :device_name_on_chrome:
@@ -1,3 +1,4 @@
1
- :linkstatus_parallel_num: 8
1
+ :linkstatus_parallel_num: 1
2
+ :linkstatus_thread_num: 4
2
3
  :linkstatus_open_timeout: 60
3
4
  :linkstatus_read_timeout: 60
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.9.7
4
+ version: 0.9.8
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: 2019-06-14 00:00:00.000000000 Z
16
+ date: 2019-06-25 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: awesome_print