ci-queue 0.56.0 → 0.58.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e463afd14fdd0af687967316891f41c3f6e8f227eeb4924b12448ce91749cf74
4
- data.tar.gz: db803750f16b9a10ee3c5498b4c1eaa5df768247d39d7efa2abc3ae15a6efc00
3
+ metadata.gz: 0302564aa747e3b115328f8e8a09ba89e319631c885eb6250236a4f53d5d4b3f
4
+ data.tar.gz: c09e4e48c6fcded24e23673d39beb5374960e95ac47a1f74805dce6e868c1ae8
5
5
  SHA512:
6
- metadata.gz: b99390737597eb6c3eb2faadff1dbb64b9dcd03b9a9906ed287350e35b164f60ea913e29227ebead7ebc98e10a088e394ae23051ed3c240d8c7b97b6bcb77cee
7
- data.tar.gz: 6382ff6e7c0a486de687268b259046616c8299990b426255a415142e247991c38b7271cb31b4de0ded5dfe9ed12e20480fe7514a16542372a96e9ca6a650f7d4
6
+ metadata.gz: d885b7fd5fbaaefb1fb3271a5364285b0b4a16a2e58449beae1e9f1a8e430f9e48554f7e707299124b4ae132e0122679b8a2c1163f4d22e2707a03fdba3f09b4
7
+ data.tar.gz: daa111f58048ce32e754698858305ed48d68f35e4d60a023b5263674d3151386cb395a36e1a40b6926ae874b1b4187567b9937632deedc77a474b63d34c5f9b2
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ci-queue (0.56.0)
4
+ ci-queue (0.58.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -13,16 +13,18 @@ module CI
13
13
 
14
14
  module RedisInstrumentation
15
15
  def call(command, redis_config)
16
- result = super
17
16
  logger = redis_config.custom[:debug_log]
18
- logger.info("#{command}: #{result}")
17
+ logger.info("Running '#{command}'")
18
+ result = super
19
+ logger.info("Finished '#{command}': #{result}")
19
20
  result
20
21
  end
21
22
 
22
23
  def call_pipelined(commands, redis_config)
23
- result = super
24
24
  logger = redis_config.custom[:debug_log]
25
- logger.info("#{commands}: #{result}")
25
+ logger.info("Running '#{commands}'")
26
+ result = super
27
+ logger.info("Finished '#{commands}': #{result}")
26
28
  result
27
29
  end
28
30
  end
@@ -185,6 +187,20 @@ module CI
185
187
 
186
188
  attr_reader :redis, :redis_url
187
189
 
190
+ def with_redis_timeout(timeout)
191
+ prev = redis._client.timeout
192
+ redis._client.timeout = timeout
193
+ yield
194
+ ensure
195
+ redis._client.timeout = prev
196
+ end
197
+
198
+ def measure
199
+ starting = Process.clock_gettime(Process::CLOCK_MONOTONIC)
200
+ yield
201
+ Process.clock_gettime(Process::CLOCK_MONOTONIC) - starting
202
+ end
203
+
188
204
  def key(*args)
189
205
  ['build', build_id, *args].join(':')
190
206
  end
@@ -47,12 +47,6 @@ module CI
47
47
 
48
48
  private
49
49
 
50
- def measure
51
- starting = Process.clock_gettime(Process::CLOCK_MONOTONIC)
52
- yield
53
- Process.clock_gettime(Process::CLOCK_MONOTONIC) - starting
54
- end
55
-
56
50
  def active_workers?
57
51
  # if there are running jobs we assume there are still agents active
58
52
  redis.zrangebyscore(key('running'), CI::Queue.time_now.to_f - config.timeout, "+inf", limit: [0,1]).count > 0
@@ -204,15 +204,35 @@ module CI
204
204
  @total = tests.size
205
205
 
206
206
  if @master = redis.setnx(key('master-status'), 'setup')
207
- redis.multi do |transaction|
208
- transaction.lpush(key('queue'), tests) unless tests.empty?
209
- transaction.set(key('total'), @total)
210
- transaction.set(key('master-status'), 'ready')
211
-
212
- transaction.expire(key('queue'), config.redis_ttl)
213
- transaction.expire(key('total'), config.redis_ttl)
214
- transaction.expire(key('master-status'), config.redis_ttl)
207
+ puts "Worker electected as leader, pushing #{@total} tests to the queue."
208
+ puts
209
+
210
+ attempts = 0
211
+ duration = measure do
212
+ with_redis_timeout(5) do
213
+ redis.without_reconnect do
214
+ redis.multi do |transaction|
215
+ transaction.lpush(key('queue'), tests) unless tests.empty?
216
+ transaction.set(key('total'), @total)
217
+ transaction.set(key('master-status'), 'ready')
218
+
219
+ transaction.expire(key('queue'), config.redis_ttl)
220
+ transaction.expire(key('total'), config.redis_ttl)
221
+ transaction.expire(key('master-status'), config.redis_ttl)
222
+ end
223
+ end
224
+ rescue ::Redis::BaseError => error
225
+ if !queue_initialized? && attempts < 3
226
+ puts "Retrying pushing #{@total} tests to the queue... (#{error})"
227
+ attempts += 1
228
+ retry
229
+ end
230
+
231
+ raise if !queue_initialized?
232
+ end
215
233
  end
234
+
235
+ puts "Finished pushing #{@total} tests to the queue in #{duration.round(2)}s."
216
236
  end
217
237
  register
218
238
  redis.expire(key('workers'), config.redis_ttl)
@@ -58,6 +58,8 @@ module CI
58
58
 
59
59
  def stop_heartbeat!; end
60
60
 
61
+ def report_worker_error(error); end
62
+
61
63
  def created_at=(timestamp)
62
64
  @created_at ||= timestamp
63
65
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module CI
4
4
  module Queue
5
- VERSION = '0.56.0'
5
+ VERSION = '0.58.0'
6
6
  DEV_SCRIPTS_ROOT = ::File.expand_path('../../../../../redis', __FILE__)
7
7
  RELEASE_SCRIPTS_ROOT = ::File.expand_path('../redis', __FILE__)
8
8
  end
@@ -223,7 +223,7 @@ module Minitest
223
223
 
224
224
  failing_order = queue.candidates
225
225
  step("Final validation")
226
- status = if run_tests_in_fork(failing_order)
226
+ if run_tests_in_fork(failing_order)
227
227
  step(yellow("The bisection was inconclusive, there might not be any leaky test here."))
228
228
  File.write('log/test_order.log', "")
229
229
  exit! 1
@@ -314,7 +314,8 @@ module Minitest
314
314
  private
315
315
 
316
316
  attr_reader :queue_config, :options, :command, :argv
317
- attr_accessor :queue, :queue_url, :grind_list, :grind_count, :load_paths, :verbose
317
+ attr_writer :queue_url
318
+ attr_accessor :queue, :grind_list, :grind_count, :load_paths, :verbose
318
319
 
319
320
  def require_worker_id!
320
321
  if queue.distributed?
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.56.0
4
+ version: 0.58.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: 2024-07-24 00:00:00.000000000 Z
11
+ date: 2024-10-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -242,7 +242,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
242
242
  - !ruby/object:Gem::Version
243
243
  version: '0'
244
244
  requirements: []
245
- rubygems_version: 3.5.16
245
+ rubygems_version: 3.5.20
246
246
  signing_key:
247
247
  specification_version: 4
248
248
  summary: Distribute tests over many workers using a queue