mini_autobot 0.0.3 → 0.0.4

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: 304864d910ed49b64b576de654ff04d5173e534b
4
- data.tar.gz: c7b5881befcfedf13e325e0f3581d7066bd4d04b
3
+ metadata.gz: 8cc67ceef5896e0d638609b72025a40233cd24ab
4
+ data.tar.gz: b0f4a4bc84afd272d3b969c93f157cbfe9617496
5
5
  SHA512:
6
- metadata.gz: 1b57d2ea5b02d55fe7e14e886d32f9ea8cdc7541394bd647297365633171fed553c200ecc101aa67cf81cb91d14d3925d1e46c7d013c3e1f5578249ffbaed208
7
- data.tar.gz: f14c61b84e901e72cf1d53cdd3cad30004af1b8ece8d9719efbcf0ecf3f429d081013ac7e902053236517d0fec52bfdd4d987301e743ed5fc9b404aff23a163b
6
+ metadata.gz: 0ae15ae997a355a466464bb92fab425ab82e28e1f4b94b5853873d2bbe69a79207e9075f52d37623e4f660a8bc357cf298229850ec41825fd32e84a449053586
7
+ data.tar.gz: 52cfa030069a7dfa2c7dfc45d36743dbe445965b7f2b90d90638fbb89b87f4f2d1075c7376202bfe8f672fc48cd53ac4a9a77241daf9e5e168e23d830906647e
@@ -23,8 +23,7 @@ module MiniAutobot
23
23
  # return true only if specified to run on mac in connector
24
24
  # @return [boolean]
25
25
  def run_on_mac?
26
- return true if @platform.include?('osx')
27
- return false
26
+ @platform.include?('osx')
28
27
  end
29
28
 
30
29
  # remove all results files under logs/tap_results/
@@ -34,9 +33,8 @@ module MiniAutobot
34
33
  end
35
34
 
36
35
  def count_autobot_process
37
- counting_process = IO.popen "ps -ef | grep '#{@static_run_command}' -c"
38
- count_of_processes = counting_process.readlines[0].to_i
39
- count_of_processes
36
+ counting_process_output = IO.popen "ps -ef | grep 'bin/#{@static_run_command}' -c"
37
+ counting_process_output.readlines[0].to_i - 1 # minus grep process
40
38
  end
41
39
 
42
40
  # run multiple commands with logging to start multiple tests in parallel
@@ -48,7 +46,7 @@ module MiniAutobot
48
46
  if run_on_mac?
49
47
  @simultaneous_jobs = 10 # saucelabs account limit for parallel is 10 for mac
50
48
  else
51
- @simultaneous_jobs = 15 # saucelabs account limit for parallel is 15 for non-mac
49
+ @simultaneous_jobs = 20 # saucelabs account limit for parallel is 15 for non-mac
52
50
  end
53
51
  end
54
52
 
@@ -65,62 +63,55 @@ module MiniAutobot
65
63
  keep_running_full(all_to_run)
66
64
  end
67
65
 
68
- wait_all_done_saucelabs if @on_sauce
69
- wait_for_pids(@pids) unless ENV['JENKINS_HOME']
66
+ Process.waitall
70
67
  puts "\nAll Complete! Started at #{@start_time} and finished at #{Time.now}\n"
71
68
  exit
72
69
  end
73
70
 
74
- def wait_for_pids(pids)
75
- running_pids = pids # assume all pids are running at this moment
76
- while running_pids.size > 1
77
- sleep 5
78
- puts "running_pids = #{running_pids}"
79
- running_pids.each do |pid|
80
- unless process_running?(pid)
81
- puts "#{pid} is not running, removing it from pool"
82
- running_pids.delete(pid)
83
- end
84
- end
85
- end
86
- end
87
-
88
- def process_running?(pid)
89
- begin
90
- Process.getpgid(pid)
91
- true
92
- rescue Errno::ESRCH
93
- false
94
- end
95
- end
96
-
97
71
  # runs each test from a test set in a separate child process
98
72
  def run_test_set(test_set)
99
73
  test_set.each do |test|
100
74
  run_command = "#{@static_run_command} -n #{test} #{@pipe_tap} > logs/tap_results/#{test}.t"
101
75
  pipe = IO.popen(run_command)
102
76
  puts "Running #{test} #{pipe.pid}"
103
- @pids << pipe.pid
104
77
  end
105
78
  end
106
79
 
80
+ # recursively keep running #{simultaneous_jobs} number of tests in parallel
81
+ # exit when no test left to run
107
82
  def keep_running_full(all_to_run)
108
- full_count = simultaneous_jobs + 2
109
- running_count = count_autobot_process
110
- while running_count >= full_count
83
+ running_subprocess_count = count_autobot_process - 1 # minus parent process
84
+ puts "WARNING: running_subprocess_count = #{running_subprocess_count}
85
+ is more than what it is supposed to run(#{simultaneous_jobs}),
86
+ notify mini_autobot maintainers" if running_subprocess_count > simultaneous_jobs + 1
87
+ while running_subprocess_count >= simultaneous_jobs
111
88
  sleep 5
112
- running_count = count_autobot_process
89
+ running_subprocess_count = count_autobot_process - 1
113
90
  end
114
- to_run_count = full_count - running_count
91
+ to_run_count = simultaneous_jobs - running_subprocess_count
115
92
  tests_to_run = all_to_run.slice!(0, to_run_count)
93
+
116
94
  run_test_set(tests_to_run)
117
- if all_to_run.size > 0
118
- keep_running_full(all_to_run)
119
- else
120
- return
95
+
96
+ keep_running_full(all_to_run) if all_to_run.size > 0
97
+ end
98
+
99
+ # @deprecated Use more native wait/check of Process
100
+ def wait_for_pids(pids)
101
+ running_pids = pids # assume all pids are running at this moment
102
+ while running_pids.size > 1
103
+ sleep 5
104
+ puts "running_pids = #{running_pids}"
105
+ running_pids.each do |pid|
106
+ unless process_running?(pid)
107
+ puts "#{pid} is not running, removing it from pool"
108
+ running_pids.delete(pid)
109
+ end
110
+ end
121
111
  end
122
112
  end
123
113
 
114
+ # @deprecated Too time consuming and fragile, should use more native wait/check of Process
124
115
  def wait_all_done_saucelabs
125
116
  size = all_tests.size
126
117
  job_statuses = saucelabs_last_n_statuses(size)
@@ -131,6 +122,8 @@ module MiniAutobot
131
122
  end
132
123
  end
133
124
 
125
+ private
126
+
134
127
  # call saucelabs REST API to get last #{limit} jobs' statuses
135
128
  # possible job status: complete, error, in progress
136
129
  def saucelabs_last_n_statuses(limit)
@@ -193,5 +186,14 @@ module MiniAutobot
193
186
  end
194
187
  end
195
188
 
189
+ def process_running?(pid)
190
+ begin
191
+ Process.getpgid(pid)
192
+ true
193
+ rescue Errno::ESRCH
194
+ false
195
+ end
196
+ end
197
+
196
198
  end
197
199
  end
@@ -1,3 +1,3 @@
1
1
  module MiniAutobot
2
- VERSION = '0.0.3'
2
+ VERSION = '0.0.4'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mini_autobot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ripta Pasay
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-08-18 00:00:00.000000000 Z
13
+ date: 2015-08-20 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport