ci-queue 0.57.0 → 0.58.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: f7d14c6d18d859390f4213fd8d9c6d0a94578439ae8d8ca499584d382992bca8
4
- data.tar.gz: 433999764455024fe84cf5758434a706415e612afe1a2460a1235fb3fc5e41d3
3
+ metadata.gz: 0302564aa747e3b115328f8e8a09ba89e319631c885eb6250236a4f53d5d4b3f
4
+ data.tar.gz: c09e4e48c6fcded24e23673d39beb5374960e95ac47a1f74805dce6e868c1ae8
5
5
  SHA512:
6
- metadata.gz: ed7e6c1547cbf90a00b3b80e8229dc13ba8803453de9d6af291a51add17023ddf1745c0a96ff424737e08d6bffd6cbd51e5c9e60c3acfb0263d01c03c60083a7
7
- data.tar.gz: 5519db14c36093f0f4c0b5109764c3a4029f411a4b73436047ebae9fd1be7c0559ceea48a7f48cf8de4ea372ab0c3a0269cb250f05aeff28f501f252aeddc379
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.57.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)
@@ -2,7 +2,7 @@
2
2
 
3
3
  module CI
4
4
  module Queue
5
- VERSION = '0.57.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.57.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-08-05 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