ci-queue 0.15.1 → 0.16.0

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
  SHA256:
3
- metadata.gz: be97720fd013ba146232d7ed706bbfde45525263e84ecb99e780b74e526b8c77
4
- data.tar.gz: 6868d32c98c70fbbeb3583ec4f613b117288370c91e900766fd7e3e1b9aa6426
3
+ metadata.gz: bce03b836af2ca47628929525648bed8d667a434b3d09228d33e0429cbb6a3a4
4
+ data.tar.gz: 99e6734a053804f6104409822ac2292c26bcd373d060f34611a1e0fd20be3aa3
5
5
  SHA512:
6
- metadata.gz: 85c8b1febf77dd9971637dd54b9bef89d966fb934dc2ec639cd41c33cd6ec11b82e478f136e802ac9e6b8653d4e57b72abf75f87f7fe0814683222828d60db65
7
- data.tar.gz: 2fd24846567dc7e1569ee932e7e0674ab893c67061fd1007cf57366efb4220309dc62405587dd2d701c2366b864fc32144024cf8ef5312245c00dc45a1d70af0
6
+ metadata.gz: 3c8cf25173e9282dc101252ca6f494b94dcbc5c7baa6dd9283320aae47e9413a6139f78956ba999ed24aa4a876278f0f45fcede73a8b821039960ce4d8326e22
7
+ data.tar.gz: e96bbc23377e38e7bcd36239adb8e5b05c4d8488601972f744f5484d1b569e5a35de85fb56de6b89f912e525728ed3200c08c78c0c81db8ed932e79e86338c77
@@ -17,6 +17,10 @@ module CI
17
17
 
18
18
  attr_accessor :shuffler
19
19
 
20
+ module Warnings
21
+ RESERVED_LOST_TEST = :RESERVED_LOST_TEST
22
+ end
23
+
20
24
  def shuffle(tests, random)
21
25
  if shuffler
22
26
  shuffler.call(tests, random)
@@ -20,6 +20,19 @@ module CI
20
20
  redis.hkeys(key('error-reports'))
21
21
  end
22
22
 
23
+ def pop_warnings
24
+ warnings = redis.multi do
25
+ redis.lrange(key('warnings'), 0, -1)
26
+ redis.del(key('warnings'))
27
+ end.first
28
+
29
+ warnings.map { |p| Marshal.load(p) }
30
+ end
31
+
32
+ def record_warning(type, attributes)
33
+ redis.rpush(key('warnings'), Marshal.dump([type, attributes]))
34
+ end
35
+
23
36
  def record_error(id, payload, stats: nil)
24
37
  redis.pipelined do
25
38
  redis.hset(
@@ -18,10 +18,14 @@ module CI
18
18
  def wait_for_workers
19
19
  return false unless wait_for_master(timeout: config.timeout)
20
20
 
21
+ yield if block_given?
22
+
21
23
  time_left = config.timeout
22
24
  until exhausted? || time_left <= 0
23
- sleep 0.1
24
- time_left -= 0.1
25
+ sleep 1
26
+ time_left -= 1
27
+
28
+ yield if block_given?
25
29
  end
26
30
  exhausted?
27
31
  rescue CI::Queue::Redis::LostMaster
@@ -46,7 +46,7 @@ module CI
46
46
  wait_for_master
47
47
  until shutdown_required? || config.circuit_breaker.open? || exhausted?
48
48
  if test = reserve
49
- yield index.fetch(test)
49
+ yield index.fetch(test), @last_warning
50
50
  else
51
51
  sleep 0.05
52
52
  end
@@ -140,11 +140,17 @@ module CI
140
140
  end
141
141
 
142
142
  def try_to_reserve_lost_test
143
- eval_script(
143
+ lost_test = eval_script(
144
144
  :reserve_lost,
145
145
  keys: [key('running'), key('completed'), key('worker', worker_id, 'queue')],
146
146
  argv: [Time.now.to_f, timeout],
147
147
  )
148
+
149
+ if lost_test
150
+ build.record_warning(Warnings::RESERVED_LOST_TEST, test: lost_test, timeout: timeout)
151
+ end
152
+
153
+ lost_test
148
154
  end
149
155
 
150
156
  def push(tests)
@@ -1,6 +1,6 @@
1
1
  module CI
2
2
  module Queue
3
- VERSION = '0.15.1'
3
+ VERSION = '0.16.0'
4
4
  DEV_SCRIPTS_ROOT = ::File.expand_path('../../../../../redis', __FILE__)
5
5
  RELEASE_SCRIPTS_ROOT = ::File.expand_path('../redis', __FILE__)
6
6
  end
@@ -133,7 +133,7 @@ module Minitest
133
133
 
134
134
  step("Waiting for workers to complete")
135
135
 
136
- unless supervisor.wait_for_workers
136
+ unless supervisor.wait_for_workers { display_warnings(supervisor.build) }
137
137
  unless supervisor.queue_initialized?
138
138
  abort! "No master was elected. Did all workers crash?"
139
139
  end
@@ -153,6 +153,20 @@ module Minitest
153
153
  attr_reader :queue_config, :options, :command, :argv
154
154
  attr_accessor :queue, :queue_url, :load_paths
155
155
 
156
+ def display_warnings(build)
157
+ build.pop_warnings.each do |type, attributes|
158
+ case type
159
+ when CI::Queue::Warnings::RESERVED_LOST_TEST
160
+ puts reopen_previous_step
161
+ puts yellow(
162
+ "[WARNING] #{attributes[:test]} was picked up by another worker because it didn't complete in the allocated #{attributes[:timeout]} seconds.\n" \
163
+ "You may want to either optimize this test of bump ci-queue timeout.\n" \
164
+ "It's also possible that the worker that was processing it was terminated without being able to report back.\n"
165
+ )
166
+ end
167
+ end
168
+ end
169
+
156
170
  def run_tests_in_fork(queue)
157
171
  child_pid = fork do
158
172
  Minitest.queue = queue
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ci-queue
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.1
4
+ version: 0.16.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jean Boussier
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-03-05 00:00:00.000000000 Z
11
+ date: 2019-03-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ansi